Documentation
¶
Overview ¶
Package anthropic implements Anthropic-compatible streaming model clients.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AssistantMessage ¶
type AssistantMessage struct {
ID string
Blocks []ContentBlock
Usage Usage
}
type Client ¶
type Client struct {
HTTP *http.Client
BaseURL string
APIKey string
AuthToken string
RateLimit RateLimitOptions
Sleep func(context.Context, time.Duration) error
Fallbacks ProviderFallbackOptions
ForceOpenAICompatible bool
}
func NewWithOptions ¶
func NewWithOptions(baseURL, apiKey, authToken string, options ClientOptions) *Client
func NewWithRateLimit ¶
func NewWithRateLimit(baseURL, apiKey, authToken string, rateLimit RateLimitOptions) *Client
type ClientOptions ¶
type ClientOptions struct {
RateLimit RateLimitOptions
RequestTimeout time.Duration
ConnectTimeout time.Duration
Fallbacks ProviderFallbackOptions
ForceOpenAICompatible bool
}
type ContentBlock ¶
type ContentBlock struct {
Type string `json:"type"`
Text string `json:"text,omitempty"`
Thinking string `json:"thinking,omitempty"`
Data string `json:"data,omitempty"`
Source *ContentSource `json:"source,omitempty"`
Title string `json:"title,omitempty"`
Signature string `json:"signature,omitempty"`
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`
Input json.RawMessage `json:"input,omitempty"`
ToolUseID string `json:"tool_use_id,omitempty"`
Content string `json:"content,omitempty"`
IsError bool `json:"is_error,omitempty"`
}
type ContentSource ¶
type Message ¶
type Message struct {
ID string `json:"id,omitempty"`
Role string `json:"role"`
Content []ContentBlock `json:"content"`
}
func TextMessage ¶
func ToolResultMessage ¶
type MissingCredentialsError ¶
func (MissingCredentialsError) Error ¶
func (e MissingCredentialsError) Error() string
type ProviderFallbackOptions ¶
type RateLimitOptions ¶
type RateLimitOptions struct {
MaxRetries int `json:"max_retries"`
InitialBackoff time.Duration `json:"initial_backoff"`
MaxBackoff time.Duration `json:"max_backoff"`
}
func DefaultRateLimitOptions ¶
func DefaultRateLimitOptions() RateLimitOptions
func (RateLimitOptions) Report ¶
func (o RateLimitOptions) Report() RateLimitReport
type RateLimitReport ¶
type Request ¶
type Request struct {
Model string `json:"model"`
MaxTokens int `json:"max_tokens"`
Temperature *float64 `json:"temperature,omitempty"`
ReasoningEffort string `json:"-"`
ExtraBody map[string]any `json:"-"`
System string `json:"system,omitempty"`
Messages []Message `json:"messages"`
Tools []ToolDefinition `json:"tools,omitempty"`
Stream bool `json:"stream"`
}
type ToolDefinition ¶
Click to show internal directories.
Click to hide internal directories.