compat

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: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewClient

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

NewClient builds the provider from cfg and spec and wraps it in a ready *litellm.Client. It is a convenience for custom OpenAI-compatible endpoints. It calls New(cfg, spec) and then litellm.New(provider, opts...).

Types

type AuthSpec

type AuthSpec struct {
	APIKeyRequired bool
}

type CapabilityMapper added in v1.8.1

type CapabilityMapper func(model string, base litellm.Capabilities) litellm.Capabilities

type Config

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

	// AllowUnknownProviderOptions copies unknown request ProviderOptions into
	// the JSON body. The default remains strict; applications that expose an
	// explicit extra_body escape hatch can opt in.
	AllowUnknownProviderOptions bool
}

type EndpointSpec

type EndpointSpec struct {
	BaseURL    string
	ChatPath   string
	ModelsPath string
}

type FeatureSpec

type FeatureSpec struct {
	StrictTools    StrictToolMode
	APIKeyRequired bool
}

type HTTPClient

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

type HeaderSpec

type HeaderSpec struct {
	Extra  map[string]string
	Stream map[string]string
}

type MessageMapper

type MessageMapper func([]litellm.Message) (any, error)

type Provider

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

func New

func New(cfg Config, spec Spec) (*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) Stream

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

type ProviderOptionsMapper

type ProviderOptionsMapper func(litellm.ProviderOptions, map[string]any, *litellm.Request) error

type RequestSpec

type RequestSpec struct {
	MaxTokensField                         string
	OmitStop                               bool
	MaxStopSequences                       int
	EmitEmptyAssistantContentWithToolCalls bool

	SupportsJSONSchema bool
	JSONSchemaToPrompt bool

	Thinking        ThinkingMapper
	ResponseFormat  ResponseFormatMapper
	CleanSchema     SchemaMapper
	ProviderOptions ProviderOptionsMapper
	Warnings        WarningMapper
	Messages        MessageMapper
	Tools           ToolMapper

	AllowUnknownProviderOptions bool
	AllowedProviderOptions      map[string]struct{}
}

type ResponseFormatMapper

type ResponseFormatMapper func(*litellm.ResponseFormat) (any, error)

type ResponseSpec

type ResponseSpec struct {
	ModelFromResponse         bool
	ContentAsInterface        bool
	ReasoningFields           []string
	HasCompletionTokenDetails bool
	HasCacheTokens            bool
}

type SchemaMapper

type SchemaMapper func(litellm.Schema) (any, error)

type Spec

type Spec struct {
	Name     string
	Endpoint EndpointSpec
	Auth     AuthSpec
	Headers  HeaderSpec
	Request  RequestSpec
	Response ResponseSpec
	Stream   StreamSpec
	Features FeatureSpec

	Capabilities CapabilityMapper
}

type StreamSpec

type StreamSpec struct {
	DataPrefix string

	ReasoningFields     []string
	ReasoningCondition  string
	ReasoningCumulative bool

	ContentFields              []string
	ContentCumulative          bool
	ContentCumulativeCondition string
	DoneSentinel               string

	OmitStreamOptions bool
}

type StrictToolMode

type StrictToolMode int
const (
	StrictToolsOmit StrictToolMode = iota
	StrictToolsForward
	StrictToolsRequireAll
)

type ThinkingMapper

type ThinkingMapper func(*litellm.Thinking, string) (map[string]any, error)

type ToolMapper

type ToolMapper func([]litellm.Tool) (any, error)

type WarningMapper

type WarningMapper func(*litellm.Request) []litellm.Warning

Jump to

Keyboard shortcuts

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