providers

package
v0.0.25 Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package providers contains SDK provider wiring for common model backends.

Index

Constants

View Source
const (
	DefaultProviderOpenAI     = "openai"
	DefaultProviderAnthropic  = "anthropic"
	DefaultProviderOpenRouter = "openrouter"
	DefaultProviderGemini     = "gemini"
	DefaultProviderGroq       = "groq"
	DefaultProviderLocal      = "local"
	DefaultProviderCopilot    = "copilot"
)
View Source
const DefaultCodexBackendBaseURL = "https://chatgpt.com/backend-api/codex"

Variables

This section is empty.

Functions

func NewDefaultMultiProvider

func NewDefaultMultiProvider() *agentsdk.MultiProvider

NewDefaultMultiProvider creates a MultiProvider with OpenAI and Anthropic registered and OpenAI as the default provider.

func NewProviderFromConfig

func NewProviderFromConfig(spec ProviderSpec) (agentsdk.ModelProvider, error)

func NewRunner

func NewRunner(model string) (*agentsdk.Runner, error)

NewRunner creates a Runner backed by the default provider set.

func NewRunnerFromConfig

func NewRunnerFromConfig(spec ProviderSpec) (*agentsdk.Runner, error)

Types

type ProviderRoute added in v0.0.22

type ProviderRoute struct {
	// Prefix is the routing key matched against a model's "prefix/model"
	// segment. When empty it defaults to Provider.
	Prefix string
	// Provider is the base provider type to build (e.g. "openai", "anthropic",
	// "copilot", "openrouter"). Required; "multi" is not allowed.
	Provider string
	BaseURL  string
	APIKey   string
	// AuthMode selects the auth scheme for this route (e.g. "oauth" or
	// "api_key"). Empty uses the provider's default (API key). For OAuth, the
	// token is supplied via APIKey for anthropic/copilot, or via the
	// OpenAIOAuth* fields for openai.
	AuthMode string
	APIMode  string

	// OpenAI OAuth configuration, used when Provider is "openai" and AuthMode
	// is "oauth".
	OpenAIOAuthPath          string
	OpenAIOAuthAccountID     string
	OpenAIOAuthAccountIDPath string
	OpenAIAuthSession        *sdkopenai.AuthSession
}

ProviderRoute declares a single provider instance registered under an arbitrary routing prefix. Routes are registered after the canonical provider set, so a route whose Prefix matches a canonical provider name (e.g. "anthropic") overrides that default registration.

type ProviderSpec

type ProviderSpec struct {
	Provider                 string
	DefaultProvider          string
	Model                    string
	BaseURL                  string
	APIKey                   string
	AuthMode                 string
	APIMode                  string
	OpenAIOAuthPath          string
	OpenAIOAuthAccountID     string
	OpenAIOAuthAccountIDPath string
	OpenAIAuthSession        *sdkopenai.AuthSession
	ProviderAPIKeys          map[string]string
	ProviderBaseURLs         map[string]string
	ProviderAPIModes         map[string]string
	// ModelFallbacks is an ordered list of fallback model identifiers sent as
	// the OpenRouter "models" array so the provider retries the next model when
	// one is unavailable. It is only forwarded to OpenRouter; other
	// OpenAI-compatible providers ignore it. Empty disables fallback routing.
	ModelFallbacks []string
	// Routes declares named provider instances registered under arbitrary
	// routing prefixes, on top of the canonical provider set. Routes let a
	// single MultiProvider expose the same base provider under multiple
	// prefixes with independent auth/credentials, so callers can route by model
	// prefix (e.g. "anthropic/..." vs "anthropic-oauth/...") to select API-key
	// vs OAuth per request. A non-empty Routes list implies multi-provider
	// behavior regardless of Provider.
	Routes []ProviderRoute
}

Directories

Path Synopsis
Package anthropic exposes the Anthropic provider and client helpers as part of the public agent SDK surface.
Package anthropic exposes the Anthropic provider and client helpers as part of the public agent SDK surface.
Package oauth exposes provider OAuth material parsing and refresh helpers.
Package oauth exposes provider OAuth material parsing and refresh helpers.
Package openai exposes the OpenAI-compatible provider, client, and auth helpers as part of the public agent SDK surface.
Package openai exposes the OpenAI-compatible provider, client, and auth helpers as part of the public agent SDK surface.

Jump to

Keyboard shortcuts

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