KIE.AI
All Model
  • All Model
  • Old Model
language
language
  • 🇺🇸 English
  • 🇨🇳 Chinese
language
language
  • 🇺🇸 English
  • 🇨🇳 Chinese
Support
All Model
  • All Model
  • Old Model
All Model
  • All Model
  • Old Model
MarketFile Upload APICommon APIAI Agents
MarketFile Upload APICommon APIAI Agents
  1. Run coding agents on KIE
  • Overview
  • Build with KIE models
    • Install kie-models
    • What your agent can do
  • Run coding agents on KIE
    • Install kie-chat-agents
    • Claude Code
    • Codex CLI
    • Grok Build
  • Help
    • Troubleshooting
    • Changelog
  1. Run coding agents on KIE

Install kie-chat-agents

KIE (api.kie.ai) serves its chat models over each vendor's own wire protocol. When the agent speaks the same protocol as the model, no adapter is needed. When they differ, a local translation proxy has to sit in between; see When protocols don't match below.

One section per agent, each self-contained: how to list the models that agent can run, what configuration it needs, and how it fails. Codex CLI, Claude Code and Grok Build are covered so far; other agents will be added later as sibling sections. The protocol-mismatch section is shared, so a new agent does not need its own pairing table.

WARNING

⚠️ Use the latest models for agent features

For agent features, use the latest model in each series. Some older models currently support chat requests only; connecting them to an agent may cause request errors or unexpected results. These models are marked "Chat only" on their model pages in the Market. The models each agent can use are listed in that agent's model listing.

Install

npx skills add https://kie.ai

Once installed, you can simply ask your agent, for example "Configure Codex to use KIE", and the skill follows the steps on that agent's page. You can also configure the agent by hand with the pages below.

Prerequisites

A KIE API key created at https://kie.ai/api-key, exported as KIE_API_KEY, and the agent you want to configure already installed.

The model-listing snippets need curl and jq on your PATH. Most systems do not ship jq: brew install jq, apt install jq or winget install jqlang.jq.

In PowerShell, curl is an alias for Invoke-WebRequest and does not accept these arguments. Write curl.exe as in the Windows snippets below. Under cmd.exe the snippets must be rewritten; they cannot be pasted as is.

The three agents at a glance

Summarized from the agent pages; see each page for details.

AgentProtocolList modelsWhere the config goesBase URLCredential
Claude CodeAnthropic MessagesGET https://api.kie.ai/anthropic/v1/modelsEnvironment variables, or env in ~/.claude/settings.jsonANTHROPIC_BASE_URL=https://api.kie.ai/anthropicRaw key in ANTHROPIC_AUTH_TOKEN
Codex CLIOpenAI ResponsesGET https://api.kie.ai/openai/v1/models[model_providers.kie] in ~/.codex/config.tomlhttps://api.kie.ai/openai/v1env_key = "KIE_API_KEY"
Grok BuildResponses (api_backend = "responses")GET https://api.kie.ai/xai/v1/models[model.kie] in ~/.grok/config.tomlhttps://api.kie.ai/xai/v1env_key = "KIE_API_KEY"

Rules shared by all three agents:

  1. Take model names from the listing, not from memory. Re-run the listing every time; the model set changes.
  2. Authenticate with Authorization: Bearer. A header literally named apikey is rejected with 401.
  3. Do not put the full request URL in the base URL. The agent appends /v1/messages or /responses itself.
  4. Put the configuration in user-level files, not project-level ones. Project-level files are either ignored or committed to the repository.

When protocols don't match

Every agent here speaks one wire protocol, and every KIE listing is served over one protocol. When the two match, configure the agent as its page says and traffic goes straight to api.kie.ai. When they don't, you need a local translation proxy.

When you need a proxy

  1. Read the agent's page: which protocol it speaks and which path it appends.
  2. Read the model's listing: which protocol KIE serves it over.
  3. Same protocol: no proxy. Different protocol: tell the user a local translation proxy is needed, and ask before writing one. The user may already have a proxy, or may not want one this time. Do not generate proxy code without asking.
  4. Once the user has a proxy, or has explicitly asked for one, point the agent's base URL at the proxy, not at api.kie.ai.
  5. List models from the model side's listing, not the agent's native listing. Fill the agent's model setting with an id from that list. Its built-in default names and aliases only hold for its native protocol.

What the proxy exposes

Model listingKIE requestProtocol
GET /openai/v1/modelsPOST /openai/v1/responsesResponses
GET /anthropic/v1/modelsPOST /anthropic/v1/messagesMessages
GET /xai/v1/modelsPOST /xai/v1/responsesResponses

The proxy listens on the path the agent will build and forwards to the KIE request for that listing. Both directions must be translated, including the streaming and tool calls the agent actually sends. Authentication to KIE is Authorization: Bearer $KIE_API_KEY.

When a future agent's listing is not in this table, add a row. The rules in this section do not change.

When writing a proxy

Only write one when the user explicitly asks. Map honestly; do not invent platform behavior.

  1. Learn both protocol shapes from real agent requests and the official protocols, not from memory. Capture what the agent actually sends (claude --debug, Codex logs, GROK_LOG_FILE) and the shape KIE expects on the model path. Field tables pieced together from training data are usually incomplete.
  2. Forward the model id unchanged. Do not hard-code a default model name, and do not rewrite sonnet / opus / claude-* into GPT slugs, or the other way round.
  3. If the proxy serves GET /models, return the list in the shape the agent expects, with data from the model side's KIE listing. Passing the other side's document through as is has the wrong shape. A failed listing is an error; do not invent a fake model.
  4. Tool calls must complete a round. id / call_id / tool_use_id stay consistent between the request and the tool result in the next turn. Do not drop tools. If KIE rejects tools, pass that error back.
  5. Streaming must end the way the agent ends a turn. Emit the event sequence the agent consumes, including the terminal event. If KIE errors or the stream drops mid-way, the agent must see a failure, not an HTTP 200 with an empty completed turn.
  6. Do not inject new user/assistant content to work around protocol limits. Some Messages models reject a conversation that ends with an assistant turn. Inventing a follow-up user message makes the request valid but changes the meaning of the turn, and Codex will then keep continuing. Either reshape losslessly or return the upstream error as is.

Pointing the agent at the proxy

The listen address is whatever the proxy binds. The agent's base URL still follows the rules on its page: Claude Code appends /v1/messages to ANTHROPIC_BASE_URL, Codex appends /responses to base_url, and Grok Build appends /responses to base_url when api_backend = "responses". So leave that suffix out of the value.

Claude Code running a Responses model:

export ANTHROPIC_BASE_URL=http://127.0.0.1:<port>
export ANTHROPIC_AUTH_TOKEN=$KIE_API_KEY
export ANTHROPIC_MODEL=…

ANTHROPIC_MODEL is an id from GET /openai/v1/models, not Claude Code's sonnet / opus aliases.

Codex CLI running a Messages model:

model = "…"
model_provider = "kie"

[model_providers.kie]
name = "KIE"
base_url = "http://127.0.0.1:<port>/v1"
env_key = "KIE_API_KEY"
wire_api = "responses"

model is an id from GET /anthropic/v1/models. base_url still does not include /responses.

Do not leave the agent's base URL pointing at api.kie.ai while sending an id from another listing, and do not point the agent straight at the model side's KIE prefix without translation.

What this skill does not provide

This skill does not include, generate or name any translation proxy. It only states the listen path, the KIE path, which listing to read, and which agent setting takes the proxy address. Proxy code is written only when the user explicitly asks.

Previous
What your agent can do
Next
Claude Code
Built with