Client Integrations (Claude Code / Codex CLI / SDKs)
One-click scripts for pointing Claude Code and Codex CLI at the gateway, plus OpenAI and Anthropic SDK configuration.
Point existing AI clients to Inference Space by switching only the base URL and API key. The data plane is https://ai.inf.space, and authentication uses a gateway API key beginning with gk_. This page provides one-click installation scripts for Claude Code and Codex CLI, plus manual configuration for the OpenAI and Anthropic SDKs.
The private deployment integration is identical; replace
ai.inf.spacewith your own data-plane domain → Enterprise Private Deployment.
All integration base URLs point to the data plane at https://ai.inf.space. Use it for browser login, key creation, usage monitoring, and API requests.
Codex CLI
The one-click installation script writes a named provider section, [model_providers.tos-run], to ~/.codex/config.toml and stores the API key in the separate TOS_API_KEY environment variable.
curl -fsSL https://tos.run/install/codex.sh | bash -s -- --key gk_YOUR_KEYirm https://tos.run/install/codex.ps1 -OutFile setup-codex.ps1
.\setup-codex.ps1 -Key gk_YOUR_KEYThe ~/.codex/config.toml written by the script is equivalent to:
model_provider = "tos-run"
model = "gpt-5.6-sol"
model_reasoning_effort = "medium"
preferred_auth_method = "apikey"
[model_providers.tos-run]
name = "Inference Space"
base_url = "https://ai.inf.space/v1"
env_key = "TOS_API_KEY"
wire_api = "responses"
request_max_retries = 0
stream_max_retries = 0Key points:
base_url = https://ai.inf.space/v1, andwire_api = responses(the Codex Responses protocol).env_key = TOS_API_KEY: Codex reads the API key from this environment variable. The script adds it to~/.zshrcor~/.bashrc.model_provider = tos-run: switches the default provider to the named gateway section. Otherwise Codex routes to the built-inopenaiprovider and returns a 401.- Use the model shown as available in the console. We recommend managing it as a configuration value.
Do not reuse OPENAI_API_KEY as the gateway key. Codex's built-in openai provider reads OPENAI_API_KEY; reusing it would (1) overwrite your actual OpenAI key and (2) prevent Codex from distinguishing the key's owner. Always use the separate TOS_API_KEY.
If Codex is not installed yet: npm install -g @openai/codex.
Claude Code
The one-click installation script writes an env block to ~/.claude/settings.json and points Claude Code to the gateway's Anthropic-compatible endpoint.
curl -fsSL https://tos.run/install/claude.sh | bash -s -- --key gk_YOUR_KEYThe ~/.claude/settings.json written by the script is equivalent to the following. Existing keys are preserved and merged:
{
"env": {
"ANTHROPIC_BASE_URL": "https://ai.inf.space",
"ANTHROPIC_AUTH_TOKEN": "gk_YOUR_KEY"
}
}Key points:
ANTHROPIC_BASE_URL = https://ai.inf.space(the data plane, without/v1; Claude Code appends/v1/messagesitself).ANTHROPIC_AUTH_TOKEN = gk_YOUR_KEY: sends the key to the gateway asAuthorization: Bearer.
Do not set a global ANTHROPIC_API_KEY. Its priority is higher than the env block in settings.json, so it bypasses the gateway and sends requests to the native Anthropic endpoint. Similarly, an ANTHROPIC_BASE_URL exported in the shell overrides the value in settings.json. If the installation script detects either conflict, it warns you; follow the instructions to run unset ANTHROPIC_API_KEY or unset ANTHROPIC_BASE_URL.
If Claude Code is not installed yet: npm install -g @anthropic-ai/claude-code.
OpenAI SDK
For the OpenAI-compatible API, set base_url to https://ai.inf.space/v1 and use a gk_ gateway key.
import os
from openai import OpenAI
client = OpenAI(
base_url="https://ai.inf.space/v1",
api_key=os.environ["TOS_API_KEY"], # Gateway key beginning with gk_
)
resp = client.chat.completions.create(
model="qwen-plus", # See the console for available models
messages=[{"role": "user", "content": "Introduce yourself in one sentence."}],
)
print(resp.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://ai.inf.space/v1",
apiKey: process.env.TOS_API_KEY, // Gateway key beginning with gk_
});
const resp = await client.chat.completions.create({
model: "qwen-plus", // See the console for available models
messages: [{ role: "user", content: "Introduce yourself in one sentence." }],
});
console.log(resp.choices[0].message.content);Some OpenAI-compatible clients automatically read the key from OPENAI_API_KEY. That variable usually has higher priority and may bypass the gateway key configured in your code. We recommend passing api_key explicitly and storing the gateway key in the separate TOS_API_KEY variable.
Anthropic SDK
For the Anthropic-native Messages API, set base_url to https://ai.inf.space; the SDK appends /v1/messages. The gateway accepts Authorization: Bearer gk_... on the data plane, so pass the gateway key through auth_token.
import os
from anthropic import Anthropic
client = Anthropic(
base_url="https://ai.inf.space",
auth_token=os.environ["TOS_API_KEY"], # → Authorization: Bearer gk_...
)
msg = client.messages.create(
model="claude-sonnet-4-x", # See the console for available models
max_tokens=1024,
messages=[{"role": "user", "content": "Introduce yourself in three sentences."}],
)
print(msg.content)import Anthropic from "@anthropic-ai/sdk";
const client = new Anthropic({
baseURL: "https://ai.inf.space",
authToken: process.env.TOS_API_KEY, // → Authorization: Bearer gk_...
});
const msg = await client.messages.create({
model: "claude-sonnet-4-x", // See the console for available models
max_tokens: 1024,
messages: [{ role: "user", content: "Introduce yourself in three sentences." }],
});
console.log(msg.content);Always use a gateway key beginning with gk_; do not mix it with a native provider key. For Anthropic-native Messages parameters, streaming, and tool calls, see Claude Messages API. For error handling and retries, see Error Codes and Error Handling and Rate Limits and Quotas.