Skip to content

feat: add query_params option to ModelProviderInfo to support Azure#1435

Merged
bolinfest merged 1 commit intomainfrom
pr1435
Jun 30, 2025
Merged

feat: add query_params option to ModelProviderInfo to support Azure#1435
bolinfest merged 1 commit intomainfrom
pr1435

Conversation

@bolinfest
Copy link
Collaborator

@bolinfest bolinfest commented Jun 30, 2025

As discovered in #1365, the Azure provider needs to be able to specify api-version as a query param, so this PR introduces a generic query_params option to the model_providers config so that an Azure provider can be defined as follows:

[model_providers.azure]
name = "Azure"
base_url = "https://YOUR_PROJECT_NAME.openai.azure.com/openai"
env_key = "AZURE_OPENAI_API_KEY"
query_params = { api-version = "2025-04-01-preview" }

This PR also updates the docs with this example.

While here, we also update wire_api to default to "chat", as that is likely the common case for someone defining an external provider.

Fixes #1365.

@bolinfest bolinfest added the code-review Issues relating to code reviews performed by codex label Jun 30, 2025
@github-actions github-actions bot added codex-review-in-progress and removed code-review Issues relating to code reviews performed by codex labels Jun 30, 2025
@github-actions
Copy link
Contributor

PR Summary

Adds optional query_params support in ModelProviderInfo and centralises endpoint construction via get_full_url, enabling providers like Azure that require query-string arguments. Refactors call sites, updates docs/examples, and expands tests accordingly.

Notes

  • query_params: HashMap<String, String> (default None) appended to /chat/completions or /responses depending on wire_api.
  • get_full_url removes scattered string concatenation in chat_completions.rs & client.rs.
  • Docs now clarify default wire_api = "chat" and show Azure/Ollama examples.
  • New unit tests cover TOML deserialisation with/without query_params.

Review

Nice, tidy enhancement that makes provider configs more flexible and reduces URL-building duplication.

✅ Looks good overall; just a couple of nits:

  • Consider using the url crate to percent-encode query values and avoid manual k=v joins.
  • get_full_url trims neither trailing slashes nor ensures leading ones—worth double-checking edge cases.

Otherwise, great addition! 🎉


View workflow run

@bolinfest bolinfest merged commit 6dad5c3 into main Jun 30, 2025
12 checks passed
@bolinfest bolinfest deleted the pr1435 branch June 30, 2025 18:39
@github-actions github-actions bot locked and limited conversation to collaborators Jun 30, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Migrating from codex-cli to codex-rs

1 participant