Documentation
¶
Overview ¶
Package openai connects to the OpenAI API, or any endpoint that implements it exactly (such as Azure OpenAI), through Chat Completions or Responses. Use provider/compat for other OpenAI-compatible servers.
Index ¶
Constants ¶
const ( ProviderOptionFrequencyPenalty = "frequency_penalty" ProviderOptionPresencePenalty = "presence_penalty" ProviderOptionLogitBias = "logit_bias" ProviderOptionLogprobs = "logprobs" ProviderOptionTopLogprobs = "top_logprobs" ProviderOptionStore = "store" ProviderOptionModeration = "moderation" ProviderOptionStreamOptions = "stream_options" ProviderOptionPromptCacheKey = "prompt_cache_key" ProviderOptionPromptCacheOptions = "prompt_cache_options" ProviderOptionPromptCacheRetention = "prompt_cache_retention" ProviderOptionPrediction = "prediction" ProviderOptionMetadata = "metadata" ProviderOptionServiceTier = "service_tier" ProviderOptionSafetyIdentifier = "safety_identifier" ProviderOptionUser = "user" ProviderOptionVerbosity = "verbosity" ProviderOptionWebSearchOptions = "web_search_options" ProviderOptionParallelToolCalls = "parallel_tool_calls" ProviderOptionSeed = "seed" )
ProviderOptions are native request fields of the selected API, copied into the body as is. An option naming a generated object (such as Responses "text" or "reasoning") is merged into it. Responses options that add output litellm does not model, hosted tools and server-side compaction, are not offered, as their items would drop out of the conversation; nor is previous_response_id, as a Response carries no id. Results reported beside the output, such as moderation scores, are in Response.Raw when captured.
const ( ProviderOptionConversation = "conversation" ProviderOptionInclude = "include" ProviderOptionTruncation = "truncation" // ProviderOptionBackground is supported by Stream only; Chat has no job // polling interface and rejects background=true. ProviderOptionBackground = "background" ProviderOptionPrompt = "prompt" // ProviderOptionText is merged into the generated text object, e.g. // {"verbosity": "low"}. ProviderOptionText = "text" // ProviderOptionReasoning is merged into the generated reasoning object, // e.g. {"summary": "auto"}. ProviderOptionReasoning = "reasoning" )
Responses API options (Config.API = APIResponses) not listed above.
const ( APIChat = "chat" APIResponses = "responses" )
Config.API values.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Name identifies the provider in responses, errors and ProviderState,
// "openai" by default. Give each endpoint its own name, such as an Azure
// deployment, so reasoning state is replayed only where it was issued.
Name string
// API selects Chat Completions (APIChat, the default) or APIResponses.
API string
// APIKey authenticates requests; APIKeyFunc, when set, resolves it per
// request instead.
APIKey string
APIKeyFunc func(context.Context) (string, error)
// BaseURL is the API root, https://api.openai.com/v1 by default.
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
}
Config configures the OpenAI client. An API key is required.
type Provider ¶
type Provider struct {
// contains filtered or unexported fields
}
Provider implements litellm.Provider and litellm.CapabilityProvider.
func (*Provider) Capabilities ¶ added in v1.8.1
func (p *Provider) Capabilities() litellm.Capabilities
Capabilities reports the static protocol facts of the selected API.