anthropic

package
v0.36.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2026 License: Apache-2.0 Imports: 11 Imported by: 2 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package anthropic implements agent.LLMProvider for Anthropic's Claude models via the Messages API, including prompt caching, extended thinking, and structured output (synthesized-tool JSON mode).

Index

Constants

View Source
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 WithMaxTokens

func WithMaxTokens(n int64) Option

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

func WithTemperature(t float64) Option

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 extended 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.

func WithTopP

func WithTopP(v float64) Option

WithTopP pins nucleus sampling. Anthropic recommends adjusting either temperature or top_p, not both. Unset keeps the provider default. Ignored while extended thinking is enabled.

type Provider

type Provider struct {
	MaxTokens int64
	// contains filtered or unexported fields
}

Provider implements agent.LLMProvider using the Anthropic Messages API (Claude).

func New

func New(apiKey string, model string, opts ...Option) (*Provider, error)

New creates a Claude-backed provider. Auto-discovers ANTHROPIC_API_KEY from environment if apiKey is empty.

func (*Provider) GenerateStream

func (p *Provider) GenerateStream(ctx context.Context, memory []history.Message, availableTools *tools.Registry, streamChan chan<- agent.StreamEvent) (agent.LLMResult, error)

Jump to

Keyboard shortcuts

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