Documentation
¶
Overview ¶
Package anthropic implements agent.LLMProvider for Anthropic's Claude models via the Messages API, including prompt caching, adaptive thinking, and native structured output.
Index ¶
Constants ¶
const DefaultMaxTokens int64 = 8192
DefaultMaxTokens is the per-call Anthropic MaxTokens used when no override is provided. 8192 catches typical chat + tool-use turns without truncating most code-gen workloads. Bump via WithMaxTokens for long structured outputs (HTML5 playables, full schema dumps, inline charts) — Sonnet 4.6 supports up to 64K.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option func(*Provider)
Option configures a Provider at construction.
func WithEffort ¶ added in v0.47.0
WithEffort sends output_config.effort verbatim on every request and takes precedence over the effort derived from agent.ThinkingBudget. Unset (or "") keeps the model's default. The value is not validated: the accepted set ("low", "medium", "high", "xhigh", "max") differs per model, and the API rejects what a model does not support.
func WithMaxTokens ¶
WithMaxTokens overrides the per-call Anthropic MaxTokens. Use for code-generation, long structured output, or any workload where the default truncates mid-stream.
func WithTemperature ¶
WithTemperature pins the sampling temperature (0.0–1.0 for Anthropic). Use 0 for maximally reproducible classification/extraction turns; unset keeps the provider default. Ignored while thinking is enabled — the API rejects sampling overrides alongside thinking. Anthropic exposes no seed parameter, so temperature 0 is best-effort reproducibility, not bit-exact.
Models from Claude Opus 4.7 on reject temperature and top_p outright ("temperature is deprecated for this model"). The option is sent as given, so leave it unset for those models.
type Provider ¶
type Provider struct {
MaxTokens int64
// contains filtered or unexported fields
}
Provider implements agent.LLMProvider using the Anthropic Messages API (Claude).
func New ¶
New creates a Claude-backed provider. Auto-discovers ANTHROPIC_API_KEY from environment if apiKey is empty.
func (*Provider) Capabilities ¶ added in v0.40.0
func (*Provider) Capabilities() agent.LLMCapabilities
Capabilities reports features implemented by the Anthropic adapter.