> ## Documentation Index
> Fetch the complete documentation index at: https://gomodel-refactor-aliases.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# GoModel & Codex

> Put GoModel between Codex and your models: keep billing on your ChatGPT subscription, or route Codex to any other provider.

GoModel is a good fit for Codex because Codex already targets the OpenAI
Responses API.

`Codex -> GoModel -> upstream`

Codex talks to GoModel with a GoModel master key, so every request shows up in
the dashboard. The one choice to make is which provider serves the model,
because that decides what pays for it:

| Provider                                                                                                           | Upstream                                   | Billing                    |
| ------------------------------------------------------------------------------------------------------------------ | ------------------------------------------ | -------------------------- |
| [`chatgpt`](/providers/chatgpt)                                                                                    | The Codex backend behind your ChatGPT plan | ChatGPT subscription quota |
| `openai`, [`deepseek`](/providers/deepseek), [`anthropic`](/providers/anthropic), [any other](/providers/overview) | That provider's API                        | That provider's API credit |

Everything after this point is the same either way.

## Before you start

* Install Codex on your machine.
* Choose a GoModel master key, for example `change-me`.

To bill Codex to your ChatGPT plan, sign in once so Codex writes its token
file, then hand that token to GoModel:

```bash theme={null}
codex login
export CHATGPT_API_KEY=$(jq -r .tokens.access_token ~/.codex/auth.json)
```

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

See the [ChatGPT provider page](/providers/chatgpt) for the model list, the
token's \~10-day lifetime, and which Responses parameters that backend accepts.

To bill it to API credit instead, configure any other provider as usual — for
example `-e OPENAI_API_KEY="sk-..."` — and use one of its models in step 2.

## 1. Confirm the Responses API

Optional: check that GoModel answers a plain Responses request before involving
Codex. Use a model your configured provider actually serves.

```bash theme={null}
curl -s http://localhost:8080/v1/responses \
  -H "Authorization: Bearer change-me" \
  -H "Content-Type: application/json" \
  -d '{"model": "gpt-5.6-sol", "input": "Reply with exactly ok"}'
```

The response contains `ok`. For the Python and JavaScript equivalents, see the
[Responses API reference](/advanced/responses-api).

## 2. Configure Codex to use GoModel

Add a Responses-based provider to `~/.codex/config.toml`:

```toml theme={null}
model_provider = "gomodel"
model = "gpt-5.6-sol"   # or any model your GoModel serves

[model_providers.gomodel]
name = "GoModel"
base_url = "http://localhost:8080/v1"
env_key = "GOMODEL_API_KEY"
wire_api = "responses"
```

Then export the GoModel master key for that provider:

```bash theme={null}
export GOMODEL_API_KEY=change-me
```

<Note>
  Codex requires this variable even when you are signed in with ChatGPT, and it
  carries the GoModel master key — not an OpenAI key. Without it the provider
  fails to start.
</Note>

To try it without editing your config, pass the same settings inline:

```bash theme={null}
GOMODEL_API_KEY=change-me codex exec \
  -c model_provider=gomodel \
  -c 'model_providers.gomodel.name="GoModel"' \
  -c 'model_providers.gomodel.base_url="http://localhost:8080/v1"' \
  -c 'model_providers.gomodel.env_key="GOMODEL_API_KEY"' \
  -c 'model_providers.gomodel.wire_api="responses"' \
  -m gpt-5.6-sol 'Reply with exactly ok and no punctuation.'
```

<Note>
  Codex ignores `OPENAI_BASE_URL`. Use the provider config above, or set
  `openai_base_url` in Codex config if you intentionally want to override the
  built-in OpenAI provider.
</Note>

## 3. Run a Codex test prompt

```bash theme={null}
codex exec -m gpt-5.6-sol 'Reply with exactly ok and no punctuation.'
```

The validated result was:

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

<Note>
  Codex 0.147.0 logs `failed to refresh available models: missing field
      "models"` at startup. It calls its own catalogue endpoint, which GoModel
  answers with the standard OpenAI `/v1/models` shape. The message is cosmetic
  — Codex falls back and the session works.
</Note>

## 4. Check the traffic in GoModel

Open the GoModel dashboard audit logs:

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

This lets you confirm that Codex is reaching GoModel and inspect the full
request and response trail. From the same dashboard, you can keep following
your GoModel traffic and usage.

## DeepSeek V4

Codex sends `POST /v1/responses`, which DeepSeek does not serve natively. Use
`type: deepseek` rather than `type: openai`: the DeepSeek provider translates
`/responses` to `/chat/completions`, while the generic OpenAI provider forwards
it upstream unchanged.

```yaml theme={null}
providers:
  deepseek:
    type: deepseek
    api_key: "${DEEPSEEK_API_KEY}"
```

Then set `model = "deepseek-v4-pro"` in the Codex config from step 2. See the
[DeepSeek page](/providers/deepseek) for the reasoning-effort mapping, and
[Responses compatibility](/advanced/responses-compatibility) for what
chat-translated providers drop — including the `reasoning.encrypted_content`
Codex asks for on every request.

## Current status

* the recommended integration path is Codex custom provider -> standard
  `http://localhost:8080/v1`
* Codex custom provider mode sends `POST /v1/responses` as plain JSON, so the
  old `--disable enable_request_compression` workaround is no longer required

## References

* OpenAI Codex discussion: [Deprecating `chat/completions` support in Codex](https://github.com/openai/codex/discussions/7782)
* OpenAI Codex repository: [openai/codex](https://github.com/openai/codex)

## Validated on August 20, 2026

This guide was validated against a local GoModel instance and Codex CLI
`0.147.0`. Local validation confirmed:

* `codex exec` returned `ok` through `Codex -> GoModel -> ChatGPT subscription`
* `POST /v1/responses` returned `200 OK` for both streaming and non-streaming
  callers
* Codex sent plain JSON; no `Content-Encoding: zstd` header was present
* the custom `gomodel` provider failed without its `env_key`, because Codex
  still requires that variable when signed in with ChatGPT
