Skip to content

[BUG] Custom provider headers (User-Agent) from opencode.json not applied to fetch requests #22608

Closed as not planned

Description

@woaye168

Description

When configuring custom headers for a provider in opencode.json, the User-Agent header (and potentially other custom headers) is not actually sent with the API requests.

This is particularly important for providers like Kimi (https://api.kimi.com/coding/v1), where sending a custom User-Agent unlocks higher rate limits and additional coding plan quotas.

Configuration Example

{
  "provider": {
    "kimi-cli": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "kimi-cli",
      "options": {
        "baseURL": "https://api.kimi.com/coding/v1",
        "apiKey": "{env:ANTHROPIC_API_KEY}",
        "headers": {
          "Authorization": "Bearer sk-kimi-xxx",
          "User-Agent": "KimiCLI/1.30.0"
        }
      }
    }
  }
}

Expected Behavior

The User-Agent: KimiCLI/1.30.0 header should be included in the HTTP requests sent to the provider API.

Actual Behavior

The custom User-Agent header is not applied to the outgoing fetch requests. This causes the provider to treat the request as a generic client, missing out on official client benefits (e.g., higher rate limits, extra coding plan quota for Kimi).

Related Issues

Plugins

None

OpenCode version

No response

Operating System

All

Terminal

All

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 15, 2026
  2. github-actions commented on Apr 15, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

  3. woaye168 commented on Apr 15, 2026

    @woaye168
    Author

    Thanks for the triage, but I believe this issue is distinct from #15306 in a few important ways:

    1. Specific symptom: Are custom provider headers from config expected to work in v1.2.x? #15306 is a broad question about whether any custom provider headers work. This issue is specifically about the User-Agent header being silently dropped, which is a concrete, reproducible bug.

    2. Real-world business impact: For the Kimi provider (api.kimi.com/coding/v1), the User-Agent header is not cosmetic — it directly determines:

      • Request routing and speed: Requests without the official User-Agent (KimiCLI/1.30.0) are routed to a lower-priority tier.
      • Coding plan quota: Kimi allocates additional coding-plan credits only to requests that identify as the official CLI client. Without this header, users burn through their generic quota much faster and hit rate limits sooner.
    3. Regression context: provider headers from config not applied to fetch requests #11789 reported the exact same bug and was closed as "fixed" by PR fix(provider): apply config headers to fetch requests #11978. The fact that User-Agent is still not being forwarded today suggests the previous fix was either incomplete or regressed. This issue highlights a specific header that the prior fix missed.

    Could a maintainer please confirm whether the custom fetch wrapper in provider.ts is stripping/overwriting the User-Agent header? Happy to provide packet captures or verbose logs if needed.

  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
  5. github-actions commented on Jul 4, 2026

    @github-actions
    Contributor

    To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.

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

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions