fix: auto-route Ollama Cloud models to ollama.com when API key is set#381
Merged
fix: auto-route Ollama Cloud models to ollama.com when API key is set#381
Conversation
Cloud models (e.g. qwen3-coder:480b-cloud) sent through localhost fail with 401 because the local daemon doesn't forward client Bearer tokens. When OLLAMA_API_KEY is configured and the model is a cloud model, route directly to https://ollama.com instead of localhost:11434. Changes: - llm: add resolve_effective_host() with cloud auto-routing - llm: add is_cloud_model() detector, bail early when cloud model lacks API key, filter empty API keys as None - ai: show API key source and cloud routing in `fledge ai status` - ai: prompt for API key when `fledge ai use` selects a cloud model - config_cmds: show env var override indicators in `fledge config list` Closes #380 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
❌ Corvin says...
_
<(;\ .oO(oh no...)
|/(\
\(\\
" "\\
"Even the dumpster of code seems empty today."
CI Summary
| Check | Status |
|---|---|
| Dependency Audit | ✅ Passed |
| Integration (3 OS) | ❌ failure |
| Lint (fmt + clippy) | ❌ failure |
| Spec Validation | ❌ failure |
| Tests (3 OS) | ✅ Passed |
Powered by corvid-pet
Collaborator
Author
|
👋 CorvidAgent is looking into this. |
- rustfmt: reformat function signatures - clippy: replace useless format!() with .to_string() - spec: document 3 new exports (resolve_effective_host, is_cloud_model, DEFAULT_OLLAMA_CLOUD_HOST), add cloud routing invariants and error case Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Collaborator
Author
|
All three CI failures addressed in 3c89cdd:
Verified locally: |
Collaborator
Author
|
👋 CorvidAgent is looking into this. |
Contributor
There was a problem hiding this comment.
✅ Corvin says...
_
<(^\ .oO(Caw! ^v^)
|/(\
\(\\
" "\\
"Caw! Your code sparkles like a dropped french fry."
CI Summary
| Check | Status |
|---|---|
| Dependency Audit | ✅ Passed |
| Integration (3 OS) | ✅ Passed |
| Lint (fmt + clippy) | ✅ Passed |
| Spec Validation | ✅ Passed |
| Tests (3 OS) | ✅ Passed |
Powered by corvid-pet
Collaborator
Author
|
CI failures resolved in 3c89cdd:
All checks now passing — spec-check, lint, tests (3 OS), audit, and integration (3 OS). ✅ |
Collaborator
Author
|
👋 CorvidAgent is looking into this. |
2 similar comments
Collaborator
Author
|
👋 CorvidAgent is looking into this. |
Collaborator
Author
|
👋 CorvidAgent is looking into this. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
qwen3-coder:480b-cloud) now auto-route tohttps://ollama.comwhenOLLAMA_API_KEYis configured, instead of going throughlocalhost:11434where the local daemon can't forward authfledge ai statusnow shows API key source (env/config/not set) and whether cloud routing is activefledge ai useprompts for API key when selecting a cloud model without one configuredfledge config listnow shows env var override indicators forOLLAMA_HOSTandOLLAMA_API_KEYNone— prevents sendingAuthorization: Bearerwith no tokenHost resolution precedence
OLLAMA_HOSTenv var (explicit user override — always wins)https://ollama.com) when API key present AND model is cloudhttp://localhost:11434)Test plan
is_cloud_modelcorrectly matches-cloudvariantsresolve_effective_hostroutes cloud models to ollama.com with keyOLLAMA_HOSTenv var overrides cloud auto-routingbuild_providererrors early when cloud model lacks API keyCloses #380
🤖 Generated with Claude Code