Skip to content

Get up and running with Kimi, GLM, MiniMax, DeepSeek, gpt-oss, Qwen, Gemma and other models.

cmd/config: use envconfig.Host() for base API in launch config packages (#13937)

Gabe Goodhart7b62c410605a
diff --git a/cmd/config/claude.go b/cmd/config/claude.go
index 9f1fa7ac9..bc183a6ac 100644
--- a/cmd/config/claude.go
+++ b/cmd/config/claude.go
@@ -6,6 +6,8 @@ import (
"os/exec"
"path/filepath"
"runtime"
+
+ "github.com/ollama/ollama/envconfig"
)
// Claude implements Runner for Claude Code integration
@@ -50,7 +52,7 @@ func (c *Claude) Run(model string) error {
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Env = append(os.Environ(),
- "ANTHROPIC_BASE_URL=http://localhost:11434",
+ "ANTHROPIC_BASE_URL="+envconfig.Host().String(),
"ANTHROPIC_API_KEY=",
"ANTHROPIC_AUTH_TOKEN=ollama",
)
diff --git a/cmd/config/clawdbot.go b/cmd/config/clawdbot.go
index f21b7db22..faad1251c 100644
--- a/cmd/config/clawdbot.go
+++ b/cmd/config/clawdbot.go
@@ -9,6 +9,8 @@ import (
"os/exec"
"path/filepath"
"strings"
+
+ "github.com/ollama/ollama/envconfig"
)
type Clawdbot struct{}
@@ -90,7 +92,7 @@ func (c *Clawdbot) Edit(models []string) error {
ollama = make(map[string]any)
}
- ollama["baseUrl"] = "http://127.0.0.1:11434/v1"
+ ollama["baseUrl"] = envconfig.Host().String() + "/v1"
// needed to register provider
ollama["apiKey"] = "ollama-local"
// TODO(parthsareen): potentially move to responses
diff --git a/cmd/config/droid.go b/cmd/config/droid.go
index 75e48d02f..1e2a853a9 100644
--- a/cmd/config/droid.go
+++ b/cmd/config/droid.go
@@ -7,6 +7,8 @@ import (
"os/exec"
"path/filepath"
"slices"
+
+ "github.com/ollama/ollama/envconfig"
)
// Droid implements Runner and Editor for Droid integration
@@ -117,7 +119,7 @@ func (d *Droid) Edit(models []string) error {
newModels = append(newModels, modelEntry{
Model: model,
DisplayName: model,
- BaseURL: "http://localhost:11434/v1",
+ BaseURL: envconfig.Host().String() + "/v1",
APIKey: "ollama",
Provider: "generic-chat-completion-api",
MaxOutputTokens: 64000,
diff --git a/cmd/config/droid_test.go b/cmd/config/droid_test.go
index 9d202fc98..58b4ea9f9 100644
--- a/cmd/config/droid_test.go
+++ b/cmd/config/droid_test.go
@@ -218,7 +218,7 @@ func TestDroidEdit(t *testing.T) {
}
}
- if model["baseUrl"] != "http://localhost:11434/v1" {
+ if model["baseUrl"] != "http://127.0.0.1:11434/v1" {
t.Errorf("unexpected baseUrl: %s", model["baseUrl"])
}
if model["apiKey"] != "ollama" {
@@ -447,7 +447,7 @@ const testDroidSettingsFixture = `{
{
"model": "existing-ollama-model",
"displayName": "existing-ollama-model",
- "baseUrl": "http://localhost:11434/v1",
+ "baseUrl": "http://127.0.0.1:11434/v1",
"apiKey": "ollama",
"provider": "generic-chat-completion-api",
"maxOutputTokens": 64000,
diff --git a/cmd/config/opencode.go b/cmd/config/opencode.go
index ace67f2e4..736acfec5 100644
--- a/cmd/config/opencode.go
+++ b/cmd/config/opencode.go
@@ -9,6 +9,8 @@ import (
"path/filepath"
"slices"
"strings"
+
+ "github.com/ollama/ollama/envconfig"
)
// OpenCode implements Runner and Editor for OpenCode integration
@@ -88,7 +90,7 @@ func (o *OpenCode) Edit(modelList []string) error {
"npm": "@ai-sdk/openai-compatible",
"name": "Ollama (local)",
"options": map[string]any{
- "baseURL": "http://localhost:11434/v1",
+ "baseURL": envconfig.Host().String() + "/v1",
},
}
}