Use KIE from your coding agent
KIE provides two agent skills. A skill is a small set of instructions your coding agent loads on its own. With a skill loaded, you can ask for a result in plain words and the agent handles the API calls, without you pasting docs into the chat.One install command adds both skills. Your agent picks the right one from your request.Set your key first: export KIE_API_KEY=your_key. Create one at kie.ai/api-key.
⚠️ Use the latest models for agent featuresFor 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.
The two skills#
kie-models: build with KIE models#
Lets your agent use 200+ image, video, music and speech models on KIE. The agent picks a model, reads its parameters, uploads input files and polls until the result is ready.For: adding generation to your own app, or producing image, video and audio files directly.
Types: Image · Video · Music · Speech
Start with: Install kie-models → What your agent can do
kie-chat-agents: run coding agents on KIE#
Run Codex CLI, Claude Code or Grok Build on KIE chat models with your KIE credits. Covers the base URL, key and model name for each agent.For: running your coding agent on KIE's models and billing.
Covered so far: Codex CLI · Claude Code · Grok Build
Start with: Install kie-chat-agents → the page for your agent
Which skill do I need?#
| You want to | Skill | Example request |
|---|
| Generate images, video, music or speech in your app | kie-models | "Add a Veo 3.1 video endpoint to my API" |
| Generate a file directly | kie-models | "Make a 1:1 product photo of a white ceramic mug with GPT Image 2 and save it to ./public" |
| Run Claude Code, Codex or Grok Build on KIE credits | kie-chat-agents | "Configure Codex to use KIE" |
| See which models an agent can use | kie-chat-agents | "List the models Claude Code can use on KIE" |
Quick start#
1.
Install the skills (once per machine, requires Node.js): 3.
Export it as KIE_API_KEY. Both skills read the key from this variable, so it never needs to go into your project files.$env:KIE_API_KEY = "your_key"
setx KIE_API_KEY "your_key"
setx only applies to windows opened afterwards. Set $env: as well to use it right away. 4.
Start your agent from a shell where the variable is set, then pick a path:Generate images, video, music or speech → Install kie-models
Run your coding agent on KIE → Install kie-chat-agents
What happens when you ask (kie-models)#
| Step | What the agent does |
|---|
| FIND | Searches the live model list |
| READ | Loads that model's parameters |
| UPLOAD | Hosts your input files if needed |
| RUN | Submits the task and waits |
| SAVE | Downloads the result |
For example, if you say "Make a 1:1 product photo of a white ceramic mug with GPT Image 2 and save it to ./public", the agent searches the models, reads the parameters of gpt-image-2-text-to-image, submits the task, waits for it to finish and saves the image to ./public.Generated files are kept for 14 days. The agent downloads them for you, so nothing is lost when the link expires.
How coding agents connect to KIE (kie-chat-agents)#
KIE serves its chat models over each vendor's own wire protocol. When the agent speaks the same protocol as the model, point the agent at api.kie.ai and no adapter is needed.| Agent | Protocol | List available models |
|---|
| Claude Code | Anthropic Messages | GET https://api.kie.ai/anthropic/v1/models |
| Codex CLI | OpenAI Responses | GET https://api.kie.ai/openai/v1/models |
| Grok Build | Responses | GET https://api.kie.ai/xai/v1/models |
When the protocols differ (for example, running a Responses model from Claude Code), you need a local translation proxy. See When protocols don't match on the Install kie-chat-agents page.
Good to know#
Model names come from the live list. Both skills make the agent read the model list from KIE every time instead of writing names from memory, so new models work right away.
Authentication is always Authorization: Bearer. Every KIE endpoint carries the API key in this one header. A header named apikey is rejected with 401.
Usage is billed in KIE credits, the same as calling the API yourself. Every call shows up on kie.ai/logs. Keep your key safe. Keep it in an environment variable, never in chat, screenshots or files committed to a repository. If it leaks, reset it at kie.ai/api-key.
Pages in this section#
| Page | What's inside |
|---|
| Install kie-models | Install the skills, set your API key and run your first generation task |
| What your agent can do | Supported model types, the steps the agent handles, how to phrase a request |
| Install kie-chat-agents | Install, prerequisites, the three agents at a glance, what to do when protocols don't match |
| Claude Code | Listing models, environment and settings configuration, verifying, common pitfalls |
| Codex CLI | Listing models, config.toml provider setup, reasoning effort, common pitfalls |
| Grok Build | Listing models, [model.*] setup, verifying, common pitfalls |
| Troubleshooting | Fixes for 401, doubled paths, model not found, variables not picked up and more |
| Changelog | Release notes |