Skip to content

Add extra headers support for custom LLM providers#739

Open
Duyi-Wang wants to merge 1 commit into
Open-Less:betafrom
Duyi-Wang:dev
Open

Add extra headers support for custom LLM providers#739
Duyi-Wang wants to merge 1 commit into
Open-Less:betafrom
Duyi-Wang:dev

Conversation

@Duyi-Wang

@Duyi-Wang Duyi-Wang commented Jun 23, 2026

Copy link
Copy Markdown

User description

背景

部分 OpenAI-compatible 的 custom LLM provider 需要通过自定义 HTTP headers 完成接入。现有配置只支持 Base URL、API Key 和 Model,无法覆盖这类 custom 接入需求,也会影响模型拉取、provider 校验和实际调用链路的一致性。

变更

  • 为 custom LLM provider 增加 Extra headers 配置入口,使用 JSON object 格式填写。
  • 将 extra headers 接入 credentials 持久化,避免把自定义鉴权信息写入普通配置。
  • 在 provider 校验、模型拉取、实际 LLM provider 构建时统一传递 extra headers。
  • 增加 header name/value 校验:
    • JSON 必须是 object。
    • header value 必须是 string。
    • header name 必须是合法 HTTP header token。
    • header value 不允许包含 CR/LF。
  • 支持 API Key 留空时不发送默认 Bearer header,便于 custom provider 使用纯自定义 header 接入。
  • 补充多语言文案和后端测试覆盖。

验证

  • git diff --check
  • npm run build -- --mode development

PR Type

Enhancement, Tests


Description

  • Add extra headers support for custom LLM providers

  • Include validation and persistence of extra headers JSON

  • Propagate extra headers through provider config, request, and UI

  • Add test for extra headers and empty API key behavior


Diagram Walkthrough

flowchart LR
  UI["UI: Extra headers field"] --> Credentials["Credentials: ark.extra_headers account"]
  Credentials --> Persist["Storage: parse & validate JSON"]
  Persist --> ProviderConfig["ProviderConfig: include extra_headers"]
  ProviderConfig --> Request["Request: add custom headers"]
  Request --> Provider["OpenAI-compatible provider"]
Loading

File Walkthrough

Relevant files
Enhancement
6 files
credentials.rs
Handle extra headers as special account                                   
+10/-0   
providers.rs
Include extra headers in provider config and requests       
+17/-2   
coordinator.rs
Pass extra headers when building LLM provider                       
+2/-1     
credentials.rs
Add persist, parse, and validate extra headers                     
+97/-1   
polish.rs
Add builder method for extra headers                                         
+5/-0     
ProvidersSection.tsx
Show extra headers field for custom provider                         
+10/-0   
Tests
1 files
mod.rs
Add test for extra headers in model fetch                               
+52/-0   
Documentation
5 files
en.ts
Add English i18n for extra headers                                             
+2/-0     
ja.ts
Add Japanese i18n for extra headers                                           
+2/-0     
ko.ts
Add Korean i18n for extra headers                                               
+2/-0     
zh-CN.ts
Add Chinese i18n for extra headers                                             
+2/-0     
zh-TW.ts
Add Traditional Chinese i18n for extra headers                     
+2/-0     

@github-actions

github-actions Bot commented Jun 23, 2026

Copy link
Copy Markdown
Contributor

PR Reviewer Guide 🔍

(Review updated until commit c224c00)

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 No security concerns identified
⚡ No major issues detected

@github-actions

Copy link
Copy Markdown
Contributor

Persistent review updated to latest commit c224c00

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant