Documentation
¶
Overview ¶
Package llmux provides a high-performance LLM gateway as a Go library. It supports 44+ LLM providers with unified OpenAI-compatible API.
LLMux can be used in two modes:
- Library Mode: Import and use directly in your Go application
- Gateway Mode: Run as a standalone HTTP proxy server
Basic usage:
client, err := llmux.New(
llmux.WithProvider(llmux.ProviderConfig{
Name: "openai",
Type: "openai",
APIKey: os.Getenv("OPENAI_API_KEY"),
Models: []string{"gpt-4o", "gpt-4o-mini"},
}),
)
if err != nil {
log.Fatal(err)
}
defer client.Close()
resp, err := client.ChatCompletion(ctx, &llmux.ChatRequest{
Model: "gpt-4o",
Messages: []llmux.ChatMessage{
{Role: "user", Content: json.RawMessage(`"Hello!"`)},
},
})
Index ¶
- Constants
- Variables
- func WithRateLimitAPIKey(ctx context.Context, apiKey string) context.Context
- type Cache
- type CacheControl
- type CacheEntry
- type CacheStats
- type CacheType
- type ChatMessage
- type ChatRequest
- type ChatResponse
- type Choice
- type Client
- func (c *Client) AddProvider(name string, prov Provider, models []string) error
- func (c *Client) CalculateCost(model string, usage *types.Usage) float64
- func (c *Client) ChatCompletion(ctx context.Context, req *ChatRequest) (*ChatResponse, error)
- func (c *Client) ChatCompletionStream(ctx context.Context, req *ChatRequest) (*StreamReader, error)
- func (c *Client) Close() error
- func (c *Client) Embedding(ctx context.Context, req *types.EmbeddingRequest) (*types.EmbeddingResponse, error)
- func (c *Client) GetProvider(name string) (Provider, bool)
- func (c *Client) GetProviders() []string
- func (c *Client) GetStats(deploymentID string) *DeploymentStats
- func (c *Client) ListDeployments() []*provider.Deployment
- func (c *Client) ListModels(ctx context.Context) ([]Model, error)
- func (c *Client) RegisterProviderFactory(providerType string, factory ProviderFactory)
- func (c *Client) RemoveProvider(name string) error
- func (c *Client) ResilienceStats(key string) ResilienceStats
- func (c *Client) SetCooldown(deploymentID string, until time.Time) error
- type ClientConfig
- type Deployment
- type DeploymentConfig
- type DeploymentStats
- type EmbeddingData
- type EmbeddingRequest
- type EmbeddingResponse
- type EmbeddingUsage
- type FallbackReporter
- type LLMError
- type Model
- type Option
- func WithCache(cache Cache) Option
- func WithCacheTTL(ttl time.Duration) Option
- func WithCacheTypeLabel(label string) Option
- func WithCooldown(d time.Duration) Option
- func WithDefaultProvider(provider string) Option
- func WithEWMAAlpha(alpha float64) Option
- func WithFallback(enabled bool) Option
- func WithFallbackReporter(reporter FallbackReporter) Option
- func WithLogger(logger *slog.Logger) Option
- func WithOTelMetrics(config observability.OTelMetricsConfig) Option
- func WithPlugin(p plugin.Plugin) Option
- func WithPluginConfig(config plugin.PipelineConfig) Option
- func WithPricingFile(path string) Option
- func WithProvider(cfg ProviderConfig) Option
- func WithProviderInstance(name string, prov Provider, models []string) Option
- func WithRateLimiter(limiter resilience.DistributedLimiter) Option
- func WithRateLimiterConfig(config RateLimiterConfig) Option
- func WithRetry(count int, backoff time.Duration) Option
- func WithRetryJitter(jitter float64) Option
- func WithRetryMaxBackoff(d time.Duration) Option
- func WithRoundRobinStore(store router.RoundRobinStore) Option
- func WithRouter(r Router) Option
- func WithRouterStrategy(strategy Strategy) Option
- func WithStatsStore(store router.StatsStore) Option
- func WithStreamRecoveryMaxAccumulatedBytes(maxBytes int) Option
- func WithStreamRecoveryMode(mode StreamRecoveryMode) Option
- func WithTimeout(d time.Duration) Option
- type PluginContext
- type PluginInterface
- type PluginPipelineConfig
- type PluginShortCircuit
- type Provider
- type ProviderConfig
- type ProviderFactory
- type RateLimitKeyStrategy
- type RateLimiterConfig
- type RequestContext
- type ResilienceStats
- type ResponseFormat
- type ResponseMetrics
- type Router
- type RouterConfig
- type Strategy
- type StreamChoice
- type StreamChunk
- type StreamDelta
- type StreamOptions
- type StreamReader
- type StreamRecoveryMode
- type Tool
- type ToolCall
- type ToolCallFunction
- type ToolFunction
- type Usage
Constants ¶
const ( // StrategySimpleShuffle randomly selects from available deployments. StrategySimpleShuffle = router.StrategySimpleShuffle // StrategyShuffle is an alias for StrategySimpleShuffle. StrategyShuffle = router.StrategySimpleShuffle // StrategyRoundRobin selects deployments in strict round-robin order. StrategyRoundRobin = router.StrategyRoundRobin // StrategyLowestLatency selects the deployment with lowest average latency. StrategyLowestLatency = router.StrategyLowestLatency // StrategyLeastBusy selects the deployment with fewest active requests. StrategyLeastBusy = router.StrategyLeastBusy // StrategyLowestTPMRPM selects the deployment with lowest TPM/RPM usage. StrategyLowestTPMRPM = router.StrategyLowestTPMRPM // StrategyLowestCost selects the deployment with lowest cost per token. StrategyLowestCost = router.StrategyLowestCost // StrategyTagBased filters deployments based on request tags. StrategyTagBased = router.StrategyTagBased )
Re-export routing strategy constants.
const ( // CacheTypeLocal is an in-memory cache. CacheTypeLocal = cache.TypeLocal // CacheTypeRedis is a Redis cache. CacheTypeRedis = cache.TypeRedis // CacheTypeDual is an in-memory + Redis dual cache. CacheTypeDual = cache.TypeDual // CacheTypeSemantic is a semantic cache with vector similarity. CacheTypeSemantic = cache.TypeSemantic )
Re-export cache type constants.
const ( TypeAuthentication = errors.TypeAuthentication TypeRateLimit = errors.TypeRateLimit TypeInvalidRequest = errors.TypeInvalidRequest TypeNotFound = errors.TypeNotFound TypeTimeout = errors.TypeTimeout TypeInternalError = errors.TypeInternalError TypeContextLength = errors.TypeContextLength TypeContentPolicy = errors.TypeContentPolicy TypePermissionDenied = errors.TypePermissionDenied TypeInsufficientQuota = errors.TypeInsufficientQuota )
Re-export error type constants.
const Version = "2.0.0"
Version is the current version of LLMux.
Variables ¶
var ( NewAuthenticationError = errors.NewAuthenticationError NewPermissionError = errors.NewPermissionError NewRateLimitError = errors.NewRateLimitError NewInsufficientQuotaError = errors.NewInsufficientQuotaError NewInvalidRequestError = errors.NewInvalidRequestError NewNotFoundError = errors.NewNotFoundError NewTimeoutError = errors.NewTimeoutError NewInternalError = errors.NewInternalError )
Re-export error factory functions.
Functions ¶
Types ¶
type CacheControl ¶
CacheControl allows per-request cache behavior customization.
type CacheEntry ¶
CacheEntry represents a single cache entry for pipeline operations.
type ChatMessage ¶
type ChatMessage = types.ChatMessage
ChatMessage represents a single message in the conversation.
type ChatRequest ¶
type ChatRequest = types.ChatRequest
ChatRequest represents an OpenAI-compatible chat completion request.
type ChatResponse ¶
type ChatResponse = types.ChatResponse
ChatResponse represents an OpenAI-compatible chat completion response.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the main entry point for LLMux library mode. It manages providers, routing, caching, and request execution.
Client is safe for concurrent use by multiple goroutines.
func New ¶
New creates a new LLMux client with the given options.
Example:
client, err := llmux.New(
llmux.WithProvider(llmux.ProviderConfig{
Name: "openai",
Type: "openai",
APIKey: os.Getenv("OPENAI_API_KEY"),
Models: []string{"gpt-4o"},
}),
llmux.WithRouterStrategy(llmux.StrategyLowestLatency),
)
func (*Client) AddProvider ¶
AddProvider adds a provider at runtime. This is useful for dynamically adding providers without recreating the client.
func (*Client) CalculateCost ¶
CalculateCost computes the usage cost for a given model using loaded pricing data. Returns 0 when pricing is unavailable or model not found.
func (*Client) ChatCompletion ¶
func (c *Client) ChatCompletion(ctx context.Context, req *ChatRequest) (*ChatResponse, error)
ChatCompletion sends a chat completion request. It handles routing, retries, fallback, and caching automatically.
func (*Client) ChatCompletionStream ¶
func (c *Client) ChatCompletionStream(ctx context.Context, req *ChatRequest) (*StreamReader, error)
ChatCompletionStream sends a streaming chat completion request. Returns a StreamReader that can be used to iterate over response chunks.
Example:
stream, err := client.ChatCompletionStream(ctx, req)
if err != nil {
return err
}
defer stream.Close()
for {
chunk, err := stream.Recv()
if err == io.EOF {
break
}
if err != nil {
return err
}
fmt.Print(chunk.Choices[0].Delta.Content)
}
func (*Client) Embedding ¶
func (c *Client) Embedding(ctx context.Context, req *types.EmbeddingRequest) (*types.EmbeddingResponse, error)
Embedding sends an embedding request. It handles routing, retries, and fallback automatically.
func (*Client) GetProvider ¶
GetProvider returns the provider instance by name.
func (*Client) GetProviders ¶
GetProviders returns the names of all registered providers.
func (*Client) GetStats ¶
func (c *Client) GetStats(deploymentID string) *DeploymentStats
GetStats returns routing statistics for a deployment.
func (*Client) ListDeployments ¶
func (c *Client) ListDeployments() []*provider.Deployment
ListDeployments returns a snapshot of all deployments.
func (*Client) ListModels ¶
ListModels returns all available models from registered providers.
func (*Client) RegisterProviderFactory ¶
func (c *Client) RegisterProviderFactory(providerType string, factory ProviderFactory)
RegisterProviderFactory registers a custom provider factory. This allows adding support for new provider types.
func (*Client) RemoveProvider ¶
RemoveProvider removes a provider at runtime.
func (*Client) ResilienceStats ¶
func (c *Client) ResilienceStats(key string) ResilienceStats
ResilienceStats returns the resilience status for a provider key.
type ClientConfig ¶
type ClientConfig struct {
// Providers configuration
Providers []ProviderConfig
// Custom provider instances (for advanced use)
ProviderInstances []providerInstance
// Routing
RouterStrategy Strategy
Router Router // Custom router (overrides RouterStrategy)
FallbackEnabled bool
RetryCount int
RetryBackoff time.Duration
RetryMaxBackoff time.Duration
RetryJitter float64
CooldownPeriod time.Duration
EWMAAlpha float64
DefaultProvider string
FallbackReporter FallbackReporter
// Distributed Routing Stats (for multi-instance deployments)
StatsStore router.StatsStore
// Distributed Round Robin counters (for multi-instance deployments)
RoundRobinStore router.RoundRobinStore
// Caching
CacheEnabled bool
Cache Cache // Custom cache implementation
CacheTTL time.Duration
CacheTypeLabel string
// HTTP
Timeout time.Duration
// Logging
Logger *slog.Logger
// Plugins
Plugins []plugin.Plugin
PluginConfig *plugin.PipelineConfig
// Pricing
PricingFile string
// Stream recovery
StreamRecoveryMode StreamRecoveryMode
// StreamRecoveryMaxAccumulatedBytes caps the in-memory accumulated stream content used for recovery.
// Set to 0 to disable the cap (not recommended).
StreamRecoveryMaxAccumulatedBytes int
// Observability
OTelMetricsConfig observability.OTelMetricsConfig
// Rate Limiting (Distributed)
RateLimiter resilience.DistributedLimiter
RateLimiterConfig RateLimiterConfig
}
ClientConfig holds all configuration for the LLMux client.
type Deployment ¶
type Deployment = provider.Deployment
Deployment represents a specific model deployment configuration.
type DeploymentConfig ¶
type DeploymentConfig = router.DeploymentConfig
DeploymentConfig contains deployment-specific configuration for routing.
type DeploymentStats ¶
type DeploymentStats = router.DeploymentStats
DeploymentStats tracks performance metrics for a deployment.
type EmbeddingData ¶
type EmbeddingData struct {
Object string `json:"object"`
Embedding []float64 `json:"embedding"`
Index int `json:"index"`
}
EmbeddingData represents a single embedding vector.
type EmbeddingRequest ¶
EmbeddingRequest represents an embedding request (future support).
type EmbeddingResponse ¶
type EmbeddingResponse struct {
Object string `json:"object"`
Data []EmbeddingData `json:"data"`
Model string `json:"model"`
Usage *EmbeddingUsage `json:"usage,omitempty"`
}
EmbeddingResponse represents an embedding response (future support).
type EmbeddingUsage ¶
type EmbeddingUsage struct {
PromptTokens int `json:"prompt_tokens"`
TotalTokens int `json:"total_tokens"`
}
EmbeddingUsage contains token usage for embedding requests.
type FallbackReporter ¶
type FallbackReporter func(ctx context.Context, originalModel, fallbackModel string, err error, success bool)
FallbackReporter receives fallback outcomes for observability.
type Model ¶
type Model struct {
ID string `json:"id"`
Provider string `json:"provider"`
Object string `json:"object,omitempty"`
}
Model represents an available model from a provider.
type Option ¶
type Option func(*ClientConfig)
Option is a function that configures the Client.
func WithCache ¶
WithCache enables caching with the given implementation.
Example:
redisCache, _ := redis.New(redis.WithAddr("localhost:6379"))
llmux.WithCache(redisCache)
func WithCacheTTL ¶
WithCacheTTL sets the default cache TTL. This is used when no TTL is specified in the cache control.
func WithCacheTypeLabel ¶
WithCacheTypeLabel sets the cache type label for metrics.
func WithCooldown ¶
WithCooldown sets the cooldown period for failed deployments. Deployments that fail will be excluded from routing for this duration.
func WithDefaultProvider ¶
WithDefaultProvider prefers a provider when multiple deployments are available.
func WithEWMAAlpha ¶
WithEWMAAlpha sets the smoothing factor for EWMA calculations. alpha should be between 0 and 1. A higher alpha discounts older observations faster.
func WithFallback ¶
WithFallback enables/disables fallback on failure. When enabled, failed requests will be retried on different deployments.
func WithFallbackReporter ¶
func WithFallbackReporter(reporter FallbackReporter) Option
WithFallbackReporter records fallback outcomes.
func WithLogger ¶
WithLogger sets the logger for the client. The logger is used for debug, info, and error messages.
func WithOTelMetrics ¶
func WithOTelMetrics(config observability.OTelMetricsConfig) Option
WithOTelMetrics configures OpenTelemetry metrics.
func WithPlugin ¶
WithPlugin adds a plugin to the client. Plugins are executed in the order of their priority.
func WithPluginConfig ¶
func WithPluginConfig(config plugin.PipelineConfig) Option
WithPluginConfig sets the plugin pipeline configuration.
func WithPricingFile ¶
WithPricingFile sets the path to the custom pricing JSON file.
func WithProvider ¶
func WithProvider(cfg ProviderConfig) Option
WithProvider adds a provider configuration. The provider will be created automatically based on the Type field.
Example:
llmux.WithProvider(llmux.ProviderConfig{
Name: "openai",
Type: "openai",
APIKey: os.Getenv("OPENAI_API_KEY"),
Models: []string{"gpt-4o", "gpt-4o-mini"},
})
func WithProviderInstance ¶
WithProviderInstance adds a pre-configured provider instance. Use this when you need custom provider configuration beyond what ProviderConfig offers.
Example:
openaiProvider := openai.New(
openai.WithAPIKey(os.Getenv("OPENAI_API_KEY")),
openai.WithBaseURL("https://custom-endpoint.com/v1"),
)
llmux.WithProviderInstance("my-openai", openaiProvider, []string{"gpt-4o"})
func WithRateLimiter ¶
func WithRateLimiter(limiter resilience.DistributedLimiter) Option
WithRateLimiter sets a custom distributed rate limiter implementation. This enables distributed rate limiting across multiple LLMux instances.
Example:
redisClient := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
limiter := resilience.NewRedisLimiter(redisClient)
llmux.WithRateLimiter(limiter)
func WithRateLimiterConfig ¶
func WithRateLimiterConfig(config RateLimiterConfig) Option
WithRateLimiterConfig sets the rate limiter configuration. This configures the rate limits (RPM/TPM) and key strategy.
Example:
llmux.WithRateLimiterConfig(llmux.RateLimiterConfig{
Enabled: true,
RPMLimit: 100,
TPMLimit: 10000,
WindowSize: time.Minute,
KeyStrategy: llmux.RateLimitKeyByAPIKey,
})
func WithRetry ¶
WithRetry configures retry behavior. count: number of retry attempts (0 = no retries) backoff: initial backoff duration (exponential backoff is applied)
func WithRetryJitter ¶
WithRetryJitter sets the jitter ratio for retries (0.0 - 1.0).
func WithRetryMaxBackoff ¶
WithRetryMaxBackoff sets the maximum backoff duration for retries. Use 0 to disable the cap.
func WithRoundRobinStore ¶
func WithRoundRobinStore(store router.RoundRobinStore) Option
WithRoundRobinStore sets a distributed round-robin store for consistent RR across instances.
func WithRouter ¶
WithRouter sets a custom router implementation. This overrides the RouterStrategy option.
Example:
customRouter := myrouter.New(...) llmux.WithRouter(customRouter)
func WithRouterStrategy ¶
WithRouterStrategy sets the routing strategy. Available strategies:
- StrategySimpleShuffle: Random selection with optional weights
- StrategyLowestLatency: Select deployment with lowest latency
- StrategyLeastBusy: Select deployment with fewest active requests
- StrategyLowestTPMRPM: Select deployment with lowest token/request usage
- StrategyLowestCost: Select deployment with lowest cost
- StrategyTagBased: Filter deployments by tags
func WithStatsStore ¶
func WithStatsStore(store router.StatsStore) Option
WithStatsStore sets a distributed stats store for routing decisions. This enables multi-instance deployments to share routing statistics (latency, active requests, cooldowns), making load-balanced strategies like least-busy and lowest-latency work correctly across a cluster.
Example:
redisClient := redis.NewClient(&redis.Options{Addr: "localhost:6379"})
statsStore := router.NewRedisStatsStore(redisClient)
llmux.WithStatsStore(statsStore)
func WithStreamRecoveryMaxAccumulatedBytes ¶
WithStreamRecoveryMaxAccumulatedBytes caps the accumulated stream content retained in-memory for recovery. A value of 0 disables the cap.
func WithStreamRecoveryMode ¶
func WithStreamRecoveryMode(mode StreamRecoveryMode) Option
WithStreamRecoveryMode configures how streaming recovery behaves after a mid-stream failure.
func WithTimeout ¶
WithTimeout sets the HTTP request timeout. This applies to all provider API calls.
type PluginContext ¶
PluginContext provides execution context for plugins.
type PluginInterface ¶
PluginInterface defines the interface for LLMux plugins. Plugins can intercept and modify requests/responses at various lifecycle points.
type PluginPipelineConfig ¶
type PluginPipelineConfig = plugin.PipelineConfig
PluginPipelineConfig holds configuration for the plugin pipeline.
type PluginShortCircuit ¶
type PluginShortCircuit = plugin.ShortCircuit
PluginShortCircuit represents a plugin's decision to short-circuit the request.
type ProviderConfig ¶
ProviderConfig contains provider-specific configuration.
type ProviderFactory ¶
ProviderFactory creates provider instances from configuration.
type RateLimitKeyStrategy ¶
type RateLimitKeyStrategy string
RateLimitKeyStrategy defines how to derive the rate limit key.
const ( // RateLimitKeyByAPIKey uses the API key as the rate limit key. RateLimitKeyByAPIKey RateLimitKeyStrategy = "api_key" // #nosec G101 -- identifier value, not a credential. // RateLimitKeyByUser uses the user ID as the rate limit key. RateLimitKeyByUser RateLimitKeyStrategy = "user" // RateLimitKeyByModel uses the model name as the rate limit key. RateLimitKeyByModel RateLimitKeyStrategy = "model" // RateLimitKeyByAPIKeyAndModel uses both API key and model as the rate limit key. RateLimitKeyByAPIKeyAndModel RateLimitKeyStrategy = "api_key_model" // #nosec G101 -- identifier value, not a credential. )
type RateLimiterConfig ¶
type RateLimiterConfig struct {
// Enabled indicates whether rate limiting is enabled.
Enabled bool
// RPMLimit is the requests per minute limit.
RPMLimit int64
// TPMLimit is the tokens per minute limit.
TPMLimit int64
// WindowSize is the sliding window duration (default: 1 minute).
WindowSize time.Duration
// KeyStrategy defines how to derive the rate limit key.
KeyStrategy RateLimitKeyStrategy
// FailOpen allows requests when the rate limiter backend fails.
FailOpen bool
}
RateLimiterConfig holds configuration for rate limiting.
type RequestContext ¶
type RequestContext = router.RequestContext
RequestContext contains request-specific information for routing decisions.
type ResilienceStats ¶
type ResilienceStats struct {
Key string `json:"key"`
CircuitState string `json:"circuit_state"`
RateLimitTokens float64 `json:"rate_limit_tokens"`
ConcurrentCurrent int `json:"concurrent_current"`
ConcurrentCapacity int `json:"concurrent_capacity"`
}
ResilienceStats exposes provider-level resilience metrics.
type ResponseFormat ¶
type ResponseFormat = types.ResponseFormat
ResponseFormat specifies the output format for the model.
type ResponseMetrics ¶
type ResponseMetrics = router.ResponseMetrics
ResponseMetrics contains metrics from a completed request.
type RouterConfig ¶
RouterConfig contains router configuration options.
type StreamChoice ¶
type StreamChoice = types.StreamChoice
StreamChoice represents a choice in a streaming response.
type StreamChunk ¶
type StreamChunk = types.StreamChunk
StreamChunk represents a single chunk in a streaming response.
type StreamDelta ¶
type StreamDelta = types.StreamDelta
StreamDelta contains the incremental content in a stream chunk.
type StreamOptions ¶
type StreamOptions = types.StreamOptions
StreamOptions specifies options for streaming responses.
type StreamReader ¶
type StreamReader struct {
// contains filtered or unexported fields
}
StreamReader provides an iterator interface for streaming responses. It handles SSE parsing and provides a simple Recv() method for consuming chunks.
Example:
stream, err := client.ChatCompletionStream(ctx, req)
if err != nil {
return err
}
defer stream.Close()
for {
chunk, err := stream.Recv()
if err == io.EOF {
break
}
if err != nil {
return err
}
fmt.Print(chunk.Choices[0].Delta.Content)
}
func (*StreamReader) Close ¶
func (s *StreamReader) Close() error
Close releases resources associated with the stream. It's safe to call Close multiple times.
func (*StreamReader) Recv ¶
func (s *StreamReader) Recv() (*types.StreamChunk, error)
Recv returns the next chunk from the stream. Returns io.EOF when the stream is complete. Returns an error if the stream encounters an error.
func (*StreamReader) TTFT ¶
func (s *StreamReader) TTFT() time.Duration
TTFT returns the Time To First Token duration. Returns 0 if no chunks have been received yet.
type StreamRecoveryMode ¶
type StreamRecoveryMode string
StreamRecoveryMode controls how stream recovery behaves after a mid-stream failure.
const ( StreamRecoveryOff StreamRecoveryMode = "off" StreamRecoveryAppend StreamRecoveryMode = "append" StreamRecoveryRetry StreamRecoveryMode = "retry" )
type ToolCallFunction ¶
type ToolCallFunction = types.ToolCallFunction
ToolCallFunction contains the function name and arguments.
type ToolFunction ¶
type ToolFunction = types.ToolFunction
ToolFunction describes a callable function.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
bench
|
|
|
cmd/mock
command
Package main provides the mock LLM server entry point.
|
Package main provides the mock LLM server entry point. |
|
cmd/runner
command
Package main provides the benchmark runner entry point.
|
Package main provides the benchmark runner entry point. |
|
internal/mock
Package mock provides a mock LLM server for benchmarking.
|
Package mock provides a mock LLM server for benchmarking. |
|
internal/runner
Package runner provides benchmark execution and result collection.
|
Package runner provides benchmark execution and result collection. |
|
Package caches provides public cache implementations for LLMux library mode.
|
Package caches provides public cache implementations for LLMux library mode. |
|
dual
Package dual provides a two-tier cache with in-memory (L1) and Redis (L2).
|
Package dual provides a two-tier cache with in-memory (L1) and Redis (L2). |
|
memory
Package memory provides an in-memory cache implementation with LRU + TTL eviction.
|
Package memory provides an in-memory cache implementation with LRU + TTL eviction. |
|
redis
Package redis provides a Redis-based cache implementation.
|
Package redis provides a Redis-based cache implementation. |
|
cmd
|
|
|
server
command
Package main is the entry point for the LLMux gateway server.
|
Package main is the entry point for the LLMux gateway server. |
|
internal
|
|
|
api
Package api provides HTTP handlers for the LLM gateway API.
|
Package api provides HTTP handlers for the LLM gateway API. |
|
auth
Package auth provides API key authentication and multi-tenant support.
|
Package auth provides API key authentication and multi-tenant support. |
|
cache
Package cache provides caching functionality for LLM responses.
|
Package cache provides caching functionality for LLM responses. |
|
cache/semantic
Package semantic provides semantic caching functionality using vector similarity.
|
Package semantic provides semantic caching functionality using vector similarity. |
|
cache/semantic/embedding
Package embedding provides interfaces and implementations for generating text embeddings used in semantic caching.
|
Package embedding provides interfaces and implementations for generating text embeddings used in semantic caching. |
|
cache/semantic/vector
Package vector provides vector storage interfaces and implementations for semantic caching functionality.
|
Package vector provides vector storage interfaces and implementations for semantic caching functionality. |
|
config
Package config provides configuration management with hot-reload support.
|
Package config provides configuration management with hot-reload support. |
|
governance
Package governance provides policy evaluation and accounting for gateway requests.
|
Package governance provides policy evaluation and accounting for gateway requests. |
|
healthcheck
Package healthcheck provides proactive deployment probing.
|
Package healthcheck provides proactive deployment probing. |
|
httputil
Package httputil provides helpers for working with HTTP payloads safely.
|
Package httputil provides helpers for working with HTTP payloads safely. |
|
mcp
Package mcp provides Model Context Protocol (MCP) integration for LLMux.
|
Package mcp provides Model Context Protocol (MCP) integration for LLMux. |
|
metrics
Package metrics provides budget-related Prometheus metrics.
|
Package metrics provides budget-related Prometheus metrics. |
|
observability
Package observability provides a callback system for observability integrations.
|
Package observability provides a callback system for observability integrations. |
|
plugin
Package plugin provides a plugin system for LLMux that enables request interception, modification, and short-circuiting.
|
Package plugin provides a plugin system for LLMux that enables request interception, modification, and short-circuiting. |
|
plugin/builtin
Package builtin provides built-in plugin implementations for common use cases.
|
Package builtin provides built-in plugin implementations for common use cases. |
|
pool
Package pool provides object pooling for request and response types to reduce memory allocations and improve performance.
|
Package pool provides object pooling for request and response types to reduce memory allocations and improve performance. |
|
pricing
Package pricing provides functionality for calculating model usage costs.
|
Package pricing provides functionality for calculating model usage costs. |
|
provider
Package provider defines the interface for LLM provider adapters.
|
Package provider defines the interface for LLM provider adapters. |
|
provider/providers
Package providers provides a centralized registry for all LLM providers.
|
Package providers provides a centralized registry for all LLM providers. |
|
resilience
Package resilience provides high-availability patterns for the LLM gateway.
|
Package resilience provides high-availability patterns for the LLM gateway. |
|
secret
Package secret provides secret management interfaces and implementations.
|
Package secret provides secret management interfaces and implementations. |
|
secret/env
Package env implements a secret provider that reads from environment variables.
|
Package env implements a secret provider that reads from environment variables. |
|
secret/vault
Package vault implements a secret provider that reads from HashiCorp Vault.
|
Package vault implements a secret provider that reads from HashiCorp Vault. |
|
streaming
Package streaming provides SSE (Server-Sent Events) streaming utilities.
|
Package streaming provides SSE (Server-Sent Events) streaming utilities. |
|
tokenizer
Package tokenizer provides token counting helpers for LLM requests and responses.
|
Package tokenizer provides token counting helpers for LLM requests and responses. |
|
pkg
|
|
|
cache
Package cache provides public caching interfaces for LLM responses.
|
Package cache provides public caching interfaces for LLM responses. |
|
errors
Package errors defines unified error types for LLM gateway operations.
|
Package errors defines unified error types for LLM gateway operations. |
|
plugin
Package plugin provides the public API for the LLMux plugin system.
|
Package plugin provides the public API for the LLMux plugin system. |
|
pricing
Package pricing provides functionality for managing and retrieving model pricing information.
|
Package pricing provides functionality for managing and retrieving model pricing information. |
|
provider
Package provider defines the public interface for LLM provider adapters.
|
Package provider defines the public interface for LLM provider adapters. |
|
router
Package router provides public request routing and load balancing interfaces.
|
Package router provides public request routing and load balancing interfaces. |
|
types
Package types defines core data structures for LLM API requests and responses.
|
Package types defines core data structures for LLM API requests and responses. |
|
Package providers provides a unified registry for all LLMux provider implementations.
|
Package providers provides a unified registry for all LLMux provider implementations. |
|
ai21
Package ai21 provides the AI21 Labs provider for LLMux library mode.
|
Package ai21 provides the AI21 Labs provider for LLMux library mode. |
|
anthropic
Package anthropic provides the Anthropic Claude provider for LLMux library mode.
|
Package anthropic provides the Anthropic Claude provider for LLMux library mode. |
|
anyscale
Package anyscale provides the Anyscale Endpoints provider for LLMux library mode.
|
Package anyscale provides the Anyscale Endpoints provider for LLMux library mode. |
|
azure
Package azure provides the Azure OpenAI provider for LLMux library mode.
|
Package azure provides the Azure OpenAI provider for LLMux library mode. |
|
baichuan
Package baichuan provides the Baichuan (百川) provider for LLMux library mode.
|
Package baichuan provides the Baichuan (百川) provider for LLMux library mode. |
|
bedrock
Package bedrock implements the AWS Bedrock provider adapter.
|
Package bedrock implements the AWS Bedrock provider adapter. |
|
cerebras
Package cerebras provides the Cerebras provider for LLMux library mode.
|
Package cerebras provides the Cerebras provider for LLMux library mode. |
|
cloudflare
Package cloudflare provides the Cloudflare Workers AI provider for LLMux library mode.
|
Package cloudflare provides the Cloudflare Workers AI provider for LLMux library mode. |
|
cohere
Package cohere provides the Cohere provider for LLMux library mode.
|
Package cohere provides the Cohere provider for LLMux library mode. |
|
databricks
Package databricks provides the Databricks provider for LLMux library mode.
|
Package databricks provides the Databricks provider for LLMux library mode. |
|
deepinfra
Package deepinfra provides the DeepInfra provider for LLMux library mode.
|
Package deepinfra provides the DeepInfra provider for LLMux library mode. |
|
deepseek
Package deepseek provides the DeepSeek provider for LLMux library mode.
|
Package deepseek provides the DeepSeek provider for LLMux library mode. |
|
fireworks
Package fireworks provides the Fireworks AI provider for LLMux library mode.
|
Package fireworks provides the Fireworks AI provider for LLMux library mode. |
|
gemini
Package gemini provides the Google Gemini provider for LLMux library mode.
|
Package gemini provides the Google Gemini provider for LLMux library mode. |
|
github
Package github provides the GitHub Models provider for LLMux library mode.
|
Package github provides the GitHub Models provider for LLMux library mode. |
|
groq
Package groq provides the Groq provider for LLMux library mode.
|
Package groq provides the Groq provider for LLMux library mode. |
|
huggingface
Package huggingface provides the Hugging Face Inference API provider for LLMux library mode.
|
Package huggingface provides the Hugging Face Inference API provider for LLMux library mode. |
|
hunyuan
Package hunyuan provides the Tencent Hunyuan (腾讯混元) provider for LLMux library mode.
|
Package hunyuan provides the Tencent Hunyuan (腾讯混元) provider for LLMux library mode. |
|
hyperbolic
Package hyperbolic provides the Hyperbolic provider for LLMux library mode.
|
Package hyperbolic provides the Hyperbolic provider for LLMux library mode. |
|
lambda
Package lambda provides the Lambda Labs provider for LLMux library mode.
|
Package lambda provides the Lambda Labs provider for LLMux library mode. |
|
lmstudio
Package lmstudio provides the LM Studio provider for LLMux library mode.
|
Package lmstudio provides the LM Studio provider for LLMux library mode. |
|
minimax
Package minimax provides the MiniMax provider for LLMux library mode.
|
Package minimax provides the MiniMax provider for LLMux library mode. |
|
mistral
Package mistral provides the Mistral AI provider for LLMux library mode.
|
Package mistral provides the Mistral AI provider for LLMux library mode. |
|
moonshot
Package moonshot provides the Moonshot AI (月之暗面) provider for LLMux library mode.
|
Package moonshot provides the Moonshot AI (月之暗面) provider for LLMux library mode. |
|
novita
Package novita provides the Novita AI provider for LLMux library mode.
|
Package novita provides the Novita AI provider for LLMux library mode. |
|
nvidia
Package nvidia provides the NVIDIA NIM provider for LLMux library mode.
|
Package nvidia provides the NVIDIA NIM provider for LLMux library mode. |
|
ollama
Package ollama provides the Ollama provider for LLMux library mode.
|
Package ollama provides the Ollama provider for LLMux library mode. |
|
openai
Package openai provides the OpenAI provider for LLMux library mode.
|
Package openai provides the OpenAI provider for LLMux library mode. |
|
openailike
Package openailike provides a base implementation for OpenAI-compatible providers.
|
Package openailike provides a base implementation for OpenAI-compatible providers. |
|
openrouter
Package openrouter provides the OpenRouter provider for LLMux library mode.
|
Package openrouter provides the OpenRouter provider for LLMux library mode. |
|
perplexity
Package perplexity provides the Perplexity AI provider for LLMux library mode.
|
Package perplexity provides the Perplexity AI provider for LLMux library mode. |
|
qwen
Package qwen provides the Alibaba Qwen (通义千问) provider for LLMux library mode.
|
Package qwen provides the Alibaba Qwen (通义千问) provider for LLMux library mode. |
|
replicate
Package replicate provides the Replicate provider for LLMux library mode.
|
Package replicate provides the Replicate provider for LLMux library mode. |
|
sambanova
Package sambanova provides the SambaNova provider for LLMux library mode.
|
Package sambanova provides the SambaNova provider for LLMux library mode. |
|
siliconflow
Package siliconflow provides the SiliconFlow (硅基流动) provider for LLMux library mode.
|
Package siliconflow provides the SiliconFlow (硅基流动) provider for LLMux library mode. |
|
snowflake
Package snowflake provides the Snowflake Cortex provider for LLMux library mode.
|
Package snowflake provides the Snowflake Cortex provider for LLMux library mode. |
|
stepfun
Package stepfun provides the StepFun (阶跃星辰) provider for LLMux library mode.
|
Package stepfun provides the StepFun (阶跃星辰) provider for LLMux library mode. |
|
together
Package together provides the Together AI provider for LLMux library mode.
|
Package together provides the Together AI provider for LLMux library mode. |
|
vertexai
Package vertexai implements the Google Vertex AI provider adapter.
|
Package vertexai implements the Google Vertex AI provider adapter. |
|
vllm
Package vllm provides the vLLM provider for LLMux library mode.
|
Package vllm provides the vLLM provider for LLMux library mode. |
|
volcengine
Package volcengine provides the ByteDance Volcengine (火山引擎) provider for LLMux library mode.
|
Package volcengine provides the ByteDance Volcengine (火山引擎) provider for LLMux library mode. |
|
watsonx
Package watsonx provides the IBM watsonx.ai provider for LLMux library mode.
|
Package watsonx provides the IBM watsonx.ai provider for LLMux library mode. |
|
xai
Package xai provides the xAI (Grok) provider for LLMux library mode.
|
Package xai provides the xAI (Grok) provider for LLMux library mode. |
|
yi
Package yi provides the 01.AI Yi (零一万物) provider for LLMux library mode.
|
Package yi provides the 01.AI Yi (零一万物) provider for LLMux library mode. |
|
zhipu
Package zhipu implements the Zhipu AI provider adapter.
|
Package zhipu implements the Zhipu AI provider adapter. |
|
Package routers provides public router implementations for LLMux library mode.
|
Package routers provides public router implementations for LLMux library mode. |
|
tests
|
|
|
testutil
Package testutil provides testing utilities for E2E tests.
|
Package testutil provides testing utilities for E2E tests. |