Documentation
¶
Overview ¶
Package auto provides zero-config multi-provider setup for LLM providers.
Index ¶
- Constants
- func New(ctx context.Context, opts ...Option) (*aggregate.Provider, error)
- type Option
- func WithAnthropic() Option
- func WithBedrock() Option
- func WithClaude(store claude.TokenStore) Option
- func WithClaudeAccount(name string, store claude.TokenStore) Option
- func WithClaudeLocal() Option
- func WithGlobalAlias(alias string, targets ...string) Option
- func WithGlobalAliases(aliases map[string][]string) Option
- func WithName(name string) Option
- func WithOpenAI() Option
- func WithOpenRouter() Option
- func WithoutAutoDetect() Option
Constants ¶
const ( ProviderClaude = "claude" ProviderBedrock = "bedrock" ProviderOpenAI = "openai" ProviderOpenRouter = "openrouter" ProviderAnthropic = "anthropic" )
Provider type names.
const ( EnvOpenAIKey = "OPENAI_API_KEY" EnvOpenAIKeyAlt = "OPENAI_KEY" EnvOpenRouterKey = "OPENROUTER_API_KEY" EnvAnthropicKey = "ANTHROPIC_API_KEY" )
Environment variable names.
const ( AliasFast = "fast" AliasDefault = "default" AliasPowerful = "powerful" )
Global model aliases.
Variables ¶
This section is empty.
Functions ¶
func New ¶
New creates an aggregate provider with auto-detected or explicitly configured providers.
Without options, it auto-detects available providers:
- Claude local (~/.claude credentials)
- AWS Bedrock (always included)
- Anthropic direct API (if ANTHROPIC_API_KEY is set)
- OpenAI (if OPENAI_API_KEY or OPENAI_KEY is set)
- OpenRouter (if OPENROUTER_API_KEY is set)
With explicit options, you can configure specific providers:
auto.New(ctx,
auto.WithName("myapp"),
auto.WithClaude(tokenStore), // Claude accounts from store
auto.WithClaudeLocal(), // Claude local credentials
auto.WithBedrock(), // AWS Bedrock
)
Types ¶
type Option ¶
type Option func(*config)
Option configures the auto provider.
func WithAnthropic ¶
func WithAnthropic() Option
WithAnthropic adds direct Anthropic API provider. Requires ANTHROPIC_API_KEY environment variable.
func WithClaude ¶
func WithClaude(store claude.TokenStore) Option
WithClaude adds all Claude OAuth accounts from a TokenStore. Each account key becomes a separate provider instance with name equal to the key.
func WithClaudeAccount ¶
func WithClaudeAccount(name string, store claude.TokenStore) Option
WithClaudeAccount adds a specific Claude OAuth account.
func WithClaudeLocal ¶
func WithClaudeLocal() Option
WithClaudeLocal adds the local Claude credentials (~/.claude).
func WithGlobalAlias ¶ added in v0.19.0
WithGlobalAlias adds a user-defined global alias that resolves to one or more targets. Targets should be provider-prefixed model references (e.g., "openai/o3", "openrouter/openai/o3"). Multiple targets enable failover - if the first target fails, the next is tried.
Example:
auto.WithGlobalAlias("o3", "openai/o3", "openrouter/openai/o3")
func WithGlobalAliases ¶ added in v0.19.0
WithGlobalAliases adds multiple user-defined global aliases. Each key is an alias name, and the value is a slice of targets.
Example:
auto.WithGlobalAliases(map[string][]string{
"o3": {"openai/o3", "openrouter/openai/o3"},
"codex": {"openai/codex"},
})
func WithOpenAI ¶
func WithOpenAI() Option
WithOpenAI adds OpenAI provider. Requires OPENAI_API_KEY or OPENAI_KEY environment variable.
func WithOpenRouter ¶
func WithOpenRouter() Option
WithOpenRouter adds OpenRouter provider. Requires OPENROUTER_API_KEY environment variable.
func WithoutAutoDetect ¶
func WithoutAutoDetect() Option
WithoutAutoDetect disables auto-detection of providers. Use this when you want to explicitly configure all providers.