Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmd/engine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,7 @@ func buildLLM(c config.LLMConfig) (llmgate.Client, error) {
APIKey: c.Anthropic.APIKey,
Model: c.Anthropic.Model,
ReasoningModel: c.Anthropic.ReasoningModel,
BaseURL: c.Anthropic.BaseURL,
})
case "openai":
return openai.New(openai.Config{
Expand Down
1 change: 1 addition & 0 deletions cmd/server/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,6 +393,7 @@ func buildLLM(c enginecfg.LLMConfig) (llmgate.Client, error) {
APIKey: c.Anthropic.APIKey,
Model: c.Anthropic.Model,
ReasoningModel: c.Anthropic.ReasoningModel,
BaseURL: c.Anthropic.BaseURL,
})
case "openai":
return openai.New(openai.Config{
Expand Down
10 changes: 10 additions & 0 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,16 @@ func applyEnvOverrides(c *Config) {
if v := firstEnv("VLS_LLM_DRIVER", "VLE_LLM_DRIVER"); v != "" {
c.Engine.LLM.Driver = v
}
// Anthropic-compatible gateway overrides (e.g. GLM/Zhipu via
// https://api.z.ai/api/anthropic): base URL + model, so the
// anthropic driver can run a non-Anthropic model without a secret
// edit.
if v := firstEnv("VLS_LLM_ANTHROPIC_BASE_URL", "VLE_LLM_ANTHROPIC_BASE_URL"); v != "" {
c.Engine.LLM.Anthropic.BaseURL = v
}
if v := firstEnv("VLS_LLM_ANTHROPIC_MODEL", "VLE_LLM_ANTHROPIC_MODEL"); v != "" {
c.Engine.LLM.Anthropic.Model = v
}
Comment on lines +327 to +332
}

// firstEnv returns the first non-empty value from the named env vars.
Expand Down
19 changes: 19 additions & 0 deletions pkg/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,6 +332,12 @@ type AnthropicBlock struct {
APIKey string `yaml:"api_key"`
Model string `yaml:"model"`
ReasoningModel string `yaml:"reasoning_model"`
// BaseURL overrides the Anthropic API endpoint. Empty = official
// api.anthropic.com. Set this to point the Anthropic driver at any
// Anthropic-compatible gateway — e.g. GLM/Zhipu's
// https://api.z.ai/api/anthropic — so the same driver can drive a
// non-Anthropic model that speaks the Messages API.
BaseURL string `yaml:"base_url"`
}

// OpenAIBlock configures the OpenAI provider.
Expand Down Expand Up @@ -805,6 +811,19 @@ func applyEnvOverrides(c *Config) {
if v := os.Getenv("VLE_LLM_DRIVER"); v != "" {
c.LLM.Driver = v
}
// Anthropic-driver overrides. These let an operator point the
// anthropic driver at an Anthropic-compatible gateway (e.g. GLM via
// https://api.z.ai/api/anthropic) without baking the values into the
// config file or secret.
if v := os.Getenv("VLE_LLM_ANTHROPIC_API_KEY"); v != "" {
c.LLM.Anthropic.APIKey = v
}
if v := os.Getenv("VLE_LLM_ANTHROPIC_BASE_URL"); v != "" {
c.LLM.Anthropic.BaseURL = v
}
if v := os.Getenv("VLE_LLM_ANTHROPIC_MODEL"); v != "" {
c.LLM.Anthropic.Model = v
}
if v := os.Getenv("VLE_TLS_CERT_FILE"); v != "" {
c.Server.TLS.CertFile = v
}
Expand Down
Loading