Documentation
¶
Overview ¶
Package anthropic provides Anthropic API integration for the LLM gateway.
Index ¶
- Variables
- func New(providerCfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
- type Provider
- func (p *Provider) CancelBatch(ctx context.Context, id string) (*core.BatchResponse, error)
- func (p *Provider) ChatCompletion(ctx context.Context, req *core.ChatRequest) (*core.ChatResponse, error)
- func (p *Provider) ClearBatchResultHints(batchID string)
- func (p *Provider) CreateBatch(ctx context.Context, req *core.BatchRequest) (*core.BatchResponse, error)
- func (p *Provider) CreateBatchWithHints(ctx context.Context, req *core.BatchRequest) (*core.BatchResponse, map[string]string, error)
- func (p *Provider) Embeddings(_ context.Context, _ *core.EmbeddingRequest) (*core.EmbeddingResponse, error)
- func (p *Provider) GetBatch(ctx context.Context, id string) (*core.BatchResponse, error)
- func (p *Provider) GetBatchResults(ctx context.Context, id string) (*core.BatchResultsResponse, error)
- func (p *Provider) GetBatchResultsWithHints(ctx context.Context, id string, endpointByCustomID map[string]string) (*core.BatchResultsResponse, error)
- func (p *Provider) ListBatches(ctx context.Context, limit int, after string) (*core.BatchListResponse, error)
- func (p *Provider) ListModels(ctx context.Context) (*core.ModelsResponse, error)
- func (p *Provider) Passthrough(ctx context.Context, req *core.PassthroughRequest) (*core.PassthroughResponse, error)
- func (p *Provider) Responses(ctx context.Context, req *core.ResponsesRequest) (*core.ResponsesResponse, error)
- func (p *Provider) SetBaseURL(url string)
- func (p *Provider) StreamChatCompletion(ctx context.Context, req *core.ChatRequest) (io.ReadCloser, error)
- func (p *Provider) StreamResponses(ctx context.Context, req *core.ResponsesRequest) (io.ReadCloser, error)
Constants ¶
This section is empty.
Variables ¶
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 ¶
func New(providerCfg providers.ProviderConfig, opts providers.ProviderOptions) core.Provider
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 ¶
NewWithHTTPClient creates a new Anthropic provider with a custom HTTP client. If httpClient is nil, http.DefaultClient is used.
func (*Provider) CancelBatch ¶
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 ¶
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 ¶
func (p *Provider) Embeddings(_ context.Context, _ *core.EmbeddingRequest) (*core.EmbeddingResponse, error)
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) 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 ¶
ListModels retrieves the list of available models from Anthropic's /v1/models endpoint
func (*Provider) Passthrough ¶
func (p *Provider) Passthrough(ctx context.Context, req *core.PassthroughRequest) (*core.PassthroughResponse, error)
Passthrough forwards an opaque Anthropic-native request without typed translation.
func (*Provider) Responses ¶
func (p *Provider) Responses(ctx context.Context, req *core.ResponsesRequest) (*core.ResponsesResponse, error)
Responses sends a Responses API request to Anthropic (converted to messages format)
func (*Provider) SetBaseURL ¶
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)