Documentation
¶
Index ¶
Constants ¶
const ( AnthropicVersion = "2023-06-01" BetaInterleavedThinking = "interleaved-thinking-2025-05-14" )
const ( // Claude 4.6 (current). ModelOpus = "claude-opus-4-6" ModelSonnet = "claude-sonnet-4-6" // Claude 4.5 (Haiku latest). ModelHaiku = "claude-haiku-4-5-20251001" )
Model ID constants for programmatic use.
Variables ¶
var ModelAliases = map[string]string{ "opus": ModelOpus, "sonnet": ModelSonnet, "haiku": ModelHaiku, }
ModelAliases maps short alias names to full model IDs. These are used by the auto package for provider-prefixed resolution (e.g., "claude/sonnet").
Functions ¶
func CoerceAnthropicThinkingTemperature ¶ added in v0.40.0
func CoerceAnthropicThinkingTemperature(msgReq *providercore2.MessagesRequest)
func DefaultOptions ¶ added in v0.12.0
func DoCountTokensAPI ¶ added in v0.40.0
func DoCountTokensAPI( ctx context.Context, client *http.Client, baseURL, apiKey string, extraHeaders map[string]string, apiReq *providercore.MessagesRequest, ) (int, error)
DoCountTokensAPI is the shared implementation for the Anthropic count_tokens endpoint, usable by both the direct Anthropic provider and the Claude OAuth provider. extraHeaders are appended to the request (e.g. OAuth Authorization).
Types ¶
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
func (*Provider) CountTokensAPI ¶ added in v0.40.0
func (p *Provider) CountTokensAPI(ctx context.Context, apiReq *providercore.MessagesRequest) (int, error)
CountTokensAPI calls the Anthropic /v1/messages/count_tokens endpoint to get an exact token count for the given request. This is free and does not consume message rate limits, but adds one HTTP round-trip.
The returned count is exact (not a heuristic approximation). It includes tool definitions, system prompts, images, PDFs, and thinking blocks.