providers

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: May 26, 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 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
}

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.
Package gemini adapts Google's Gemini API to Glue's provider interface.
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