fix(azureopenai): update correct request body format for azure openai endpoints#29421
Conversation
Greptile SummaryThis PR attempts to fix Azure OpenAI custom provider validation by adjusting the authentication header and request body format in Key issues found:
All three changes need to be made conditional on Confidence Score: 1/5
Last reviewed commit: 96b59ad |
Additional Comments (1)
For Azure OpenAI the model/deployment is embedded in the request URL, so omitting The body: {
...(!isAzureUrl(params.baseUrl) ? { model: params.modelId } : {}),
messages: [{ role: "user", content: "Hi" }],
temperature: 1,
max_completion_tokens: DEFAULT_MAX_TOKENS,
stream: false,
},Prompt To Fix With AIThis is a comment left during a code review.
Path: src/commands/onboard-custom.ts
Line: 314-323
Comment:
**Removing `model` breaks all non-Azure OpenAI-compatible providers**
For Azure OpenAI the model/deployment is embedded in the request URL, so omitting `model` from the body is correct there. However, standard OpenAI and virtually every other OpenAI-compatible API (Ollama, Together AI, Fireworks, LM Studio, etc.) require `model` in the request body — omitting it will yield a `400` or `422` error for all those providers.
The `model` field should be included conditionally based on whether the URL is an Azure URL:
```ts
body: {
...(!isAzureUrl(params.baseUrl) ? { model: params.modelId } : {}),
messages: [{ role: "user", content: "Hi" }],
temperature: 1,
max_completion_tokens: DEFAULT_MAX_TOKENS,
stream: false,
},
```
How can I resolve this? If you propose a fix, please make it concise. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 96b59ad579
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: f4da4a3ecd
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 4f373411ac
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bae5810824
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1c2755c66b
ℹ️ About Codex in GitHub
Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
00dbe4b to
b118db6
Compare
|
Landed via temp rebase onto main.
Thanks @kunalk16! |
…) (thanks @kunalk16) (cherry picked from commit 9393dbdd14be2f612059d99620938f22938fa4be)
Summary
Describe the problem and fix in 2–5 bullets:
Change Type (select all)
Scope (select all touched areas)
Linked Issue/PR
None
User-visible / Behavior Changes
List user-visible changes (including defaults/config).
None
Security Impact (required)
Yes, explain risk + mitigation:Repro + Verification
Verified in my test ubuntu virtual machines

Repro step is to use custom provider for openclaw onboard using a valid openai endpoint, apikey and model deployment. It currently fails with verification failure 400 response
Failure repro:
Successful after fix repro:

Environment
Steps
Expected
Validation to be successful for correct azure openai endpoint, api key, model deployment name
Actual
Current code returns 400 error during validation for azure openai endpoints
Evidence
Attach at least one:
Fails before the fix:

Successful after the fix:

Human Verification (required)
What you personally verified (not just CI), and how:
Compatibility / Migration
Failure Recovery (if this breaks)
Risks and Mitigations
List only real risks for this PR. Add/remove entries as needed. If none, write
None.None