API reference
Every route the hub relays, how keys are sent, what errors look like and which limits apply.
Endpoints
| Route | Use |
|---|---|
POST /v1/chat/completions | OpenAI Chat Completions; streamed calls carry usage automatically. |
POST /v1/responses | OpenAI Responses API, used by Codex. |
POST /v1/embeddings | Embeddings, for models that offer them. |
POST /v1/messages | Anthropic Messages, for Claude Code and Claude Desktop. |
POST /v1/messages/count_tokens | Token counting; never billed. |
POST /v1beta/models/{model}:generateContent | Gemini native, one response. |
POST /v1beta/models/{model}:streamGenerateContent?alt=sse | Gemini native, streamed as server-sent events. |
GET /v1/models · GET /v1beta/models | Model lists in OpenAI and Gemini format; need a key, cost nothing. |
Sending the key
Use Authorization: Bearer, x-api-key or x-goog-api-key; Gemini clients may also append ?key=, which is stripped before forwarding.
curl --request POST "https://api.coderelayhub.com/v1beta/models/gemini-3.8-flash:generateContent" \
--header "x-goog-api-key: crh_paste_your_key_here" --header "Content-Type: application/json" \
--data '{"contents":[{"role":"user","parts":[{"text":"Summarize git rebase in one line"}]}]}'Error codes
Every call is billed on the tokens the provider reports. Errors come back in the OpenAI error envelope.
| HTTP | type | What it means on the hub |
|---|---|---|
400 | invalid_request_error · model_not_found | Malformed request, missing model, unknown model, or a model sent to the wrong protocol. |
401 | authentication_error | No API key was sent, or the key is unknown or revoked. |
402 | insufficient_quota | Balance is at zero (pay-as-you-go key) or the matching monthly plan is used up. Top up to continue. |
403 | permission_error | The account is suspended, or a monthly-plan key called a model outside its family. |
413 | invalid_request_error | Request body larger than 25 MB. |
429 | rate_limit_error | More than 120 calls a minute on one key, or 8 calls already in flight for the account. |
502 | api_error | The provider could not be reached, and nothing was charged. |
Limits
- 120 requests per rolling minute per key.
- 8 requests in flight per account.
- 25 MB per request body; long streams are never cut by a timeout.