Documentation
¶
Overview ¶
Package anthropic adapts Anthropic Messages-compatible APIs to sigma.
The provider supports streaming text, image input, tools, thinking, prompt cache markers, usage, and Anthropic-compatible endpoint variations where the upstream API exposes stable fields. Credentials resolve through sigma.Options.AuthResolver instead of direct environment reads.
Index ¶
- Constants
- Variables
- func Register(registry *sigma.Registry, providerID sigma.ProviderID, opts ...ProviderOption) error
- func RegisterDefault(providerID sigma.ProviderID, opts ...ProviderOption) error
- type MessagesCompat
- type Provider
- type ProviderOption
- type WebFetchCitations
- type WebFetchOption
- type WebSearchLocation
- type WebSearchOption
Constants ¶
const (
DefaultBaseURL = "https://api.anthropic.com/v1"
)
Variables ¶
var Tools = struct { WebSearch func(opts ...WebSearchOption) sigma.Tool WebFetch func(opts ...WebFetchOption) sigma.Tool CodeExecution func() sigma.Tool }{ WebSearch: webSearchTool, WebFetch: webFetchTool, CodeExecution: codeExecutionTool, }
Tools provides factories for Anthropic server-side provider-defined tools.
Functions ¶
func Register ¶
func Register(registry *sigma.Registry, providerID sigma.ProviderID, opts ...ProviderOption) error
Register adds an Anthropic Messages-compatible text provider to registry.
func RegisterDefault ¶
func RegisterDefault(providerID sigma.ProviderID, opts ...ProviderOption) error
RegisterDefault adds an Anthropic Messages-compatible text provider to sigma's default registry.
Types ¶
type MessagesCompat ¶
type MessagesCompat struct {
EagerToolInputStreaming bool
LongCacheRetention bool
SessionAffinityHeaders bool
CacheControlOnTools bool
AdaptiveThinking bool
}
MessagesCompat describes Anthropic Messages compatibility differences for Anthropic-compatible endpoints. Leave fields at their zero value to use provider/base-URL detection, or set them with WithMessagesCompat for tests or custom routers.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider adapts Anthropic Messages-compatible HTTP APIs to sigma.
func NewProvider ¶
func NewProvider(opts ...ProviderOption) *Provider
NewProvider constructs an Anthropic Messages-compatible provider.
type ProviderOption ¶
type ProviderOption func(*Provider)
ProviderOption configures a Provider.
func WithBaseURL ¶
func WithBaseURL(baseURL string) ProviderOption
WithBaseURL configures the provider base URL, for example an httptest server URL ending in /v1 or an Anthropic-compatible endpoint.
func WithHTTPClient ¶
func WithHTTPClient(client *http.Client) ProviderOption
WithHTTPClient configures the provider fallback HTTP client.
func WithHeader ¶
func WithHeader(key, value string) ProviderOption
WithHeader configures a provider default request header.
func WithHeaders ¶
func WithHeaders(headers map[string]string) ProviderOption
WithHeaders configures provider default request headers.
func WithMessagesCompat ¶
func WithMessagesCompat(compat MessagesCompat) ProviderOption
WithMessagesCompat overrides detected Anthropic-compatible endpoint behavior.
type WebFetchCitations ¶
type WebFetchCitations struct {
Enabled bool
}
type WebFetchOption ¶
type WebFetchOption func(*webFetchConfig)
func WithCitations ¶
func WithCitations(enabled bool) WebFetchOption
func WithMaxContentTokens ¶
func WithMaxContentTokens(tokens int) WebFetchOption
func WithWebFetchAllowedDomains ¶
func WithWebFetchAllowedDomains(domains ...string) WebFetchOption
func WithWebFetchBlockedDomains ¶
func WithWebFetchBlockedDomains(domains ...string) WebFetchOption
func WithWebFetchMaxUses ¶
func WithWebFetchMaxUses(maxUses int) WebFetchOption
type WebSearchLocation ¶
type WebSearchOption ¶
type WebSearchOption func(*webSearchConfig)
func WithAllowedDomains ¶
func WithAllowedDomains(domains ...string) WebSearchOption
func WithBlockedDomains ¶
func WithBlockedDomains(domains ...string) WebSearchOption
func WithMaxUses ¶
func WithMaxUses(maxUses int) WebSearchOption
func WithWebSearchUserLocation ¶
func WithWebSearchUserLocation(location WebSearchLocation) WebSearchOption