anthropic

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: AGPL-3.0 Imports: 11 Imported by: 0

Documentation

Overview

Package anthropic adapts the official anthropics/anthropic-sdk-go into an agentcore.Model. It targets the Anthropic Messages API directly (MODEL_MODE=anthropic).

The adapter owns no policy: it forwards whatever per-request headers the loop supplies and sends an Authorization header only when an API key is configured. Attribution headers and credential isolation are decided by the caller, keeping this adapter provider-faithful and reusable.

Index

Constants

View Source
const DefaultMaxTokens = 4096

DefaultMaxTokens is the max_tokens sent when a request does not specify one (the Anthropic API requires the field).

Variables

This section is empty.

Functions

This section is empty.

Types

type Model

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

Model is an agentcore.Model backed by the Anthropic Messages API.

func New

func New(opts Options) *Model

New constructs a Model from opts.

func (*Model) ModelID

func (m *Model) ModelID() string

ModelID implements agentcore.Model.

func (*Model) Stream

Stream implements agentcore.Model. It opens a streaming Messages request, emits text deltas as they arrive, then emits one tool call per tool_use block and a terminal step-finish carrying normalized usage.

type Options

type Options struct {
	// ModelID is the Anthropic model id (e.g. "claude-sonnet-4-6").
	ModelID string
	// APIKey is the Anthropic API key. Empty means no Authorization header.
	APIKey string
	// BaseURL overrides the API base URL. Empty uses the SDK default.
	BaseURL string
	// HTTPClient overrides the HTTP client (custom CA, TLS settings). Nil
	// uses the SDK default.
	HTTPClient *http.Client
}

Options configures a Model. ModelID is required. APIKey enables the standard Anthropic endpoint; leave it empty (and set BaseURL) to route through a gateway that injects the upstream credential itself, in which case no Authorization header is sent.

Jump to

Keyboard shortcuts

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