Skip to content

OpenAI-compatible API

CodeGate implements two OpenAI HTTP endpoints. Any SDK that already talks to api.openai.com on these paths will work by changing the base URL and the key.

  • Base URL: https://codegate.dev/v1
  • Auth: Authorization: Bearer sk-...

Currently shipped:

  • POST /v1/chat/completions, the core chat endpoint.
  • POST /v1/responses, the newer Responses API shape.

Not shipped today: /v1/completions, /v1/embeddings, /v1/models, /v1/audio/transcriptions, /v1/audio/speech. Image generation is coming soon.

POST /v1/chat/completions

Chat-shaped completion with a messages array.

bash
curl https://codegate.dev/v1/chat/completions \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      {"role": "user", "content": "Say hello."}
    ]
  }'

Response shape matches OpenAI's:

json
{
  "id": "chatcmpl-...",
  "object": "chat.completion",
  "model": "gpt-5.5",
  "choices": [
    {
      "index": 0,
      "message": {"role": "assistant", "content": "Hello."},
      "finish_reason": "stop"
    }
  ],
  "usage": {
    "prompt_tokens": 8,
    "completion_tokens": 2,
    "total_tokens": 10
  }
}

Set "stream": true for Server-Sent Events. Each event is a data: {...} chunk with a partial choices[].delta. The stream ends with data: [DONE].

Routing Claude via the OpenAI shape

You can send "model": "claude-opus-4-8" (or any Claude model) to /v1/chat/completions and CodeGate will translate the OpenAI-shape request to the Anthropic Messages format upstream, then translate the response back. This is how OpenAI-shaped clients talk to Claude through CodeGate.

If you want the native Anthropic request shape (streaming event types, tool-use round-trip, etc.) use /v1/messages directly.

POST /v1/responses

The OpenAI Responses API. A newer shape that unifies chat, tool use, and structured output behind a single input/output model.

bash
curl https://codegate.dev/v1/responses \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "input": "In one sentence, what is CodeGate?"
  }'

Response and streaming semantics match the upstream Responses API.

Streaming

Set "stream": true in the request body and use -N with curl to disable output buffering.

bash
curl -N https://codegate.dev/v1/chat/completions \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{"model":"gpt-5.5","stream":true,"messages":[{"role":"user","content":"Count to five."}]}'

Errors

Errors match the OpenAI shape:

json
{
  "error": {
    "message": "Invalid API key.",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}

See the API overview for a status code cheat sheet.

What about images and audio?

Image generation is coming soon. When it lands the endpoint will be POST /v1/images/generations. If you need it earlier, ping us on the Discord.

Audio (Whisper transcription, TTS) is not on the current roadmap.

Next

Built on new-api. Served by CodeGate.