Skip to content
Closed
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
12 changes: 8 additions & 4 deletions codex-rs/app-server/src/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ mod tests {
let models =
fallback_supported_models_for_provider("cerebras", /*include_hidden*/ false);

assert_eq!(models.len(), 2);
assert_eq!(models.len(), 3);
assert_eq!(models[0].model, "gpt-oss-120b");
assert_eq!(models[0].display_name, "OpenAI GPT OSS 120B");
assert!(models[0].is_default);
Expand All @@ -250,6 +250,9 @@ mod tests {
assert_eq!(models[1].display_name, "Z.ai GLM 4.7");
assert!(!models[1].is_default);
assert_eq!(models[1].default_reasoning_effort, ReasoningEffort::Medium);
assert_eq!(models[2].model, "gemma-4-31b");
assert_eq!(models[2].display_name, "Gemma 4 31B");
assert!(!models[2].is_default);
}

#[test]
Expand Down Expand Up @@ -277,16 +280,17 @@ mod tests {
let models =
fallback_supported_models_for_provider("anthropic", /*include_hidden*/ false);

assert_eq!(models.len(), 4);
assert_eq!(models.len(), 5);
assert_eq!(models[0].model, "claude-fable-5");
assert_eq!(models[0].display_name, "Claude Fable 5");
assert!(models[0].is_default);
assert!(!models[0].hidden);
assert_eq!(models[0].default_reasoning_effort, ReasoningEffort::None);
assert_eq!(models[0].supported_reasoning_efforts, Vec::new());
assert_eq!(models[1].model, "claude-opus-4-8");
assert_eq!(models[2].model, "claude-sonnet-4-6");
assert_eq!(models[3].model, "claude-haiku-4-5-20251001");
assert_eq!(models[2].model, "claude-sonnet-5");
assert_eq!(models[3].model, "claude-sonnet-4-6");
assert_eq!(models[4].model, "claude-haiku-4-5-20251001");
}

#[test]
Expand Down
6 changes: 5 additions & 1 deletion codex-rs/app-server/tests/suite/v2/model_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,11 @@ wire_api = "responses"
data.iter()
.map(|model| (model.id.as_str(), model.is_default))
.collect::<Vec<_>>(),
vec![("gpt-oss-120b", true), ("zai-glm-4.7", false)]
vec![
("gpt-oss-120b", true),
("zai-glm-4.7", false),
("gemma-4-31b", false),
]
);
assert!(next_cursor.is_none());
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion codex-rs/codex-api/src/endpoint/models.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1294,7 +1294,7 @@ mod tests {
assert_eq!(deepseek.display_name, "DeepSeek V4 Flash");
assert_eq!(deepseek.context_window, Some(1_048_576));
assert_eq!(deepseek.max_context_window, Some(1_048_576));
assert_eq!(deepseek.experimental_supported_tools, Vec::<String>::new());
assert_eq!(deepseek.experimental_supported_tools, vec!["tools"]);
assert!(!deepseek.supports_parallel_tool_calls);
let glm = &models[4];
assert_eq!(glm.display_name, "Z.ai GLM 5.1");
Expand Down
35 changes: 35 additions & 0 deletions codex-rs/model-provider-info/src/model_provider_info_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,41 @@ query_params = { api-version = "2025-04-01-preview" }
assert_eq!(expected_provider, provider);
}

