Documentation
¶
Overview ¶
Package anthropic implements Anthropic's Messages API using llm's neutral request, response, tool, and stream contracts. It supports generation, image input and image tool results, signed/redacted thinking replay, prompt cache controls, non-streaming client tool use, and typed text/thinking/tool streaming. Anthropic Messages has no audio input content block, so CapabilityAudio is unsupported. JSON response mode is not implemented.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIError ¶
type APIError struct {
Type string `json:"type"`
Message string `json:"message"`
RequestID string `json:"-"`
}
APIError is an error returned by Anthropic's API.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is an immutable Anthropic client. It is safe for concurrent use when its configured HTTP client is safe for concurrent use.
func NewWithOptions ¶
NewWithOptions constructs a Client with model compatibility overrides.
type Config ¶
type Config struct {
Provider string
Model string
Capabilities []llm.Capability
APIKey string
AccessToken string
BaseURL string
APIVersion string
DefaultMaxOutputTokens int
HTTPClient *http.Client
Headers http.Header
}
Config configures an Anthropic-compatible client. Model is required. Provider identifies the service in ModelInfo and errors; it defaults to "anthropic". BaseURL defaults to https://api.anthropic.com/v1, APIVersion defaults to 2023-06-01, and DefaultMaxOutputTokens defaults to 4096. Capabilities opts the configured model into optional protocol features; generation is always enabled, while streaming, client tool use, and vision must be listed explicitly. APIKey is optional to support gateways that authenticate through custom Headers. AccessToken selects Anthropic's provider-private Claude subscription OAuth identity, including its bearer, beta, CLI identity headers, and mandatory system identity; this unofficial flow is unstable. A non-nil HTTPClient and custom Headers are used as supplied, without being mutated by Client. A nil HTTPClient uses http.DefaultClient, which has no overall request timeout; callers should use context deadlines or configure a client timeout.
type Options ¶
type Options struct {
// ModelCompatibility is copied during construction.
ModelCompatibility *llm.AnthropicCompatibility
}
Options configures model-specific Anthropic protocol compatibility.