codex-gateway

OpenAI-compatible endpoint backed by a Codex subscription. Best-effort by design: turns run one at a time, take 10–60 s, and every caller must cope with a typed failure. See /healthz · dashboard.

Base URL

https://ai.altitudecraft.com/v1

Models

codex-gpt-5.6 gpt-5.6-sol gpt-5.6-terra gpt-5.6-luna gpt-5.5 gpt-5.3-codex-spark — append :low / :medium / :high / :xhigh to pick reasoning effort (e.g. codex-gpt-5.6:high).

curl

curl https://ai.altitudecraft.com/v1/chat/completions \
  -H "Authorization: Bearer $CODEX_GW_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model":"codex-gpt-5.6","messages":[{"role":"user","content":"Summarise this ticket: ..."}]}'

Python (openai ≥ 1.0)

from openai import OpenAI
client = OpenAI(base_url="https://ai.altitudecraft.com/v1", api_key=os.environ["CODEX_GW_KEY"], timeout=180, max_retries=0)
r = client.chat.completions.create(
    model="codex-gpt-5.6",
    messages=[{"role": "user", "content": "..."}],
    response_format={"type": "json_object"},   # optional: forces a JSON answer
)
print(r.choices[0].message.content)

Node (openai ≥ 4)

import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://ai.altitudecraft.com/v1", apiKey: process.env.CODEX_GW_KEY, timeout: 180_000, maxRetries: 0 });
const r = await client.chat.completions.create({
  model: "codex-gpt-5.6",
  messages: [{ role: "user", content: "..." }],
  stream: true,
});
for await (const chunk of r) process.stdout.write(chunk.choices[0]?.delta?.content ?? "");

What is and is not supported

Worksmessages (system/user/assistant, text parts), stream, stream_options.include_usage, response_format (json_object, json_schema), model + effort suffix, X-Gateway-Priority header (higher number = lower priority)
Ignoredtemperature, top_p, max_tokens, penalties, seed, stop, reasoning_effort (use the model suffix) — listed back in the X-Gateway-Ignored response header
Rejected (400)tools / functions (Codex cannot hand tool calls back to you), n > 1
Not availableembeddings, images, audio, /v1/responses

Errors (OpenAI envelope)

HTTPcodeMeaning
400invalid_request · unsupported_parameterFix the request
401unauthorizedMissing, unknown or revoked key
404model_not_foundNot on the model list above
429rate_limited · budget_exhaustedYour key's per-minute or per-day allowance; honour Retry-After
429queue_full · queue_timeoutBackpressure; honour Retry-After
429quota_exhaustedThe subscription window is spent
502upstream_auth · upstream_unavailableCodex failed on the host
503circuit_open · shutting_downFailing fast; retry later
504exec_timeoutTurn exceeded the limit and was terminated

Rule of thumb for callers: set a hard timeout, never retry 4xx, retry 429/503 after Retry-After at most once, and make "no answer" a state your feature can ship in.