Documentation
¶
Overview ¶
Package cohere provides Cohere API v2 integration for the LLM gateway.
Index ¶
- Variables
- func New(cfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
- type Provider
- func (p *Provider) ChatCompletion(ctx context.Context, req *core.ChatRequest) (*core.ChatResponse, error)
- func (p *Provider) CreateSpeech(_ context.Context, _ *core.AudioSpeechRequest) (*core.AudioResponse, error)
- func (p *Provider) CreateTranscription(ctx context.Context, req *core.AudioTranscriptionRequest) (*core.AudioResponse, error)
- func (p *Provider) Embeddings(ctx context.Context, req *core.EmbeddingRequest) (*core.EmbeddingResponse, error)
- func (p *Provider) ListModels(ctx context.Context) (*core.ModelsResponse, error)
- func (p *Provider) Passthrough(ctx context.Context, req *core.PassthroughRequest) (*core.PassthroughResponse, error)
- func (p *Provider) Responses(ctx context.Context, req *core.ResponsesRequest) (*core.ResponsesResponse, error)
- func (p *Provider) SetBaseURL(baseURL string)
- func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)
- func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)
Constants ¶
This section is empty.
Variables ¶
var Registration = providers.Registration{ Type: "cohere", New: New, Discovery: providers.DiscoveryConfig{ DefaultBaseURL: defaultBaseURL, }, }
Registration provides factory registration for the Cohere provider.
Functions ¶
func New ¶
func New(cfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
New creates a Cohere provider using the shared resilience and observability settings.
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements Cohere's native v2 chat and embedding APIs.
func NewWithHTTPClient ¶
func NewWithHTTPClient(apiKey, baseURL string, httpClient *http.Client, hooks llmclient.Hooks) *Provider
NewWithHTTPClient creates a Cohere provider with a custom HTTP client.
func (*Provider) ChatCompletion ¶
func (p *Provider) ChatCompletion(ctx context.Context, req *core.ChatRequest) (*core.ChatResponse, error)
ChatCompletion translates an OpenAI-compatible chat request to Cohere v2.
func (*Provider) CreateSpeech ¶
func (p *Provider) CreateSpeech(_ context.Context, _ *core.AudioSpeechRequest) (*core.AudioResponse, error)
CreateSpeech reports that Cohere has no text-to-speech API. AudioProvider currently groups speech and transcription into one optional capability, so a transcription-only provider must still implement this method.
func (*Provider) CreateTranscription ¶
func (p *Provider) CreateTranscription(ctx context.Context, req *core.AudioTranscriptionRequest) (*core.AudioResponse, error)
CreateTranscription translates the OpenAI-compatible multipart request to Cohere's native POST /v2/audio/transcriptions endpoint.
func (*Provider) Embeddings ¶
func (p *Provider) Embeddings(ctx context.Context, req *core.EmbeddingRequest) (*core.EmbeddingResponse, error)
Embeddings translates OpenAI-compatible embedding requests to Cohere v2.
func (*Provider) ListModels ¶
ListModels returns Cohere's model catalog in OpenAI-compatible form.
func (*Provider) Passthrough ¶
func (p *Provider) Passthrough(ctx context.Context, req *core.PassthroughRequest) (*core.PassthroughResponse, error)
Passthrough forwards a Cohere-native request without typed translation.
func (*Provider) Responses ¶
func (p *Provider) Responses(ctx context.Context, req *core.ResponsesRequest) (*core.ResponsesResponse, error)
Responses translates the OpenAI Responses API through Cohere chat.
func (*Provider) SetBaseURL ¶
SetBaseURL changes the Cohere API base URL.
func (*Provider) StreamChatCompletion ¶
func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)
StreamChatCompletion translates Cohere's event stream to OpenAI chat chunks.
func (*Provider) StreamResponses ¶
func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)
StreamResponses translates a streaming OpenAI Responses request through Cohere chat.