Documentation
¶
Overview ¶
Package cohere implements the Provider interface against Cohere's OpenAI-compatibility endpoint (https://api.cohere.ai/compatibility/v1), reusing the openai-go SDK — no new dependency. Structured output is prompt-driven (no response_format); JSON shape comes from the system prompt's contract plus the retry-once-then-degrade pipeline (ADR-0014 §4), the same way Ollama works.
Index ¶
- Constants
- func IsModelSupported(model string) bool
- func Metadata() provider.Metadata
- func Models() []string
- func New(cfg config.ProviderConfig) (provider.Provider, error)
- type Client
- func (c *Client) ContextWindow(model string) int
- func (c *Client) DefaultModel() string
- func (c *Client) EstimateTokens(s string) int
- func (c *Client) Name() string
- func (c *Client) Pricing(model string) provider.Pricing
- func (c *Client) Review(ctx context.Context, req provider.Request) (provider.Response, error)
- func (c *Client) TestConnection(ctx context.Context) error
Constants ¶
const ( Name = "cohere" // The bare command-r-plus / command-r aliases point at the 2024-03/04 // releases Cohere deprecated on 2025-09-15; the catalog pins the dated // 08-2024 releases Cohere names as their replacements. ModelCommandRPlus = "command-r-plus-08-2024" ModelCommandR = "command-r-08-2024" ModelCommandA = "command-a-03-2025" DefaultModel = ModelCommandRPlus )
Variables ¶
This section is empty.
Functions ¶
func IsModelSupported ¶
func Metadata ¶ added in v1.17.0
Metadata describes cohere without needing a credential, so documentation can list every model, context window and price for a reader who has never configured this provider. See ADR-0039.
Every field is derived from this package's own tables — supportedModels for the set and its order, contextWindowFor and pricingFor for the numbers — so adding a model there surfaces it here automatically. A hand-written literal would just relocate the duplication.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}