anthropic

package
v1.9.2 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Package anthropic connects to the Anthropic Messages API.

Index

Constants

View Source
const (
	ProviderOptionMetadata          = "metadata"
	ProviderOptionServiceTier       = "service_tier"
	ProviderOptionTopK              = "top_k"
	ProviderOptionContextManagement = "context_management"
	ProviderOptionContainer         = "container"
	ProviderOptionMCPServers        = "mcp_servers"
	ProviderOptionTools             = "tools"
	ProviderOptionOutputConfig      = "output_config"
	// ProviderOptionToolChoice is merged into the generated tool_choice, e.g.
	// {"disable_parallel_tool_use": true}.
	ProviderOptionToolChoice = "tool_choice"
)

ProviderOptions are native Messages API fields copied into the body. An option naming a generated object or array is merged into or appended to it, e.g. server tools under "tools".

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// APIKey authenticates requests; APIKeyFunc, when set, resolves it per
	// request instead.
	APIKey     string
	APIKeyFunc func(context.Context) (string, error)
	// BaseURL is the API origin, https://api.anthropic.com by default.
	BaseURL string
	// HTTPClient sends requests; nil uses http.DefaultClient. Wrap it with
	// retry.NewHTTPClient to retry.
	HTTPClient litellm.HTTPClient
	UserAgent  string
	// Headers are set after the defaults, so they can override them. Use them
	// for anthropic-beta, or to change anthropic-version from 2023-06-01.
	Headers map[string]string
}

Config configures the Messages API client. An API key is required.

type Provider

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

Provider implements litellm.Provider and litellm.CapabilityProvider.

func New

func New(cfg Config) (*Provider, error)

New returns a Provider for cfg.

func (*Provider) Capabilities added in v1.8.1

func (p *Provider) Capabilities() litellm.Capabilities

Capabilities reports the static protocol facts.

func (*Provider) Chat

func (p *Provider) Chat(ctx context.Context, req *litellm.Request) (*litellm.Response, error)

Chat sends a Messages request.

func (*Provider) Name

func (p *Provider) Name() string

Name returns "anthropic".

func (*Provider) Stream

func (p *Provider) Stream(ctx context.Context, req *litellm.Request) (litellm.Stream, error)

Stream sends a streaming Messages request.

Jump to

Keyboard shortcuts

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