anthropic

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2026 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Overview

Package anthropic provides a ModelProvider adapter for the Anthropic Messages API.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Option

type Option func(*providerOpts)

Option is a functional option for configuring Provider.

func WithAPIKey

func WithAPIKey(key string) Option

WithAPIKey sets the Anthropic API key.

func WithHTTPClient

func WithHTTPClient(c *http.Client) Option

WithHTTPClient sets a custom HTTP client.

func WithPromptCaching

func WithPromptCaching() Option

WithPromptCaching enables cache_control blocks on system and first user message.

func WithVersion

func WithVersion(v string) Option

WithVersion sets the Anthropic API version (default "2023-06-01").

type Provider

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

Provider implements runtime.ModelProvider for Anthropic's Messages API.

func New

func New(opts ...Option) *Provider

New creates a new Provider for the default Anthropic API endpoint.

func NewWithBaseURL

func NewWithBaseURL(baseURL string, opts ...Option) *Provider

NewWithBaseURL creates a new Provider with a custom base URL (for testing).

func (*Provider) Complete

func (p *Provider) Complete(ctx context.Context, req model.Request) (model.Response, error)

Complete sends a request to the Anthropic API and returns the complete response.

func (*Provider) Stream

func (p *Provider) Stream(ctx context.Context, req model.Request) (runtime.StreamReader, error)

Stream sends a request to the Anthropic API and returns a StreamReader.

Jump to

Keyboard shortcuts

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