provider-implementation

Provider Implementation

Safety Notice

This listing is imported from skills.sh public index metadata. Review upstream SKILL.md and repository scripts before running.

Copy this and send it to your AI assistant to learn

Install skill "provider-implementation" with this command: npx skills add lookatitude/beluga-ai/lookatitude-beluga-ai-provider-implementation

Provider Implementation

Checklist

  • Implement the full interface (ChatModel, Embedder, VectorStore, STT, TTS, etc.).

  • Register via init() with parent package's Register() .

  • Map provider errors to core.Error with correct ErrorCode.

  • Support context cancellation.

  • Include token/usage metrics where applicable.

  • Compile-time check: var _ Interface = (*Impl)(nil) .

  • Unit tests with mocked HTTP responses (httptest).

File Structure

llm/providers/openai/ ├── openai.go # Implementation + New() + init() ├── stream.go # Streaming ├── errors.go # Error mapping ├── openai_test.go # Tests └── testdata/ # Recorded HTTP responses

Template

var _ llm.ChatModel = (*Model)(nil)

func init() { llm.Register("openai", func(cfg llm.ProviderConfig) (llm.ChatModel, error) { return New(cfg) }) }

func New(cfg llm.ProviderConfig) (*Model, error) { if cfg.APIKey == "" { return nil, &core.Error{Op: "openai.new", Code: core.ErrAuth, Message: "API key required"} } return &Model{client: newClient(cfg.APIKey, cfg.BaseURL), model: cfg.Model}, nil }

func (m Model) Stream(ctx context.Context, msgs []schema.Message, opts ...llm.GenerateOption) iter.Seq2[schema.StreamChunk, error] { return func(yield func(schema.StreamChunk, error) bool) { / stream implementation */ } }

Error Mapping

switch apiErr.StatusCode { case 401: code = core.ErrAuth case 429: code = core.ErrRateLimit case 408, 504: code = core.ErrTimeout case 400: code = core.ErrInvalidInput }

See docs/providers.md for provider categories and priorities.

Source Transparency

This detail page is rendered from real SKILL.md content. Trust labels are metadata-based hints, not a safety guarantee.

Related Skills

Related by shared tags or category signals.

General

streaming-patterns

No summary provided by upstream source.

Repository SourceNeeds Review
General

go-interfaces

No summary provided by upstream source.

Repository SourceNeeds Review
General

go-framework

No summary provided by upstream source.

Repository SourceNeeds Review
General

doc-writing

No summary provided by upstream source.

Repository SourceNeeds Review