Repository navigation
fix: read provider config from Settings in FastAPI router - #47
Merged
Merged
Conversation
The dev-path Router resolved API keys and base URLs from os.environ directly, so a .env file alone (the documented setup) produced a misleading "Unknown model" 400 instead of configuring the provider. Delegate to the shared bridge resolvers (mojo_bridge.routing) so both servers resolve routes, keys, and base URLs identically via Settings, and split the error paths: 400 unknown model vs 503 no API key configured. Also adds suite-wide hermetic settings (tests/conftest.py): a local .env leaking into the suite is the same bug class, and 5 existing tests failed whenever one was present. Closes #46 Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Show how to run the full gateway path offline with the bundled tests/mock_upstream.py instead of a paid API key. Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
Co-authored-by: opencode-agent[bot] <219766164+opencode-agent[bot]@users.noreply.github.com>
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
Routerresolved provider API keys/base URLs fromos.environdirectly, so the documented.env-only setup produced a misleading400 Unknown modelinstead of configuring the provider. It now delegates to the shared bridge resolvers (mojo_bridge.routing), so both servers resolve routes, keys, and base URLs identically viaSettings.400 Unknown model: {model}(no route) vs503 no API key configured for provider {module}(route matched, gateway not configured).tests/conftest.pysuite-wide hermetic settings — a local.envleaking into the suite is the same bug class (5 existing tests failed whenever one was present)..env-only config serves requests; unknown-model vs missing-key produce distinct errors.tests/mock_upstream.py..playwright-mcp/.Closes #46
Consequences
Router.select_providernow raisesProviderNotConfiguredError(instead of returningNone) when a route matches but no key is configured; callers outsidemain.pywould need the same handling. None in-tree.claude-*/bedrock/*etc. now resolve to their real provider modules on the FastAPI path (previously everything mapped to OpenAI) — matching the Mojo bridge and removing drift.Testing
.env-only startup now serves200completions;400/503error split verified with curl; live end-to-end run against the mimo OpenAI-compatible API (non-streaming + SSE streaming) throughROUTES_JSON