litellm

package
v1.8.0 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2026 License: MIT Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

Client wraps an OpenAI-compatible client configured to talk to a LiteLLM proxy. LiteLLM normalizes 100+ provider APIs (Anthropic, Bedrock, Vertex, Groq, etc.) into the OpenAI Chat Completions format, so the same go-openai SDK works unchanged.

func New

func New(opts ...Option) (*Client, error)

New creates a new LiteLLM client that connects to a LiteLLM proxy server.

func (*Client) Completion

func (c *Client) Completion(ctx context.Context, content string) (*core.Response, error)

Completion generates a non-streaming completion via the LiteLLM proxy.

func (*Client) CompletionStream

func (c *Client) CompletionStream(
	ctx context.Context,
	content string,
	w io.Writer,
) (*core.Response, error)

CompletionStream streams completion tokens to the writer as they arrive.

func (*Client) GetSummaryPrefix

func (c *Client) GetSummaryPrefix(ctx context.Context, content string) (*core.Response, error)

GetSummaryPrefix uses OpenAI-format function calling through the LiteLLM proxy to extract a conventional commit prefix. Falls back to plain completion if the backing model does not support tool/function calls.

type Option

type Option interface {
	// contains filtered or unexported methods
}

Option is an interface that specifies instrumentation configuration options.

func WithBaseURL

func WithBaseURL(val string) Option

WithBaseURL sets the LiteLLM proxy base URL.

func WithFrequencyPenalty

func WithFrequencyPenalty(val float32) Option

WithFrequencyPenalty sets the frequency penalty parameter.

func WithHeaders

func WithHeaders(headers []string) Option

WithHeaders sets additional HTTP headers for requests.

func WithMaxTokens

func WithMaxTokens(val int) Option

WithMaxTokens sets the maximum token limit for generated completions.

func WithModel

func WithModel(val string) Option

WithModel sets the model identifier (e.g. "anthropic/claude-sonnet-4-6", "openai/gpt-4o").

func WithPresencePenalty

func WithPresencePenalty(val float32) Option

WithPresencePenalty sets the presence penalty parameter.

func WithProxyURL

func WithProxyURL(val string) Option

WithProxyURL sets the HTTP proxy URL for outbound connections.

func WithSkipVerify

func WithSkipVerify(val bool) Option

WithSkipVerify disables TLS certificate verification.

func WithSocksURL

func WithSocksURL(val string) Option

WithSocksURL sets the SOCKS proxy URL for outbound connections.

func WithTemperature

func WithTemperature(val float32) Option

WithTemperature sets the sampling temperature (0-2).

func WithTimeout

func WithTimeout(val time.Duration) Option

WithTimeout sets the per-request HTTP timeout.

func WithToken

func WithToken(val string) Option

WithToken sets the API key for the LiteLLM proxy.

func WithTopP

func WithTopP(val float32) Option

WithTopP sets the nucleus sampling parameter.

Jump to

Keyboard shortcuts

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