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

Grok Build

TIP
Let the skill configure it
With the KIE skills installed, you can simply ask your agent "Configure Grok Build to use KIE" and it follows the steps on this page. You can also configure it by hand as described below.

Key rules#

1.
Discover models with GET https://api.kie.ai/xai/v1/models, not from memory or training data. This endpoint gives the list Grok Build can run on this prefix. The general taskType=Chat catalog is a different, wider list that includes models this endpoint does not serve.
2.
Authenticate with Authorization: Bearer. Every KIE endpoint, including the model listing, carries the API key in this one header. A header literally named apikey is rejected with 401.
3.
Set api_backend = "responses". Grok Build's default backend is chat_completions, which sends to /v1/chat/completions. KIE serves these models on /xai/v1/responses.
4.
Fill the model field with an id from the listing. That is the name sent to KIE. It is neither the table name [model.<name>] nor Grok Build's own spelling (for example grok-4.6). The listing uses a different set of ids (for example grok-4-6). Copy the id from the list; with the built-in name KIE rejects the request even if base_url is right.
5.
Put the table in user-level config. A project-level .grok/config.toml only contributes MCP, plugin and permission keys. A [model.*] table there is not inference configuration.

List available models#

On Windows (PowerShell), send the same request with curl.exe:
curl.exe -s -H "Authorization: Bearer $env:KIE_API_KEY" `
  https://api.kie.ai/xai/v1/models | jq -r '.data[].id'
The response has the OpenAI-compatible shape. .data[] is the list: id is the value for model. object, owned_by, created and aliases are boilerplate.
List the ids for the user to choose from. Re-run the listing every time instead of reusing an earlier answer; the model set changes.

Configure#

Grok Build configures custom models with [model.<name>] tables. <name> is the key in the model picker, and model is the id sent to KIE:
[models]
default = "kie"

[model.kie]
model = "grok-4-6"
base_url = "https://api.kie.ai/xai/v1"
name = "KIE"
api_backend = "responses"
env_key = "KIE_API_KEY"
base_url is the root that requests are sent to. With api_backend = "responses", Grok Build appends /responses itself, so the value is https://api.kie.ai/xai/v1, not the full request URL https://api.kie.ai/xai/v1/responses.
env_key names the environment variable Grok Build reads the credential from and sends as a bearer token. It does not hold the key itself. Prefer it over writing the key into api_key.
You choose the picker key (kie here). [models] default must be that key (or another [model.*] key), not a name from Grok's built-in catalog; otherwise new sessions still go to xAI instead of KIE.

macOS and Linux#

The file is ~/.grok/config.toml. Export the credential in the same shell that starts grok, or add it to your shell profile:
Set GROK_HOME to keep the configuration somewhere other than ~/.grok.

Windows (PowerShell)#

The file is %USERPROFILE%\.grok\config.toml, with identical content.
$env:KIE_API_KEY = "…"
setx KIE_API_KEY "…"

Verify the setup#

grok models should list the custom key. grok inspect reports which config file is in effect. Start grok in a shell where KIE_API_KEY is set and send a message, or run grok -p "…" -m kie.
RUST_LOG=debug GROK_LOG_FILE=/tmp/grok.log grok writes a request trace. Check the base_url and the model id.

Common pitfalls#

1.
A header named apikey. KIE returns 401. Put the key in Authorization: Bearer.
2.
The full request URL in base_url. With api_backend = "responses", Grok Build appends /responses itself, so a base_url ending in /responses becomes /responses/responses.
3.
No api_backend. The default is chat_completions, which sends to /v1/chat/completions, not /xai/v1/responses.
4.
Grok's own model name in model. KIE reads the model field of [model.<name>], which must be an id from the listing. A built-in spelling such as grok-4.6 is not that id.
5.
[model.*] in the project-level .grok/config.toml. That file does not carry inference configuration. Use ~/.grok/config.toml.
6.
The key itself in env_key. It takes the name of an environment variable. The key lives in that variable, not in the config file.
7.
setx does not affect the current window. It applies to windows opened afterwards. Set $env: as well to use it right away.
8.
PowerShell curl. It is an alias for Invoke-WebRequest and does not accept these arguments. Use curl.exe.
To use a model from a listing that isn't on this protocol, see When protocols don't match on the Install kie-chat-agents page.
Previous
Codex CLI
Next
Troubleshooting
Built with