Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DefaultOptions ¶ added in v0.12.0
DefaultOptions returns the default options for Anthropic. Base URL defaults to https://api.anthropic.com. API key should be provided via WithAPIKey() or WithAPIKeyFunc().
Types ¶
type ClaudeCodeProvider ¶
type ClaudeCodeProvider struct {
// contains filtered or unexported fields
}
ClaudeCodeProvider implements the provider interface using the Claude Code CLI via cc-sdk-go. It wraps the oai.Client which spawns the official claude CLI as a subprocess.
func NewCCWithClient ¶
func NewCCWithClient(client *oai.Client) *ClaudeCodeProvider
NewCCWithClient creates a Claude Code provider with a custom oai.Client. Use this when you need to customize the underlying cchat.Client configuration (e.g. CLI path, max concurrency, working directory).
func NewClaudeCodeProvider ¶
func NewClaudeCodeProvider() *ClaudeCodeProvider
NewClaudeCodeProvider creates a new Claude Code provider with default settings. The claude CLI must be authenticated (claude setup-token) and available in PATH.
func (*ClaudeCodeProvider) CreateStream ¶
func (p *ClaudeCodeProvider) CreateStream(ctx context.Context, opts llm.StreamOptions) (<-chan llm.StreamEvent, error)
func (*ClaudeCodeProvider) Models ¶
func (p *ClaudeCodeProvider) Models() []llm.Model
func (*ClaudeCodeProvider) Name ¶
func (p *ClaudeCodeProvider) Name() string
type OAuthConfig ¶ added in v0.12.0
type OAuthConfig struct {
Access string // Access token (sk-ant-oat-...)
Refresh string // Refresh token
Expires int64 // Expiry timestamp in milliseconds
}
OAuthConfig holds OAuth token information for Claude Code authentication.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements the Anthropic (Claude) LLM backend.
func New ¶
New creates a new Anthropic provider. Options are applied on top of DefaultOptions().
Example usage:
// With API key
p := anthropic.New(llm.WithAPIKey("sk-ant-..."))
// With API key from environment
p := anthropic.New(llm.APIKeyFromEnv("ANTHROPIC_API_KEY"))
// With dynamic API key resolution
p := anthropic.New(llm.WithAPIKeyFunc(func(ctx context.Context) (string, error) {
return secretStore.Get(ctx, "anthropic-key")
}))
func (*Provider) CreateStream ¶
func (p *Provider) CreateStream(ctx context.Context, opts llm.StreamOptions) (<-chan llm.StreamEvent, error)
func (*Provider) WithOAuth ¶ added in v0.12.0
func (p *Provider) WithOAuth(oauth *OAuthConfig) *Provider
WithOAuth configures the provider to use OAuth authentication. This enables Claude Code-style authentication with automatic token refresh.