openclaw - ✅(Solved) Fix [Feature]: Support image analysis for Kimi Code Plan [1 pull requests, 2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
openclaw/openclaw#75959Fetched 2026-05-03 04:43:51
View on GitHub
Comments
2
Participants
3
Timeline
5
Reactions
3
Author
Timeline (top)
commented ×2cross-referenced ×1labeled ×1unsubscribed ×1

Currently, OpenClaw's kimi provider cannot send images to Kimi Code Plan API (api.kimi.com/coding/v1). When a user attaches an image in the conversation, the request will fail.

Error Message

{"error":{"message":"Kimi For Coding is currently only available for Coding Agents such as Kimi CLI, Claude Code, Roo Code, Kilo Code, etc.","type":"access_terminated_error"}}

  • Analyzing error screenshots

Root Cause

The request fails with: HTTP 403 Forbidden {"error":{"message":"Kimi For Coding is currently only available for Coding Agents such as Kimi CLI, Claude Code, Roo Code, Kilo Code, etc.","type":"access_terminated_error"}} This happens because:

  1. OpenClaw uses User-Agent openclaw/* which is not in Kimi's whitelist
  2. The current endpoint configuration may not be optimal for image requests

Fix Action

Fixed

PR fix notes

PR #76002: fix(kimi): switch to openai-completions endpoint for image support

Description (problem / solution / changelog)

Summary

  • Problem: The bundled kimi provider sent requests via Anthropic Messages format (/messages path), which Kimi's backend rejects with 403 Forbidden when the body contains image content.
  • Why it matters: Users with a Kimi Code Plan API key could not attach images (screenshots, diagrams, documents) — 100% reproducible failure on every image request.
  • What changed: Switched api from anthropic-messagesopenai-completions and baseUrl from https://api.kimi.com/coding/https://api.kimi.com/coding/v1 in the bundled kimi plugin so image payloads go through the OpenAI-compatible /chat/completions endpoint that Kimi's backend accepts.
  • What did NOT change: User-Agent (claude-code/0.1.0) was already correct. Core, SDK, other providers, and the stream/tool-call/thinking wrapper logic are untouched.

Change Type (select all)

  • Bug fix
  • Feature
  • Refactor required for the fix
  • Docs
  • Security hardening
  • Chore/infra

Scope (select all touched areas)

  • Gateway / orchestration
  • Skills / tool execution
  • Auth / tokens
  • Memory / storage
  • Integrations
  • API / contracts
  • UI / DX
  • CI/CD / infra

Linked Issue/PR

  • Closes #75959
  • This PR fixes a bug or regression ✅

Root Cause (if applicable)

  • Root cause: The Kimi Coding provider was configured with api: "anthropic-messages", routing image requests through the Anthropic Messages transport which serializes images in Anthropic format. Kimi's /coding/v1/chat/completions endpoint expects OpenAI image_url format and rejects Anthropic-format bodies.
  • Missing detection / guardrail: No integration smoke test exercised an image round-trip through the kimi provider; unit tests only covered text and tool-call paths.
  • Contributing context: The kimi-code model catalog already declared input: ["text", "image"], creating a false expectation that image input was supported end-to-end.

Regression Test Plan (if applicable)

  • Coverage level that should have caught this:
    • Unit test
    • Seam / integration test
    • End-to-end test
    • Existing coverage already sufficient
  • Target test or file: extensions/kimi-coding/implicit-provider.test.ts
  • Scenario the test should lock in: Provider catalog returns api: "openai-completions" and baseUrl: "https://api.kimi.com/coding/v1" — wrong transport selection would have made this assertion fail.
  • Why this is the smallest reliable guardrail: The catalog shape directly determines which transport and endpoint the image payload is routed to; catching a wrong api value here is sufficient without a live API call.
  • Existing test that already covers this (if any): provider-catalog.test.ts and implicit-provider.test.ts — both updated to assert the new values.
  • If no new test is added, why not: Existing tests were updated to cover the corrected values; no new fixture needed.

User-visible / Behavior Changes

  • Image attachments now work with kimi/kimi-code (and the legacy kimi/k2p5 ref).
  • Requests now go to https://api.kimi.com/coding/v1/chat/completions (OpenAI format) instead of the Anthropic Messages path. Existing text and tool-call sessions are unaffected.
  • Users who override baseUrl or api explicitly in config keep their overrides (catalog merge logic is unchanged).

Diagram (if applicable)

Before:
[image attached] -> anthropic-messages transport -> /coding/ (Anthropic format) -> 403 Forbidden

After:
[image attached] -> openai-completions transport -> /coding/v1/chat/completions (OpenAI image_url) -> 200 OK

Security Impact (required)

- New permissions/capabilities? No
- Secrets/tokens handling changed? No
- New/changed network calls? Yes — endpoint path changed from /coding/ to /coding/v1/chat/completions; same host, same API key, no new credential surface.
- Command/tool execution surface changed? No
- Data access scope changed? No
- If any Yes, explain risk + mitigation: The endpoint change is to the same api.kimi.com host under the same API key. The new path is the officially documented Kimi Code Plan endpoint per
their API spec and confirmed working by the issue reporter.

Repro + Verification

Environment

- OS: Ubuntu 22.04 (reported by issue author); Linux 6.19 (dev)
- Runtime/container: Node 22+
- Model/provider: kimi/kimi-code with KIMI_API_KEY=sk-kimi-*
- Integration/channel: N/A
- Relevant config: default (no explicit provider overrides)

Steps

1. Configure OpenClaw with a Kimi Code Plan API key via openclaw onboard --auth-choice kimi-code-api-key
2. Start a session with kimi/kimi-code as the active model
3. Attach a JPEG image and send a message ("Describe this image")

Expected

- 200 OK; model returns a description of the image

Actual (before fix)

- 403 Forbidden — {"error":{"message":"Kimi For Coding is currently only available for Coding Agents...","type":"access_terminated_error"}}

Evidence

- Failing test/log before + passing after — implicit-provider.test.ts, provider-catalog.test.ts, onboard.test.ts all previously asserted anthropic-messages / old URL; updated assertions
pass with new values
- Trace/log snippets — working curl provided by issue reporter in #75959

Human Verification (required)

- Verified scenarios: All 20 unit tests in extensions/kimi-coding/ pass (pnpm test extensions/kimi-coding)
- Edge cases checked: Explicit baseUrl and headers overrides in user config still take precedence (covered by existing implicit-provider.test.ts tests); User-Agent custom override merges
correctly
- What you did NOT verify: Live image round-trip against the real Kimi API (requires a paid sk-kimi-* key); tool-call streaming over the new /chat/completions endpoint in a live session

Review Conversations

- I replied to or resolved every bot review conversation I addressed in this PR.
- I left unresolved only the conversations that still need reviewer or maintainer judgment.

Compatibility / Migration

- Backward compatible? Yes — API key, model refs, and user-visible config keys are unchanged
- Config/env changes? No
- Migration needed? No
- If yes, exact upgrade steps: N/A

Risks and Mitigations

- Risk: Kimi's /chat/completions streaming format for tool calls differs from the Anthropic format (markers like <|tool_call_begin|> may behave differently).
  - Mitigation: The wrapKimiProviderStream wrapper operates on the normalized pi-ai stream layer, not the raw transport; all 20 existing stream tests pass unchanged. Live tool-call
verification in a full session is recommended before merging.

## Changed files

- `CHANGELOG.md` (modified, +4/-0)
- `docs/providers/moonshot.md` (modified, +3/-3)
- `extensions/kimi-coding/implicit-provider.test.ts` (modified, +2/-2)
- `extensions/kimi-coding/onboard.test.ts` (modified, +2/-2)
- `extensions/kimi-coding/onboard.ts` (modified, +1/-1)
- `extensions/kimi-coding/openclaw.plugin.json` (modified, +6/-0)
- `extensions/kimi-coding/provider-catalog.test.ts` (modified, +2/-2)
- `extensions/kimi-coding/provider-catalog.ts` (modified, +2/-2)
- `extensions/kimi-coding/stream.test.ts` (modified, +10/-10)
RAW_BUFFERClick to expand / collapse

Summary

Currently, OpenClaw's kimi provider cannot send images to Kimi Code Plan API (api.kimi.com/coding/v1). When a user attaches an image in the conversation, the request will fail.

Problem to solve

The request fails with: HTTP 403 Forbidden {"error":{"message":"Kimi For Coding is currently only available for Coding Agents such as Kimi CLI, Claude Code, Roo Code, Kilo Code, etc.","type":"access_terminated_error"}} This happens because:

  1. OpenClaw uses User-Agent openclaw/* which is not in Kimi's whitelist
  2. The current endpoint configuration may not be optimal for image requests

Proposed solution

Update the kimi provider to use Kimi-approved User-Agent and endpoint: Current behavior (broken for images):

  • Endpoint: /messages (or inferred from api: "openai-completions")
  • User-Agent: openclaw/2026.4.27
  • Result: 403 Forbidden when sending images Proposed changes:
  1. Use /chat/completions endpoint for OpenAI-format requests
    • Kimi Code Plan supports OpenAI Chat Completions format at /chat/completions
    • Keeps existing openai-completions API format unchanged
    • No need to switch to Anthropic Messages format
  2. Set User-Agent to a Kimi-whitelisted value
    • Kimi strictly validates User-Agent against an allowlist
    • Tested working values:
      • claude-code/0.1.0
      • claude-code/1.0.0
      • Kilo-Code/1.0
    • Tested failing values:
      • openclaw/*
      • kimi-cli/1.0 ❌ (surprisingly!)
      • Roo-Code/1.0
    • Recommended: claude-code/0.1.0 (most compatible, tested extensively)
  3. Keep standard OpenAI image format
    {
      "type": "image_url",
      "image_url": {
        "url": "data:image/jpeg;base64,..."
      }
    }

Alternatives considered

AlternativeProsCons
Switch to Anthropic Messages APINative for /messages endpointRequires rewriting image format conversion; more invasive code changes
Use kimi-cli User-AgentOfficial Kimi brandingNot in Kimi's whitelist (tested and rejected with 403)
Make User-Agent configurable per-providerFlexible for usersKimi's whitelist is very restrictive; most custom values fail
Add proxy/relay serverCompletely bypasses UA checkAdds infrastructure complexity and maintenance burden
Request Kimi to add openclaw to whitelistCleanest solution long-termOut of OpenClaw's control; may take long time or be rejected

Impact

Affected users/systems/channels:

  • All OpenClaw users who have configured the kimi provider with a Kimi Code Plan API key (sk-kimi-*)
  • Users who attach images (screenshots, diagrams, photos) in OpenClaw conversations expecting the AI to analyze them
  • Specifically impacts the kimi-code model in the kimi provider configuration

Severity:

  • Blocks workflow for image-related tasks. Users cannot use Kimi Code Plan for any vision-based tasks within OpenClaw, including:
    • Analyzing error screenshots
    • Reviewing UI/UX designs
    • Reading diagrams or charts
    • Processing photographed documents

Frequency:

  • Always — Every time a user attaches an image while using the kimi-code model, the request fails with 403 Forbidden. This is 100% reproducible.

Consequence:

  • Users must switch to other providers (e.g., OpenAI, Anthropic) for image analysis, defeating the purpose of having Kimi Code Plan configured
  • Forces users to maintain multiple API keys and providers just to handle images
  • Creates confusion because the kimi-code model is advertised as supporting ["text", "image"] input, but images silently fail
  • Extra manual work: users must download images and upload them to Kimi's web interface or other tools instead of using OpenClaw's integrated chat

Evidence/examples

This fails (current OpenClaw behavior) curl https://api.kimi.com/coding/v1/chat/completions
-H "Authorization: Bearer $KIMI_API_KEY"
-H "Content-Type: application/json"
-H "User-Agent: openclaw/2026.4.27"
-d '{ "model": "kimi-code", "messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}}, {"type": "text", "text": "Describe this"}]}] }' → 403 Forbidden This works (proposed fix) curl https://api.kimi.com/coding/v1/chat/completions
-H "Authorization: Bearer $KIMI_API_KEY"
-H "Content-Type: application/json"
-H "User-Agent: claude-code/0.1.0"
-d '{ "model": "kimi-code", "messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}}, {"type": "text", "text": "Describe this"}]}] }' → 200 OK with image description

Additional information

Additional Context

  • API Base URL: https://api.kimi.com/coding/v1
  • Required Headers: Authorization, Content-Type, User-Agent: claude-code/0.1.0
  • No anthropic-version header needed when using /chat/completions
  • Image format: Standard OpenAI image_url with base64 data URL
  • Tested image size: ~1MB JPEG works correctly
  • Model ID: kimi-code

Environment

  • OpenClaw version: 2026.4.27
  • OS: Ubuntu 22.04
  • Kimi Code Plan API key format: sk-kimi-*

extent analysis

TL;DR

Update the kimi provider to use the /chat/completions endpoint and set the User-Agent to a Kimi-whitelisted value, such as claude-code/0.1.0, to fix the image sending issue.

Guidance

  • Change the endpoint from /messages to /chat/completions for OpenAI-format requests to ensure compatibility with Kimi Code Plan API.
  • Update the User-Agent header to a whitelisted value, such as claude-code/0.1.0, to bypass the 403 Forbidden error.
  • Verify that the image format is in the standard OpenAI image_url format with base64 data URL.
  • Test the changes with a sample image to ensure the fix works as expected.

Example

{
  "model": "kimi-code",
  "messages": [{"role": "user", "content": [{"type": "image_url", "image_url": {"url": "data:image/jpeg;base64,..."}}, {"type": "text", "text": "Describe this"}]}]
}

Notes

The proposed fix assumes that the Kimi Code Plan API key is valid and properly configured. Additionally, the fix may not work if Kimi's whitelist changes or if there are other issues with the API request.

Recommendation

Apply the workaround by updating the kimi provider to use the /chat/completions endpoint and setting the User-Agent to claude-code/0.1.0, as this is the most compatible and extensively tested solution.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING