Documentation
¶
Index ¶
- Variables
- func AddCustomEndpoint(cfg *config.Config, u *ui.UI, name, endpoint, modelName, apiKey string) error
- func ConfigureLiteLLM(cfg *config.Config, u *ui.UI, provider, apiKey string, models []string) error
- func FormatBytes(b int64) string
- func GetConfiguredModels(cfg *config.Config) ([]string, error)
- func GetMasterKey(cfg *config.Config) (string, error)
- func GetProviderStatus(cfg *config.Config) (map[string]ProviderStatus, error)
- func HasConfiguredModels(cfg *config.Config) bool
- func PullOllamaModel(name string) error
- func RemoveModel(cfg *config.Config, u *ui.UI, modelName string) error
- func ValidateCustomEndpoint(endpoint, modelName, apiKey string) error
- func WarnAndStripV1Suffix(endpoint string) string
- type LiteLLMConfig
- type LiteLLMParams
- type ModelEntry
- type OllamaModel
- type ProviderInfo
- type ProviderStatus
Constants ¶
This section is empty.
Variables ¶
var WellKnownModels = map[string][]string{
"anthropic": {
"claude-sonnet-4-6",
"claude-opus-4",
"claude-sonnet-4-5-20250929",
"claude-haiku-3-5-20241022",
},
"openai": {
"gpt-4o",
"gpt-4o-mini",
"o3",
"o3-mini",
},
}
WellKnownModels maps provider names to their commonly-used model IDs. Used to populate OpenClaw's model allowlist when a wildcard is configured and the LiteLLM pod is not reachable for a live /v1/models query.
Functions ¶
func AddCustomEndpoint ¶ added in v0.6.0
func AddCustomEndpoint(cfg *config.Config, u *ui.UI, name, endpoint, modelName, apiKey string) error
AddCustomEndpoint adds a custom OpenAI-compatible endpoint to LiteLLM after validating it works.
func ConfigureLiteLLM ¶ added in v0.6.0
ConfigureLiteLLM adds a provider to the LiteLLM gateway. For cloud providers, it patches the Secret with the API key and adds the model to config.yaml. For Ollama, it discovers local models and adds them.
func FormatBytes ¶ added in v0.5.0
FormatBytes formats a byte count as a human-readable string.
func GetConfiguredModels ¶ added in v0.6.0
GetConfiguredModels returns the model names available in LiteLLM. Wildcard entries (e.g. anthropic/*) are expanded: first by querying the running LiteLLM pod's /v1/models endpoint, falling back to the baked-in WellKnownModels list if the cluster is unreachable.
func GetMasterKey ¶ added in v0.6.0
GetMasterKey reads the LiteLLM master key from the cluster Secret.
func GetProviderStatus ¶
func GetProviderStatus(cfg *config.Config) (map[string]ProviderStatus, error)
GetProviderStatus reads LiteLLM config and returns provider status.
func HasConfiguredModels ¶ added in v0.7.0
HasConfiguredModels returns true if LiteLLM has at least one non-catch-all model configured (i.e., something other than the "paid/*" route).
func PullOllamaModel ¶ added in v0.5.0
PullOllamaModel pulls a model from the Ollama registry. It streams progress to stdout, matching the UX of `ollama pull`.
func RemoveModel ¶ added in v0.7.0
RemoveModel removes a model entry from the LiteLLM ConfigMap and restarts the deployment.
func ValidateCustomEndpoint ¶ added in v0.6.0
ValidateCustomEndpoint validates that a custom OpenAI-compatible endpoint works. It runs a 2-step validation: reachability check, then inference probe. The inference probe is the definitive test — some servers (e.g., mlx-lm) don't list the loaded model in /models but accept it for inference.
func WarnAndStripV1Suffix ¶ added in v0.7.0
WarnAndStripV1Suffix checks if an endpoint URL has a trailing /v1 suffix, warns the user, and returns the stripped URL. For OpenAI-compatible providers, LiteLLM auto-appends /v1, causing double /v1/v1 if the user includes it.
Types ¶
type LiteLLMConfig ¶ added in v0.6.0
type LiteLLMConfig struct {
ModelList []ModelEntry `yaml:"model_list"`
GeneralSettings map[string]any `yaml:"general_settings,omitempty"`
LiteLLMSettings map[string]any `yaml:"litellm_settings,omitempty"`
}
LiteLLMConfig represents the LiteLLM proxy config.yaml structure.
type LiteLLMParams ¶ added in v0.6.0
type LiteLLMParams struct {
Model string `yaml:"model"`
APIBase string `yaml:"api_base,omitempty"`
APIKey string `yaml:"api_key,omitempty"`
}
LiteLLMParams holds the routing parameters for a model.
type ModelEntry ¶ added in v0.6.0
type ModelEntry struct {
ModelName string `yaml:"model_name"`
LiteLLMParams LiteLLMParams `yaml:"litellm_params"`
}
ModelEntry is a single entry in model_list.
type OllamaModel ¶ added in v0.5.0
type OllamaModel struct {
Name string `json:"name"`
Size int64 `json:"size"`
ModifiedAt string `json:"modified_at"`
}
OllamaModel describes a model pulled in the local Ollama instance.
func ListOllamaModels ¶ added in v0.5.0
func ListOllamaModels() ([]OllamaModel, error)
ListOllamaModels queries the local Ollama server for pulled models. Returns nil and an error if Ollama is not reachable.
type ProviderInfo ¶ added in v0.3.1
type ProviderInfo struct {
ID string // provider id (e.g. "anthropic", "openai", "ollama")
Name string // display name
EnvVar string // env var for API key (empty for Ollama)
}
ProviderInfo describes an LLM provider.
func GetAvailableProviders ¶ added in v0.3.1
func GetAvailableProviders(_ *config.Config) ([]ProviderInfo, error)
GetAvailableProviders returns the known provider list (static, no pod query needed).