8000 Fix: Ensure OpenAI SDK extra_body fields can correctly merge into request by chenjiawei30 · Pull Request #1119 · QuantumNous/new-api · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Fix: Ensure OpenAI SDK extra_body fields can correctly merge into request #1119

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

chenjiawei30
Copy link

🔧 Description:

This PR fixes an issue where requests using the extra_body parameter with the OpenAI Python SDK do not function as intended.

⚠️ The OpenAI SDK automatically merges extra_body fields into the top-level JSON payload. As a result, on the backend, the ExtraBody field in our request struct remains empty, and the extra parameters (such as guided_choice, guided_json, etc.) are ignored.

This behavior is identical to using the requests to send these parameters at the root of the payload, which is also a valid and common way users interact with the API.

Previously, we relied on the presence of ExtraBody in the parsed request struct, which remains empty in this case, leading to missing parameters when forwarding the request upstream.


✅ Fix:

  • When passthrough is disabled, we now scan the top-level request payload for keys that are typically expected in extra_body.
  • These fields are then explicitly merged back into the outgoing request to the model server.
  • This preserves the original logic and avoids breaking passthrough mode.

💡 Why this matters:

Without this patch, SDK users (and native requests users sending guided_* or response_format directly in the root) will experience confusing failures, where valid parameters are silently dropped. This fix ensures full compatibility with both SDK usage patterns and manual requests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant
0