language_models: Support custom HTTP headers for provider requests - #55246
Conversation
6d7d728 to
968e5d2
Compare
|
This is an alternate solution to my previous attempt at adding custom header support for openAI compatible compatible providers. First #42817, then #45673. Each time I made the PR, it stayed there for a while without getting attention from maintainers, which would then cause merge conflict. The cycle continues through another PR another member from community created: #54712 This change does not have a UI, so I hope the smaller code change will help get it merged quicker than the previous attempts. |
|
@SomeoneToIgnore Any reviews? |
7363a6e to
b0a8971
Compare
|
Thanks for this. Changes look reasonable, can you run |
|
@bennetbo thanks for taking a look at this! I've fixed the formatting issues. Looks like I'm unable to edit the "Allow edits by maintainers" setting now :-| |
Add a `custom_headers` setting to each HTTP-based language model provider (Anthropic, Bedrock, DeepSeek, Google, LM Studio, Mistral, Ollama, OpenAI, OpenAI-compatible, OpenCode, OpenRouter, Vercel AI Gateway, and xAI) so users can attach extra headers to every outgoing request. Headers managed by Zed (authentication, content-type, etc.) cannot be overridden and are skipped with a warning. Release Notes: - Added support for configuring custom HTTP headers on language model providers via `language_models.<provider>.custom_headers`. Signed-off-by: Aurabindo Pillai <mail@aurabindo.in>
|
Thank you! |
|
Wohoo! thank you for merging <3 |
…ed-industries#55246) Add a `custom_headers` setting to each HTTP-based language model provider (Anthropic, Bedrock, DeepSeek, Google, LM Studio, Mistral, Ollama, OpenAI, OpenAI-compatible, OpenCode, OpenRouter, Vercel AI Gateway, and xAI) so users can attach extra headers to every outgoing request. Headers managed by Zed (authentication, content-type, etc.) cannot be overridden and are skipped with a warning. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Added support for configuring custom HTTP headers on language model providers via `language_models.<provider>.custom_headers`. Signed-off-by: Aurabindo Pillai <mail@aurabindo.in>
…ed-industries#55246) Add a `custom_headers` setting to each HTTP-based language model provider (Anthropic, Bedrock, DeepSeek, Google, LM Studio, Mistral, Ollama, OpenAI, OpenAI-compatible, OpenCode, OpenRouter, Vercel AI Gateway, and xAI) so users can attach extra headers to every outgoing request. Headers managed by Zed (authentication, content-type, etc.) cannot be overridden and are skipped with a warning. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Added support for configuring custom HTTP headers on language model providers via `language_models.<provider>.custom_headers`. Signed-off-by: Aurabindo Pillai <mail@aurabindo.in>
…ed-industries#55246) Add a `custom_headers` setting to each HTTP-based language model provider (Anthropic, Bedrock, DeepSeek, Google, LM Studio, Mistral, Ollama, OpenAI, OpenAI-compatible, OpenCode, OpenRouter, Vercel AI Gateway, and xAI) so users can attach extra headers to every outgoing request. Headers managed by Zed (authentication, content-type, etc.) cannot be overridden and are skipped with a warning. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Added support for configuring custom HTTP headers on language model providers via `language_models.<provider>.custom_headers`. Signed-off-by: Aurabindo Pillai <mail@aurabindo.in>
…ed-industries#55246) Add a `custom_headers` setting to each HTTP-based language model provider (Anthropic, Bedrock, DeepSeek, Google, LM Studio, Mistral, Ollama, OpenAI, OpenAI-compatible, OpenCode, OpenRouter, Vercel AI Gateway, and xAI) so users can attach extra headers to every outgoing request. Headers managed by Zed (authentication, content-type, etc.) cannot be overridden and are skipped with a warning. Self-Review Checklist: - [x] I've reviewed my own diff for quality, security, and reliability - [x] Unsafe blocks (if any) have justifying comments - [x] The content is consistent with the [UI/UX checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) - [] Tests cover the new/changed behavior - [x] Performance impact has been considered and is acceptable Release Notes: - Added support for configuring custom HTTP headers on language model providers via `language_models.<provider>.custom_headers`. Signed-off-by: Aurabindo Pillai <mail@aurabindo.in>
Most of the 59 conflicts were not real divergence: earlier merges had silently reverted upstream code, so the fork side was simply older. Those files were taken from upstream wholesale after confirming they carried no Lathe commits. Restored upstream work that prior merges had dropped: * Custom HTTP headers across every LLM provider (upstream zed-industries#55246), plus extra_beta_headers, the xhigh reasoning effort, Copilot token handling, and the cloud reconnect / model refresh task. 38 files under crates/{anthropic,open_ai,google_ai,copilot_chat,opencode,open_router, language_models,bedrock} had no fork commits and now match upstream. * language::file_content, replacing an inlined copy in worktree.rs. * The Project Panel doc page and its SUMMARY entry. * threads_archive_view window controls and archived-thread fallback. * worktree file_scan_depth support and its test suite. Structural resolutions: * worktree_service: the fork had split it into creation/opening/selection while upstream moved it into the new git_ui_core crate. The split now lives in git_ui_core, with upstream's askpass cancellation, find_or_create_workspace, and MultiWorkspace::add changes applied. * File history: project_panel now goes through upstream's git_ui_core::open_file_history seam, and git_ui::init registers Lathe's FileHistoryView as the opener, so the feature is unchanged. * zed.proto: upstream's BlameBufferAtRevision pair moved to 480/481 because Lathe already occupies 478/479 with git_file_history. Renumbering upstream keeps released Lathe clients wire-compatible. * git repository backend stays libgit2-backed, converted to upstream's byte-oriented load_index_text / load_committed_text / load_blob_content. * build_gitignore_with_root ported: upstream's stricter repo-exclude guard in ignore.rs needs .git/info/exclude rooted at the work directory. Lathe behavior preserved: LatheLogo, the show_branch_name gate and the combined Branch & Stash picker, StashFile, UndoLogChanged, SkillsFeatureFlag, the git panel Lathe module and its ANSI-aware error toast, telemetry removal, synthetic-drag cancellation on window move, and ThreadTaskTimings. Not ported, each needing an upstream refactor the fork lacks: * The agent panel's create_thread / list_agents_and_models host, which depends on CreateThreadOptions and create_thread_with_options. * reinitialize_local_backend on work directory moves, which depends on respawn_local_worker. * cat-numbered code block rendering in thread_view. * render_ref_chip in git_graph, whose context menu takes no ref argument. CI: release_fork.yml and the Lathe Linux/Windows workflows updated for upstream's new workflow checks (top level permissions, no GitHub input interpolation inside run blocks). Verified: cargo check --workspace --all-targets, ./script/clippy, and cargo xtask workflows are clean. Remaining test failures in worktree, git, language, project, dev_container, editor and project_panel all reproduce at 4c757b2, and the gpui spring animation flake reproduces on pristine upstream under the same parallel load.
Add a
custom_headerssetting to each HTTP-based language model provider(Anthropic, Bedrock, DeepSeek, Google, LM Studio, Mistral, Ollama, OpenAI,
OpenAI-compatible, OpenCode, OpenRouter, Vercel AI Gateway, and xAI) so users
can attach extra headers to every outgoing request. Headers managed by Zed
(authentication, content-type, etc.) cannot be overridden and are skipped with
a warning.
Self-Review Checklist:
Release Notes:
providers via
language_models.<provider>.custom_headers.