provider

package
v1.9.5 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Overview

Package provider builds the built-in providers by name, for applications that choose a provider from configuration. Its subpackages, such as provider/openai, are the providers themselves; settings beyond Config are set by building a provider from its own package.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CatalogName

func CatalogName(name, model string) (string, bool)

CatalogName returns the name LiteLLM's model list, which package catalog loads, files model under when the provider called name serves it: OpenAI, Anthropic and Bedrock models are unprefixed, others take the list's prefix for the vendor, such as "xai/" for grok. It reports false for compat, gateway and unknown names, whose vendor is not known.

func Names

func Names() []string

Names returns the provider names New accepts, sorted.

func New

func New(name string, cfg Config) (litellm.Provider, error)

New returns the provider called name, one of Names.

Types

type Config

type Config struct {
	// Name identifies the provider in responses, errors and ProviderState;
	// empty uses the provider's own name. Give each endpoint of one protocol
	// its own name, so replay state reaches only the endpoint that issued it.
	Name string
	// APIKey authenticates requests; APIKeyFunc, when set, resolves it per
	// request instead.
	APIKey     string
	APIKeyFunc func(context.Context) (string, error)
	// BaseURL overrides the provider's endpoint; compat and gateway require
	// it, gateway as the URL its Server is served at.
	BaseURL string
	// HTTPClient sends requests; nil uses http.DefaultClient. Wrap it with
	// retry.NewHTTPClient to retry.
	HTTPClient litellm.HTTPClient
	UserAgent  string
	// Headers are set after the defaults, so they can override them.
	Headers map[string]string

	// API selects the openai endpoint: openai.APIChat (the default) or
	// openai.APIResponses.
	API string
	// AllowUnknownProviderOptions makes the Chat Completions vendors
	// (deepseek, glm, grok, mimo, minimax, ollama, openrouter, qwen) copy
	// options they do not list into the request body, as compat always does.
	AllowUnknownProviderOptions bool
	// Region and Credentials configure bedrock.
	Region      string
	Credentials bedrock.CredentialsProvider
}

Config holds the connection settings the providers share, plus the few that belong to one provider. Bedrock signs requests with Region and Credentials instead of an API key, headers or user agent.

Directories

Path Synopsis
Package anthropic connects to the Anthropic Messages API.
Package anthropic connects to the Anthropic Messages API.
Package bedrock connects to the Amazon Bedrock Converse API.
Package bedrock connects to the Amazon Bedrock Converse API.
Package compat connects to any OpenAI-compatible Chat Completions endpoint, such as vLLM, LM Studio or a gateway, and holds the Config shared by the vendor wrappers (deepseek, glm, grok, mimo, minimax, ollama, openrouter, qwen).
Package compat connects to any OpenAI-compatible Chat Completions endpoint, such as vLLM, LM Studio or a gateway, and holds the Config shared by the vendor wrappers (deepseek, glm, grok, mimo, minimax, ollama, openrouter, qwen).
Package deepseek connects to the DeepSeek API.
Package deepseek connects to the DeepSeek API.
Package gemini connects to the Gemini API.
Package gemini connects to the Gemini API.
Package glm connects to the Zhipu GLM API.
Package glm connects to the Zhipu GLM API.
Package grok connects to the xAI Grok API.
Package grok connects to the xAI Grok API.
internal
openaicompat
Package openaicompat implements the Chat Completions protocol shared by OpenAI and the OpenAI-compatible providers.
Package openaicompat implements the Chat Completions protocol shared by OpenAI and the OpenAI-compatible providers.
openaicompat/compattest
Package compattest runs openaicompat providers against canned HTTP responses in tests.
Package compattest runs openaicompat providers against canned HTTP responses in tests.
Package mimo connects to the Xiaomi MiMo API.
Package mimo connects to the Xiaomi MiMo API.
Package minimax connects to the MiniMax API.
Package minimax connects to the MiniMax API.
Package ollama connects to Ollama's OpenAI-compatible endpoint.
Package ollama connects to Ollama's OpenAI-compatible endpoint.
Package openai connects to the OpenAI API, or any endpoint that implements it exactly (such as Azure OpenAI), through Chat Completions or Responses.
Package openai connects to the OpenAI API, or any endpoint that implements it exactly (such as Azure OpenAI), through Chat Completions or Responses.
Package openrouter connects to the OpenRouter API.
Package openrouter connects to the OpenRouter API.
Package qwen connects to the Alibaba Cloud DashScope compatible-mode API.
Package qwen connects to the Alibaba Cloud DashScope compatible-mode API.

Jump to

Keyboard shortcuts

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