Skip to content

DocsGateway

Connect Claude Code or Codex

Updated Sep 18, 2026

Claude Code and Codex are coding agents that run in your terminal. Each talks to a model over its own protocol: Claude Code speaks the Anthropic Messages API, Codex speaks the OpenAI Responses API. The NextOS gateway serves both, so either tool can run on the model included with your account, or on your own Anthropic or OpenAI key once it is in your vault.

One line to paste

Open Settings > Developer > Connect Claude Code or Codex, pick the tool and a model, and press Create key and show the line. You get a line like this:

curl -fsSL https://www.jonkum.in/connect.sh | bash -s -- claude ngk_… --origin https://www.jonkum.in --model openai/gpt-oss-120b

Paste it into a terminal on the machine where the tool runs. The key in the line is made for that tool only, scoped to model calls, and shown once. Make another line for another machine or another tool.

What the script changes

Claude Code. The script writes the gateway address, the key and the model into the env block of ~/.claude/settings.json, keeping everything else in the file, and leaves a backup next to it. Claude Code reads those values in its next session. To go back to your Anthropic account, remove the ANTHROPIC_* lines from that block.

Codex. The script adds a nextos model provider to ~/.codex/config.toml, selects it, and puts the key in your shell profile as NEXTOS_GATEWAY_KEY. Open a new shell, then start Codex. To go back, remove the provider block and the export line.

The script changes nothing else, and it prints every path it touched.

Which model runs

  • With no key of your own in the vault, requests run on your plan's included model, and each reply comes out of your monthly included AI allowance. If the tool asks for a model your plan does not include, the plan's default runs instead; the reply's X-NextOS-Model header names what ran.
  • With your own Anthropic key in the vault (Settings > Privacy > Background runs), Claude Code requests for Claude models go straight to Anthropic on your key and are not metered. The same holds for Codex with an OpenAI key and OpenAI models.

Or run your subscription on your machine

The line above points Claude Code or Codex at NextOS's own model. If you'd rather your NextOS agents run through a Claude Pro/Max or ChatGPT subscription you already pay for, register your computer as a bridge instead - pick "Your machine" in the same Connect card, or see Bring your own machine for the one line and what the agent can do there.

Doing it by hand

Any client that speaks either protocol can use the same doors with a gateway key from Settings > Developer:

Client protocolBase URLEndpoint
Anthropic Messageshttps://www.jonkum.in/apiPOST /v1/messages, POST /v1/messages/count_tokens
OpenAI Responseshttps://www.jonkum.in/api/v1POST /v1/responses
OpenAI Chat Completionshttps://www.jonkum.in/api/v1POST /v1/chat/completions

Send the key as Authorization: Bearer ngk_…. Streaming, tools and token counting pass through unchanged.