Skip to content

Add custom headers for OpenAI-compatible providers - #54712

Closed
chindris-mihai-alexandru wants to merge 5 commits into
zed-industries:mainfrom
chindris-mihai-alexandru:fix/openai-compatible-custom-headers-upstream
Closed

Add custom headers for OpenAI-compatible providers#54712
chindris-mihai-alexandru wants to merge 5 commits into
zed-industries:mainfrom
chindris-mihai-alexandru:fix/openai-compatible-custom-headers-upstream

Conversation

@chindris-mihai-alexandru

Copy link
Copy Markdown

Summary

This refreshes the earlier custom-header work from #42817 and #45673 with a smaller, settings-first implementation.

It adds custom_headers support to language_models.openai_compatible, threads those headers through both /chat/completions and /responses, and documents the setting in the provider docs.

While testing custom OpenAI-compatible gateways, I also ran into streaming responses that emit data: null keepalive chunks, so this PR skips those chunks instead of failing deserialization.

Testing

  • cargo test -p open_ai -q
  • cargo check -p zed

Release Notes:

  • Improved OpenAI-compatible providers to support custom HTTP headers and ignore null SSE keepalive events.

Copilot AI review requested due to automatic review settings April 23, 2026 21:01
@cla-bot cla-bot Bot added the cla-signed The user has signed the Contributor License Agreement label Apr 23, 2026
@zed-community-bot zed-community-bot Bot added the first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions label Apr 23, 2026

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_headers to language_models.openai_compatible settings and plumb them through OpenAI /chat/completions and /responses requests.
  • Ignore data: null SSE 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.

Comment thread docs/src/ai/llm-providers.md
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@SomeoneToIgnore SomeoneToIgnore added the area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features label Apr 24, 2026
@bennetbo

bennetbo commented Jun 1, 2026

Copy link
Copy Markdown
Member

Thanks for working on this. Closing in favour of #55246

@bennetbo bennetbo closed this Jun 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:ai Related to Agent Panel, Edit Prediction, Copilot, or other AI features cla-signed The user has signed the Contributor License Agreement first contribution the author's first pull request to Zed. NOTE: the label application is automated via github actions

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants