Skip to content

API Reference

CodeGate speaks two request protocols behind one host. Pick the shape that matches your existing SDK or client.

Base URL

https://codegate.dev

One base URL. Every endpoint documented in this section is a path under it.

Protocols

ProtocolEndpointAuth header
OpenAI Chat CompletionsPOST /v1/chat/completionsAuthorization: Bearer sk-...
OpenAI ResponsesPOST /v1/responsesAuthorization: Bearer sk-...
Anthropic MessagesPOST /v1/messagesx-api-key: sk-... + anthropic-version: 2023-06-01

Gemini support is planned but not currently shipped. If you need Gemini through the same account, join the Discord and we will let you know when it lands.

Choosing a protocol

  • Already have OpenAI SDK code? Use the OpenAI-compatible endpoints. Change the base URL and key, keep everything else. Any model you point at (Claude, GPT) is routed under the hood.
  • Using Claude Code, an Anthropic SDK, or the Messages format directly? Use the Anthropic-compatible endpoint. It preserves the native Messages request shape including tool use.

The same sk-... key works for both. What changes is the auth header and the request body shape.

Common errors

StatusMeaningAction
400Bad request shape or unknown modelCheck the request body against the protocol reference.
401Missing or invalid keyConfirm the sk-... value and the auth header format.
402Balance exhaustedTop up at Console, Top Up.
403Model not permitted for this keySome models require higher tiers.
404Wrong path or unknown model IDConfirm the endpoint path.
429Too many requests upstreamBack off and retry. See Rate Limits.
5xxTransient upstream failureRetry once. CodeGate fails over between upstreams.

Streaming

Both protocols support streaming. Set "stream": true on the request body. See curl for copy-paste examples.

Next

Built on new-api. Served by CodeGate.