anthropic

package
v0.0.0-...-5fe9b4e Latest Latest
Warning

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

Go to latest
Published: Apr 28, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Overview

Package anthropic provides Anthropic API integration for the LLM gateway.

Index

Constants

This section is empty.

Variables

View Source
var Registration = providers.Registration{
	Type:                        "anthropic",
	New:                         New,
	PassthroughSemanticEnricher: passthroughSemanticEnricher{},
	Discovery: providers.DiscoveryConfig{
		DefaultBaseURL: defaultBaseURL,
	},
}

Registration provides factory registration for the Anthropic provider.

Functions

func New

New creates a new Anthropic provider.

Types

type Provider

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

Provider implements the core.Provider interface for Anthropic

func NewWithHTTPClient

func NewWithHTTPClient(apiKey string, httpClient *http.Client, hooks llmclient.Hooks) *Provider

NewWithHTTPClient creates a new Anthropic provider with a custom HTTP client. If httpClient is nil, http.DefaultClient is used.

func (*Provider) CancelBatch

func (p *Provider) CancelBatch(ctx context.Context, id string) (*core.BatchResponse, error)

CancelBatch cancels an Anthropic native message batch.

func (*Provider) ChatCompletion

func (p *Provider) ChatCompletion(ctx context.Context, req *core.ChatRequest) (*core.ChatResponse, error)

ChatCompletion sends a chat completion request to Anthropic

func (*Provider) ClearBatchResultHints

func (p *Provider) ClearBatchResultHints(batchID string)

ClearBatchResultHints clears transient per-batch endpoint hints once they have been persisted by the gateway.

func (*Provider) CreateBatch

func (p *Provider) CreateBatch(ctx context.Context, req *core.BatchRequest) (*core.BatchResponse, error)

CreateBatch creates an Anthropic native message batch.

func (*Provider) CreateBatchWithHints

func (p *Provider) CreateBatchWithHints(ctx context.Context, req *core.BatchRequest) (*core.BatchResponse, map[string]string, error)

CreateBatchWithHints creates an Anthropic native message batch and returns persisted per-item endpoint hints for later result shaping.

func (*Provider) Embeddings

Embeddings returns an error because Anthropic does not natively support embeddings. Voyage AI (Anthropic's recommended embedding provider) may be added in the future.

func (*Provider) GetBatch

func (p *Provider) GetBatch(ctx context.Context, id string) (*core.BatchResponse, error)

GetBatch retrieves an Anthropic native message batch.

func (*Provider) GetBatchResults

func (p *Provider) GetBatchResults(ctx context.Context, id string) (*core.BatchResultsResponse, error)

GetBatchResults retrieves Anthropic native message batch results.

func (*Provider) GetBatchResultsWithHints

func (p *Provider) GetBatchResultsWithHints(ctx context.Context, id string, endpointByCustomID map[string]string) (*core.BatchResultsResponse, error)

GetBatchResultsWithHints retrieves Anthropic native batch results using persisted per-item endpoint hints instead of transient in-memory state.

func (*Provider) ListBatches

func (p *Provider) ListBatches(ctx context.Context, limit int, after string) (*core.BatchListResponse, error)

ListBatches lists Anthropic native message batches.

func (*Provider) ListModels

func (p *Provider) ListModels(ctx context.Context) (*core.ModelsResponse, error)

ListModels retrieves the list of available models from Anthropic's /v1/models endpoint

func (*Provider) Passthrough

Passthrough forwards an opaque Anthropic-native request without typed translation.

func (*Provider) Responses

Responses sends a Responses API request to Anthropic (converted to messages format)

func (*Provider) SetBaseURL

func (p *Provider) SetBaseURL(url string)

SetBaseURL allows configuring a custom base URL for the provider

func (*Provider) StreamChatCompletion

func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)

StreamChatCompletion returns a raw response body for streaming (caller must close)

func (*Provider) StreamResponses

func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)

StreamResponses returns a raw response body for streaming Responses API (caller must close)

Jump to

Keyboard shortcuts

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