feat(codex): reroute GET /models to OpenAI-shaped discovery for IntelliJ - #242
Open
IceRhymers wants to merge 1 commit into
Open
feat(codex): reroute GET /models to OpenAI-shaped discovery for IntelliJ#242IceRhymers wants to merge 1 commit into
IceRhymers wants to merge 1 commit into
Conversation
OpenAI-shaped clients (e.g. JetBrains IntelliJ's AI Assistant, pointed at
the local proxy root) enumerate models via GET /models. The codex proxy
forwards to the {host}/ai-gateway/openai/v1 base path, but Databricks has
no /ai-gateway/openai/v1/models endpoint — a naive forward 400s with
"doesn't match any known API type". The working discovery endpoint is
{host}/ai-gateway/v1/models, but it returns a Databricks-shaped list
(query_name/display_name), not OpenAI's {id, object:"model"}.
Add an opt-in GET /models reroute to the shared proxy engine, gated on
the new Config.OpenAIModelsUpstream field:
- internal/core/proxy/models_reroute.go: when the field is set, register
GET /models (exact-match), fetch the discovery URL with a fresh token,
and transform the body to the OpenAI shape. Non-GET /models and
/models/{id} fall through to the inference catch-all.
- Thread the field through LaunchPlan -> core.Run -> proxy.Config, and
through the codex ProxyConfig facade (serve_codex.go bypasses core.Run).
- New ConstructModelsURL(host) in codex token.go (const /ai-gateway/v1/models),
single-sourced into both launch_codex.go (wrapper) and serve_codex.go (serve).
Off by default: claude and opencode leave OpenAIModelsUpstream empty, so
the route is never registered — byte-identical to before. The multiplexer
(databricks-agents codex serve) is covered automatically via exec-delegation.
Verified live against fevm-west: both databricks-codex serve and
databricks-agents codex serve return 44 OpenAI-shaped models on GET /models;
POST /models still forwards to inference.
Co-authored-by: Isaac
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.
What
OpenAI-shaped clients — notably JetBrains IntelliJ's AI Assistant, pointed at the local proxy root — enumerate models via
GET /models. The codex proxy forwards to the{host}/ai-gateway/openai/v1base path, but Databricks has no/ai-gateway/openai/v1/modelsendpoint — a naive forward 400s with"doesn't match any known API type". The working discovery endpoint is{host}/ai-gateway/v1/models(no/openai/v1segment), but it returns a Databricks-shaped list (query_name/display_name), not OpenAI's{id, object:"model"}.This adds an opt-in
GET /modelsreroute to the shared proxy engine, gated on a newConfig.OpenAIModelsUpstreamfield.How
internal/core/proxy/models_reroute.go— whenOpenAIModelsUpstreamis set, registerGET /models(exact-match), fetch the discovery URL with a fresh token, and transform the body to the OpenAI shape (id=query_name,object:"model",owned_by:"databricks"). Non-GET/modelsand/models/{id}fall through to the inference catch-all.LaunchPlan→core.Run→proxy.Config, and through the codexProxyConfigfacade (serve_codex.gobypassescore.Run).ConstructModelsURL(host)in codextoken.go(const/ai-gateway/v1/models), single-sourced into bothlaunch_codex.go(wrapper) andserve_codex.go(serve).Off by default
Claude and opencode leave
OpenAIModelsUpstreamempty, so the route is never registered — byte-identical to before. The multiplexer (databricks-agents codex serve) is covered automatically via exec-delegation.Testing
ConstructModelsURLtest; full affected suites green.fevm-west: bothdatabricks-codex serveanddatabricks-agents codex servereturn 44 OpenAI-shaped models onGET /models;POST /modelsstill forwards to inference.Note
The transformed
createdfield is a fixed constant — the gateway exposes no per-model creation time. OpenAI clients only require the field present and numeric; revisit if a client sorts by it.This pull request and its description were written by Isaac.