providers

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package providers exposes a small driver-style registry of provider constructors. It lets callers ask for a provider by name without hand-coding a switch over every shipped provider package.

Each provider sub-package registers itself in init() so importing `_ "github.com/erain/glue/providers/nvidia"` makes that provider resolvable via providers.New("nvidia"). The registry holds factory functions, not constructed providers, so registration is cheap and has no I/O or credential side effects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func KeyAvailable

func KeyAvailable(name string) bool

KeyAvailable reports whether the registered provider's env var is non-empty in the process environment. Returns false for unknown providers and for providers registered without an EnvKey.

func Known

func Known() []string

Known returns the registered provider names, sorted for stable output in error messages and CLI help text.

func New

func New(name string) (loop.Provider, string, string, error)

New constructs a fresh provider for the registered name. Returns the provider, its default model, the env var it consults, and an error if the name is unknown.

func Register

func Register(name string, f Factory)

Register adds a provider to the registry. Re-registering an existing name overwrites — driver-style packages may register from init() and the last importer wins.

Types

type Capabilities added in v1.13.0

type Capabilities struct {
	// ContextWindow is the default model's context window in tokens.
	// Zero means unknown.
	ContextWindow int

	// ParallelTools reports whether tool calls from one assistant turn
	// are safe to execute concurrently against this provider's models.
	ParallelTools bool

	// PromptVariant selects the system-prompt flavor assembled for
	// this provider's models: "terse" for frontier models that need
	// minimal steering, "" for the default (more explicit) variant.
	PromptVariant string

	// AutoContinue reports that the provider's models are prone to the
	// narrate-then-stop stall and benefit from the loop's bounded
	// "Please continue." nudge.
	AutoContinue bool
}

Capabilities records harness-relevant facts about a provider's models, declared at registration instead of scattered through if-provider-name switches. The zero value means "unknown / assume nothing": consumers must treat absent capabilities conservatively.

func CapabilitiesFor added in v1.13.0

func CapabilitiesFor(name string) Capabilities

CapabilitiesFor returns the registered capabilities for name, or the zero value when the provider is unknown or declared none.

type Factory

type Factory struct {
	// New returns a fresh provider configured with package defaults
	// (no explicit API key — falls back to the provider's env var).
	New func() loop.Provider

	// DefaultModel is the model id callers should use when they have
	// no opinion. The registry exposes it so a CLI agent can present
	// `--model` defaults that vary by provider.
	DefaultModel string

	// EnvKey is the environment variable the provider reads when
	// APIKey is empty. Used by KeyAvailable.
	EnvKey string

	// Capabilities declares harness-relevant facts about the
	// provider's models. Optional; the zero value means unknown.
	Capabilities Capabilities
}

Factory describes one registered provider.

func Lookup

func Lookup(name string) (Factory, bool)

Lookup returns the factory for name, or false if no provider is registered under that name.

Directories

Path Synopsis
Package codex is a glue.Provider that routes through the Codex Responses endpoint at chatgpt.com/backend-api/codex/responses, authenticated with a ChatGPT subscription via OAuth tokens read from the upstream Codex CLI's auth.json (run "codex login" once outside glue).
Package codex is a glue.Provider that routes through the Codex Responses endpoint at chatgpt.com/backend-api/codex/responses, authenticated with a ChatGPT subscription via OAuth tokens read from the upstream Codex CLI's auth.json (run "codex login" once outside glue).
auth
Package auth handles ChatGPT-subscription OAuth tokens for the providers/codex transport.
Package auth handles ChatGPT-subscription OAuth tokens for the providers/codex transport.
Package gemini adapts Google's Gemini API to Glue's provider interface using the google.golang.org/genai SDK.
Package gemini adapts Google's Gemini API to Glue's provider interface using the google.golang.org/genai SDK.
Package nvidia implements a Glue provider for the NVIDIA build inference API (https://build.nvidia.com), which exposes an OpenAI-compatible chat-completions endpoint at https://integrate.api.nvidia.com/v1.
Package nvidia implements a Glue provider for the NVIDIA build inference API (https://build.nvidia.com), which exposes an OpenAI-compatible chat-completions endpoint at https://integrate.api.nvidia.com/v1.
Package openaicompat implements the shared streaming, tool-call, and convert logic for OpenAI-style chat-completions endpoints used by the concrete providers under providers/.
Package openaicompat implements the shared streaming, tool-call, and convert logic for OpenAI-style chat-completions endpoints used by the concrete providers under providers/.
Package openrouter implements a Glue provider for OpenRouter (https://openrouter.ai), an OpenAI-compatible aggregator that routes requests across many underlying model providers.
Package openrouter implements a Glue provider for OpenRouter (https://openrouter.ai), an OpenAI-compatible aggregator that routes requests across many underlying model providers.

Jump to

Keyboard shortcuts

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