#[test]
fn test_deserialize_azure_v1_model_provider_toml() {
// Azure's v1 API uses the `/openai/v1` base path and no longer needs a
// dated `api-version` query parameter. This must deserialize without any
// `query_params` while leaving the legacy dated form (asserted in
// `test_deserialize_azure_model_provider_toml`) intact.
let azure_provider_toml = r#"
name = "Azure v1"
base_url = "https://xxxxx.openai.azure.com/openai/v1"
env_key = "AZURE_OPENAI_API_KEY"
"#;
let expected_provider = ModelProviderInfo {
name: "Azure v1".into(),
base_url: Some("https://xxxxx.openai.azure.com/openai/v1".into()),
env_key: Some("AZURE_OPENAI_API_KEY".into()),
env_key_instructions: None,
experimental_bearer_token: None,
auth: None,
aws: None,
wire_api: WireApi::Responses,
query_params: None,
http_headers: None,
env_http_headers: None,
request_max_retries: None,
stream_max_retries: None,
stream_idle_timeout_ms: None,
websocket_connect_timeout_ms: None,
requires_openai_auth: false,
supports_websockets: false,
};

let provider: ModelProviderInfo = toml::from_str(azure_provider_toml).unwrap();
assert_eq!(expected_provider, provider);
}

#[test]
fn test_deserialize_example_model_provider_toml() {
let azure_provider_toml = r#"
Expand Down
2 changes: 1 addition & 1 deletion codex-rs/models-manager/src/model_info_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ fn known_nvidia_deepseek_model_uses_local_metadata() {
assert_eq!(model.display_name, "DeepSeek V4 Flash");
assert_eq!(model.context_window, Some(1_048_576));
assert_eq!(model.max_context_window, Some(1_048_576));
assert_eq!(model.experimental_supported_tools, Vec::<String>::new());
assert_eq!(model.experimental_supported_tools, vec!["tools"]);
assert!(!model.supports_parallel_tool_calls);
assert!(!model.used_fallback_model_metadata);
}
Expand Down
11 changes: 9 additions & 2 deletions codex-rs/responses-api-proxy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,15 +79,22 @@ codex-responses-api-proxy [--port <PORT>] [--server-info <FILE>] [--http-shutdow
- `--dump-dir <DIR>`: If set, writes one request JSON file and one response JSON file per accepted proxy call under this directory. Filenames use a shared sequence/timestamp prefix so each pair is easy to correlate.
- Authentication is fixed to `Authorization: Bearer <key>` to match Codewith expectations.

For Azure, for example (ensure your deployment accepts `Authorization: Bearer <key>`):
For Azure OpenAI, point `--upstream-url` at the current v1 Responses endpoint. Microsoft's v1 API uses `https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses` and no longer requires a dated `api-version` query parameter:

```shell
printenv AZURE_OPENAI_API_KEY | env -u AZURE_OPENAI_API_KEY codex-responses-api-proxy \
--http-shutdown \
--server-info /tmp/server-info.json \
--upstream-url "https://YOUR_PROJECT_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT/responses?api-version=2025-04-01-preview"
--upstream-url "https://YOUR-RESOURCE-NAME.openai.azure.com/openai/v1/responses"
```

Because the proxy always injects a fixed `Authorization: Bearer <key>` header (see the CLI note above), the value you pipe on `stdin` must be something Azure accepts as a bearer token:

- **API key:** Azure's v1 API accepts the resource API key as a bearer token — this is how the standard `OpenAI()` client authenticates against Azure with key-based auth — so piping `AZURE_OPENAI_API_KEY` works directly. The alternative Azure `api-key: <key>` header form is not produced by this proxy.
- **Microsoft Entra ID (recommended):** pipe a valid Entra ID access token (for example from `az account get-access-token --resource https://ai.azure.com` or a `DefaultAzureCredential` token provider) instead of the API key. Entra tokens are short-lived, so restart the proxy once the token expires.

The incoming proxy request must still be `POST /v1/responses` with no query string, but `--upstream-url` accepts a full URL. A legacy dated endpoint such as `https://YOUR_PROJECT_NAME.openai.azure.com/openai/deployments/YOUR_DEPLOYMENT/responses?api-version=2025-04-01-preview` therefore keeps working if your resource has not migrated to the v1 path. The same applies to custom `model_providers` entries that set `query_params = { api-version = "..." }`; those dated configurations remain supported.

## Notes

- Only `POST /v1/responses` is permitted. No query strings are allowed.
Expand Down
Loading