Skip to content

[Bug] kimi-coding provider fails authentication due to incorrect User-Agent header #30099

@Amineelfarssi

Description

@Amineelfarssi

Bug Report: kimi-coding provider fails authentication due to incorrect User-Agent header

Description

The kimi-coding provider is documented and configurable in OpenClaw, but API requests fail authentication for subscription users. The Kimi Code API requires User-Agent: claude-code/0.1.0 header for subscription authentication, but OpenClaw sends User-Agent: OpenClaw-Gateway/1.0 (or similar generic agent string).

Expected Behavior

Configuring provider kimi-coding with a valid Kimi Code Plan subscription API key should authenticate successfully and allow model usage.

Actual Behavior

API requests are rejected or treated as unauthorized. The model either:

  • Falls back to the default model silently
  • Fails with authentication errors
  • Behaves as if using pay-per-use instead of subscription

Steps to Reproduce

  1. Subscribe to Kimi Code Plan ($20/month) at https://www.kimi.com/code/en
  2. Get API key from https://www.kimi.com/code/en (different from Moonshot API key)
  3. Configure OpenClaw:
{
  models: {
    providers: {
      "kimi-coding": {
        baseUrl: "https://api.kimi.com/coding/v1",
        apiKey: "${KIMI_API_KEY}",
        api: "openai-completions",
        models: [{
          id: "k2p5",
          name: "Kimi K2.5 (Code)",
          contextWindow: 256000
        }]
      }
    }
  }
}
  1. Try to use the model: /model kimi-coding/k2p5
  2. Send a message

Result: Request fails or falls back to different model.

Root Cause Analysis

Kimi Code API validates the User-Agent header for subscription authentication. It specifically requires:

User-Agent: claude-code/0.1.0

OpenClaw currently sends its own User-Agent (e.g., OpenClaw-Gateway/1.0), which the Kimi Code API does not recognize as a valid subscription client.

Workaround (Current)

Users must run a local proxy to inject the correct header:

# Proxy on localhost:8787 adds User-Agent: claude-code/0.1.0
# OpenClaw configured to use http://localhost:8787/v1

This adds unnecessary complexity and latency.

Proposed Fix

Option A (Minimal): Hardcode User-Agent: claude-code/0.1.0 for the kimi-coding provider specifically.

Option B (Flexible): Allow custom headers in provider config:

"kimi-coding": {
  baseUrl: "https://api.kimi.com/coding/v1",
  apiKey: "${KIMI_API_KEY}",
  headers: {
    "User-Agent": "claude-code/0.1.0"
  }
}

Related Issues

This may explain reports of /model kimi-coding/k2p5 "silently failing" — the auth is rejected but OpenClaw falls back to default model without clear error messaging.

Environment

  • OpenClaw version: 2026.2.19-2 (and likely others)
  • Provider: kimi-coding
  • Authentication: Kimi Code Plan subscription (not Moonshot pay-per-use)

Additional Context

  • Kimi Code API endpoint: https://api.kimi.com/coding/v1
  • Kimi Code and Moonshot are separate services with different API keys
  • Documentation for kimi-coding provider exists but doesn't mention this requirement

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions