Add custom headers for OpenAI-compatible providers - #54712
Closed
chindris-mihai-alexandru wants to merge 5 commits into
Closed
Add custom headers for OpenAI-compatible providers#54712chindris-mihai-alexandru wants to merge 5 commits into
chindris-mihai-alexandru wants to merge 5 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds first-class support for user-configured custom HTTP headers for OpenAI-compatible providers, and improves streaming robustness by ignoring data: null SSE keepalive events.
Changes:
- Add
custom_headerstolanguage_models.openai_compatiblesettings and plumb them through OpenAI/chat/completionsand/responsesrequests. - Ignore
data: nullSSE chunks during streaming for both Chat Completions and Responses APIs. - Update provider documentation and update call sites for the new streaming function signatures.
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| docs/src/ai/llm-providers.md | Documents custom_headers for OpenAI-compatible gateways. |
| crates/settings_content/src/language_model.rs | Adds custom_headers to OpenAI-compatible settings schema. |
| crates/open_ai/src/open_ai.rs | Threads custom headers into chat completions streaming; ignores null SSE events; adds unit tests. |
| crates/open_ai/src/responses.rs | Threads custom headers into responses streaming; ignores null SSE events; adds unit tests. |
| crates/language_models/src/settings.rs | Maps settings custom_headers into runtime provider settings. |
| crates/language_models/src/provider/open_ai_compatible.rs | Passes configured custom headers into OpenAI request helpers. |
| crates/language_models/src/provider/open_ai.rs | Updates OpenAI provider calls for new function signature (passes None). |
| crates/language_models/src/provider/x_ai.rs | Updates call for new function signature (passes None). |
| crates/language_models/src/provider/vercel.rs | Updates call for new function signature (passes None). |
| crates/language_models/src/provider/vercel_ai_gateway.rs | Updates call for new function signature (passes None). |
| crates/language_models/src/provider/opencode.rs | Updates calls for new function signature (passes None). |
| crates/agent_ui/src/agent_configuration/add_llm_provider_modal.rs | Ensures new providers written to settings include custom_headers field. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
4 tasks
Member
|
Thanks for working on this. Closing in favour of #55246 |
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.
Summary
This refreshes the earlier custom-header work from #42817 and #45673 with a smaller, settings-first implementation.
It adds
custom_headerssupport tolanguage_models.openai_compatible, threads those headers through both/chat/completionsand/responses, and documents the setting in the provider docs.While testing custom OpenAI-compatible gateways, I also ran into streaming responses that emit
data: nullkeepalive chunks, so this PR skips those chunks instead of failing deserialization.Testing
cargo test -p open_ai -qcargo check -p zedRelease Notes: