cohere

package
v0.1.61 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 26, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package cohere provides Cohere API v2 integration for the LLM gateway.

Index

Constants

This section is empty.

Variables

View Source
var Registration = providers.Registration{
	Type: "cohere",
	New:  New,
	Discovery: providers.DiscoveryConfig{
		DefaultBaseURL: defaultBaseURL,
	},
}

Registration provides factory registration for the Cohere provider.

Functions

func New

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

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

Embeddings translates OpenAI-compatible embedding requests to Cohere v2.

func (*Provider) ListModels

func (p *Provider) ListModels(ctx context.Context) (*core.ModelsResponse, error)

ListModels returns Cohere's model catalog in OpenAI-compatible form.

func (*Provider) Passthrough

Passthrough forwards a Cohere-native request without typed translation.

func (*Provider) Responses

Responses translates the OpenAI Responses API through Cohere chat.

func (*Provider) SetBaseURL

func (p *Provider) SetBaseURL(baseURL string)

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL