auto

package
v0.17.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 18, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package auto provides zero-config multi-provider setup for LLM providers.

Index

Constants

View Source
const (
	ProviderClaude     = "claude"
	ProviderBedrock    = "bedrock"
	ProviderOpenAI     = "openai"
	ProviderOpenRouter = "openrouter"
	ProviderAnthropic  = "anthropic"
)

Provider type names.

View Source
const (
	EnvOpenAIKey     = "OPENAI_API_KEY"
	EnvOpenAIKeyAlt  = "OPENAI_KEY"
	EnvOpenRouterKey = "OPENROUTER_API_KEY"
	EnvAnthropicKey  = "ANTHROPIC_API_KEY"
)

Environment variable names.

View Source
const (
	AliasFast     = "fast"
	AliasDefault  = "default"
	AliasPowerful = "powerful"
)

Global model aliases.

View Source
const (
	ClaudeOpus   = "claude-opus-4-6"
	ClaudeSonnet = "claude-sonnet-4-6"
	ClaudeHaiku  = "claude-haiku-4-5-20251001"
)

Claude model IDs.

View Source
const (
	BedrockOpus   = "anthropic.claude-opus-4-20250514-v1:0"
	BedrockSonnet = "anthropic.claude-sonnet-4-20250514-v1:0"
	BedrockHaiku  = "anthropic.claude-3-5-haiku-20241022-v1:0"
)

Bedrock model IDs.

View Source
const (
	AnthropicOpus   = ClaudeOpus
	AnthropicSonnet = ClaudeSonnet
	AnthropicHaiku  = ClaudeHaiku
)

Anthropic model IDs (same as Claude, different provider).

Variables

This section is empty.

Functions

func New

func New(ctx context.Context, opts ...Option) (*aggregate.Provider, error)

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 WithBedrock

func WithBedrock() Option

WithBedrock adds AWS Bedrock provider.

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 WithName

func WithName(name string) Option

WithName sets the aggregate provider name.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL