openai

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ProviderOptionFrequencyPenalty     = "frequency_penalty"
	ProviderOptionPresencePenalty      = "presence_penalty"
	ProviderOptionLogitBias            = "logit_bias"
	ProviderOptionN                    = "n"
	ProviderOptionLogprobs             = "logprobs"
	ProviderOptionTopLogprobs          = "top_logprobs"
	ProviderOptionStore                = "store"
	ProviderOptionModeration           = "moderation"
	ProviderOptionStreamOptions        = "stream_options"
	ProviderOptionPromptCacheKey       = "prompt_cache_key"
	ProviderOptionPromptCacheRetention = "prompt_cache_retention"
	ProviderOptionPrediction           = "prediction"
	ProviderOptionMetadata             = "metadata"
	ProviderOptionModalities           = "modalities"
	ProviderOptionAudio                = "audio"
	ProviderOptionServiceTier          = "service_tier"
	ProviderOptionSafetyIdentifier     = "safety_identifier"
	ProviderOptionUser                 = "user"
	ProviderOptionVerbosity            = "verbosity"
	ProviderOptionWebSearchOptions     = "web_search_options"
	ProviderOptionParallelToolCalls    = "parallel_tool_calls"
	ProviderOptionSeed                 = "seed"
)

Variables

This section is empty.

Functions

func Factory

func Factory(cfg Config) (litellm.Provider, error)

func NewClient

func NewClient(cfg Config, opts ...litellm.ClientOption) (*litellm.Client, error)

NewClient builds the provider from cfg and wraps it in a ready *litellm.Client. It is a convenience for the common single-provider case. It calls New(cfg) and then litellm.New(provider, opts...).

Types

type Config

type Config struct {
	APIKey            string
	APIKeyFunc        func(context.Context) (string, error)
	BaseURL           string
	HTTPClient        HTTPClient
	Transport         http.RoundTripper
	Retry             *retry.Policy
	StreamIdleTimeout time.Duration
	UserAgent         string
	Headers           map[string]string
}

type HTTPClient

type HTTPClient interface {
	Do(*http.Request) (*http.Response, error)
}

type Provider

type Provider struct {
	// contains filtered or unexported fields
}

func New

func New(cfg Config) (*Provider, error)

func (*Provider) Capabilities added in v1.8.1

func (p *Provider) Capabilities(model string) litellm.Capabilities

func (*Provider) Chat

func (p *Provider) Chat(ctx context.Context, req *litellm.Request) (*litellm.Response, error)

func (*Provider) ListModels

func (p *Provider) ListModels(ctx context.Context) ([]litellm.ModelInfo, error)

func (*Provider) Name

func (p *Provider) Name() string

func (*Provider) Responses

func (p *Provider) Responses(ctx context.Context, req *ResponsesRequest) (*litellm.Response, error)

func (*Provider) ResponsesStream

func (p *Provider) ResponsesStream(ctx context.Context, req *ResponsesRequest) (litellm.Stream, error)

func (*Provider) Stream

func (p *Provider) Stream(ctx context.Context, req *litellm.Request) (litellm.Stream, error)

type ResponsesRequest

type ResponsesRequest struct {
	Model    string
	Messages []litellm.Message
	Input    any

	Instructions       string
	Conversation       any
	PreviousResponseID string

	ContextManagement []map[string]any
	MaxOutputTokens   *int
	MaxToolCalls      *int
	Include           []string
	TopLogprobs       *int

	Temperature *float64
	TopP        *float64

	ResponseFormat *litellm.ResponseFormat
	TextVerbosity  string
	Truncation     string

	Tools             []litellm.Tool
	OpenAITools       []ResponsesTool
	ToolChoice        any
	ParallelToolCalls *bool

	ReasoningEffort  string
	ReasoningSummary string
	Thinking         *litellm.Thinking

	PromptCacheKey       string
	PromptCacheRetention string
	Metadata             map[string]string
	SafetyIdentifier     string

	ServiceTier   string
	Background    *bool
	Store         *bool
	StreamOptions *ResponsesStreamOptions

	Prompt map[string]any

	CaptureRawResponse bool
}

type ResponsesStreamOptions

type ResponsesStreamOptions struct {
	IncludeObfuscation *bool `json:"include_obfuscation,omitempty"`
}

type ResponsesTool

type ResponsesTool map[string]any

Jump to

Keyboard shortcuts

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