Skip to content

fix: kimi-for-coding provider gets 429 engine overloaded due to missing User-Agent header #27902

Closed as not planned

Description

@bzqzheng

Description

The built-in kimi-for-coding provider uses @ai-sdk/anthropic, which sends Anthropic/JS x.x.x as the User-Agent on every request. Kimi's /coding gateway intermittently returns HTTP 429 engine overloaded for requests from non-whitelisted agents — even with a valid paid API key and available quota.

Setting User-Agent: KimiCLI/1.5 (a whitelisted coding agent UA) significantly reduces these 429s in practice. The same fix is documented for other clients using the Anthropic SDK against Kimi's endpoint.

Plugins

none (built-in provider)

OpenCode version

1.15.3

Steps to reproduce

  1. Set up the built-in kimi-for-coding provider with a valid KIMI_API_KEY
  2. Send messages using a kimi-for-coding model (k2p6, k2p5, kimi-k2-thinking)
  3. Observe intermittent 429 {"error":{"type":"rate_limit_error","message":"The engine is currently overloaded, please try again later"}}

The 429s are intermittent but noticeably reduced after overriding the User-Agent to KimiCLI/1.5.

Operating System

macOS 26.0

Activity

  1. github-actions commented on May 16, 2026

    @github-actions
    Contributor

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

  2. bzqzheng commented on May 16, 2026

    @bzqzheng
    Author

    Not a duplicate — these are related but distinct:

    In other words, #24594 is why the fix cannot go in custom() via options.headers (the pattern used by Cloudflare and GitLab providers, which are also silently broken for UA today). The PR uses model.headers in fromModelsDevModel specifically to work around this.

  3. BrianJM commented on May 16, 2026

    @BrianJM

    I experienced this issue between 5/11 - 5/13 using both anthropic and openai-compatible. On 5/13, I manually patched OpenCode 1.14.50 to use a KimiCLI User-Agent:

    perl -i -pe 's/"User-Agent": `opencode\/\$\{InstallationVersion\}`/"User-Agent": (process.env.OPENCODE_USER_AGENT || "KimiCLI\/1.37.0")/g' opencode/packages/opencode/src/session/llm.ts
    

    That fixed the issue and I have not received the error since. Others on the Kimi Discord continue to report the error. Those that apply the patch also report that replacing the User-Agent resolves the issue.

  4. CrazyTomatoOo commented on May 18, 2026

    @CrazyTomatoOo

    Is there any workaround for this? I can no longer use my Kimi coding plan.

  5. tapcrapioca commented on May 18, 2026

    @tapcrapioca

    Is there any workaround for this? I can no longer use my Kimi coding plan.

    The workaround has been mentioned right above your reply. You can ask Kimi on web to help you implement the patch.

  6. bzqzheng commented on May 18, 2026

    @bzqzheng
    Author

    Is there any workaround for this? I can no longer use my Kimi coding plan.

    Try add this to opencode config

    "kimi-for-coding": {
          "models": {
            "k2p6":             { "headers": { "User-Agent": "KimiCLI/1.5" } },
            "k2p5":             { "headers": { "User-Agent": "KimiCLI/1.5" } },
            "kimi-k2-thinking": { "headers": { "User-Agent": "KimiCLI/1.5" } }
          }
        },
    
  7. BrianJM commented on May 19, 2026

    @BrianJM

    Is there any workaround for this? I can no longer use my Kimi coding plan.

    Try add this to opencode config

    "kimi-for-coding": {
          "models": {
            "k2p6":             { "headers": { "User-Agent": "KimiCLI/1.5" } },
            "k2p5":             { "headers": { "User-Agent": "KimiCLI/1.5" } },
            "kimi-k2-thinking": { "headers": { "User-Agent": "KimiCLI/1.5" } }
          }
        },
    

    This did not work for me due to the open defects: #27902 (comment).

  8. CrazyTomatoOo commented on May 19, 2026

    @CrazyTomatoOo

    Use plugin opencode-kimi-full can workaround this, even better than native.

  9. CrazyTomatoOo commented on May 21, 2026

    @CrazyTomatoOo

    When will this issue be fixed? It's been almost a week already.

  10. github-actions commented on Jul 21, 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