> ## Documentation Index
> Fetch the complete documentation index at: https://gomodel.enterpilot.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# GoModel & Kimi Code CLI

> Route Kimi Code CLI through GoModel without an api.json registry URL, configure a model profile, and verify prompts and tool calls.

Kimi Code CLI can use GoModel as an OpenAI-compatible provider. You configure
the GoModel base URL, a dedicated managed API key, and at least one model in
Kimi's `~/.kimi/config.toml` file.

Flow:

`Kimi Code CLI -> GoModel -> upstream model provider`

## You do not need an `api.json` URL

Kimi's **Custom registry (`api.json`)** option imports a models.dev-shaped
provider catalog. It is optional and is not the normal OpenAI-compatible setup
path.

GoModel exposes its model catalog at `/v1/models`, but that response uses the
OpenAI model-list format rather than Kimi's custom-registry format. Do not paste
`http://localhost:8080/v1/models` into Kimi's `api.json` prompt. Exit that
prompt and use the direct configuration below instead.

<Note>
  If you searched for `pi.json`, the file name shown by Kimi is `api.json`.
  Neither file is required for this setup.
</Note>

## Before you start

* Install [Kimi Code CLI](https://moonshotai.github.io/kimi-cli/en/guides/getting-started.html).
* Choose a GoModel master key for gateway administration, for example
  `change-me`.
* Make sure GoModel has an upstream credential for the model you want to use.

## 1. Run GoModel

Start GoModel with a master key and at least one upstream provider. This
example uses OpenAI:

```bash theme={null}
docker run --rm -p 8080:8080 \
  -e GOMODEL_MASTER_KEY="change-me" \
  -e OPENAI_API_KEY="sk-..." \
  enterpilot/gomodel
```

`GOMODEL_MASTER_KEY` is the gateway's bootstrap and administrator credential.
Do not put it in Kimi's persistent configuration. `OPENAI_API_KEY` belongs to
GoModel and is used only for the upstream request.

## 2. Create a dedicated Kimi API key

Open the GoModel dashboard at
[http://localhost:8080/admin/dashboard](http://localhost:8080/admin/dashboard)
and sign in with `GOMODEL_MASTER_KEY`. Go to
`API Keys -> Create API Key`, then:

1. Name the key `kimi-code`.
2. Set **User Path** to `/agents/kimi`.
3. Leave **Dashboard access** disabled.
4. Create the key and copy the `sk_gom_...` value. It is shown only once.

The bound user path gives Kimi its own usage and audit scope. Managed keys bind
directly to a user path, while model restrictions are configured separately as
gateway-wide [model access policies](/docs/features/user-path#model-access). If you
use those policies, allow only the selectors Kimi needs for `/agents/kimi`.

<Warning>
  Use this managed key in Kimi, not `GOMODEL_MASTER_KEY`. A managed key without
  dashboard access can call model endpoints but cannot read audit logs, create
  keys, or change gateway settings. The master key bypasses that restriction.
</Warning>

## 3. Choose a model

List the models visible through GoModel:

```bash theme={null}
curl -s http://localhost:8080/v1/models \
  -H "Authorization: Bearer sk_gom_..." \
  | jq '.data[] | {
      id,
      context_window: .metadata.context_window,
      max_output_tokens: .metadata.max_output_tokens
    }'
```

This guide uses `openai/gpt-5-mini`, with a 400,000-token context window and a
128,000-token output limit. Prefer a provider-qualified ID from this
response so GoModel routes the request to the intended provider.

## 4. Configure Kimi Code CLI

Open `~/.kimi/config.toml` and add:

```toml theme={null}
default_model = "gomodel/gpt-5-mini"
default_thinking = true

[providers.gomodel]
type = "openai_legacy"
base_url = "http://localhost:8080/v1"
api_key = "sk_gom_..."

[models."gomodel/gpt-5-mini"]
provider = "gomodel"
model = "openai/gpt-5-mini"
max_context_size = 400000
capabilities = ["thinking", "image_in"]
```

The alias `gomodel/gpt-5-mini` is local to Kimi. The `model` value is the
exact selector Kimi sends to GoModel.

<Warning>
  Kimi does not automatically read ordinary provider credentials such as
  `OPENAI_API_KEY` from your shell for persistent providers. In this file,
  `api_key` must contain the dedicated GoModel managed key, not the master key
  or an upstream provider key. Restrict access with
  `chmod 600 ~/.kimi/config.toml`.
</Warning>

Use the `context_window` value returned by GoModel as `max_context_size` when
you configure a different model. The `thinking` capability and
`default_thinking = true` match the reasoning model used here. Adjust Kimi's
capabilities to match another model.

If GoModel runs on another host, replace `localhost:8080`. Keep `/v1` in the
base URL; do not append `/chat/completions`.

## 5. Validate the setup

Check the installed Kimi version:

```bash theme={null}
kimi --version
```

Then run a small prompt:

```bash theme={null}
kimi --quiet -p 'Reply with exactly ok and no punctuation.'
```

The expected model response is:

```text theme={null}
ok
```

You can also verify tool calling:

```bash theme={null}
kimi --quiet -p 'Use the Shell tool to run pwd. After it succeeds, reply with exactly tool-ok and no punctuation.'
```

The final model response should be:

```text theme={null}
tool-ok
```

## 6. Check the traffic in GoModel

Open the GoModel dashboard audit logs:

[http://localhost:8080/admin/dashboard/audit](http://localhost:8080/admin/dashboard/audit)

Use the audit trail to confirm that Kimi is sending streaming requests to
`POST /v1/chat/completions` and that GoModel is routing them to the selected
provider. Sign in with the master key or a separate managed key that has
dashboard access; the Kimi key intentionally cannot open this page.

## Troubleshooting

### Kimi asks for an `api.json` URL

You selected Kimi's custom-registry import flow. Cancel it and edit
`~/.kimi/config.toml` as shown above. GoModel does not need a registry
endpoint for Kimi to work.

### `401 Unauthorized`

Make sure Kimi's `api_key` matches the active `sk_gom_...` managed key created
for Kimi. Do not put the master key or upstream provider key in Kimi's config.

### `reasoning_effort` is rejected

Use a model that accepts reasoning effort, declare the `thinking` capability,
and enable `default_thinking`, as in the tested example. Kimi CLI 1.49.0 sends
an explicit `reasoning_effort` value through `openai_legacy`; non-reasoning
models can reject it.

### Model not found

Copy the exact model ID from `/v1/models`. If more than one provider exposes
the same model, use the provider-qualified ID, such as
`openai/gpt-5-mini`.

## References

* Kimi Code CLI: [Getting started](https://moonshotai.github.io/kimi-cli/en/guides/getting-started.html)
* Kimi Code CLI: [Providers and models](https://moonshotai.github.io/kimi-cli/en/configuration/providers.html)
* Kimi Code CLI: [Configuration files](https://moonshotai.github.io/kimi-cli/en/configuration/config-files.html)

## Validated on August 8, 2026

This guide was validated against:

* a local GoModel instance on `http://localhost:8080`
* Kimi Code CLI `1.49.0`
* `openai/gpt-5-mini` through GoModel's OpenAI-compatible Chat Completions API

Local validation confirmed:

* Kimi accepted the documented TOML configuration with a dedicated managed key
  that had `/agents/kimi` as its user path and no dashboard access
* `kimi --quiet -p` returned `ok` through `Kimi Code CLI -> GoModel -> OpenAI`
* Kimi invoked its Shell tool and returned `tool-ok` through the same route
* the Kimi key could list and call models but received `403` from the admin API
* no GoModel application change or `api.json` endpoint was required
