Skip to content

curl

Copy-paste curl blocks for every supported protocol. All examples use https://codegate.dev as the base URL and a placeholder sk-... key. Replace sk-... with a real key from codegate.dev/console/token.

OpenAI Chat Completions

bash
curl https://codegate.dev/v1/chat/completions \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "messages": [
      {"role": "system", "content": "You are a helpful assistant."},
      {"role": "user",   "content": "In one sentence, what is CodeGate?"}
    ]
  }'

OpenAI Responses API

bash
curl https://codegate.dev/v1/responses \
  -H "Authorization: Bearer sk-..." \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-5.5",
    "input": "Give me a one-sentence summary of CodeGate."
  }'

Anthropic Messages

bash
curl https://codegate.dev/v1/messages \
  -H "x-api-key: sk-..." \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Say hello."}]
  }'

Route Claude via the OpenAI shape

You can send Claude model IDs to the OpenAI Chat Completions endpoint. CodeGate translates the request to the Anthropic Messages format upstream and translates the response back.

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

Use the OpenAI shape when your client only speaks OpenAI (Codex, opencode). Use the Anthropic endpoint when you want native Messages semantics (streaming event types, tool-use round-trip).

Streaming (Server-Sent Events)

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

OpenAI stream

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 slowly."}]
  }'

Anthropic stream

bash
curl -N https://codegate.dev/v1/messages \
  -H "x-api-key: sk-..." \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-opus-4-8",
    "max_tokens": 512,
    "stream": true,
    "messages": [{"role": "user", "content": "Count to five slowly."}]
  }'

Notes

  • All endpoints live under the same host: https://codegate.dev. There is no separate api. subdomain.
  • Not currently shipped: /v1/completions, /v1/embeddings, /v1/models, /v1/audio/*, Gemini's /v1beta/models/*. Image generation is coming soon.
  • If a request fails with 429, back off and retry.

Built on new-api. Served by CodeGate.