Reference

API Reference

One gateway, compatible with both OpenAI and Anthropic — just change the base URL and keep your code.

Base URLs

OpenAI SDK / direct
https://api.anajaklabs.dev/v1
Anthropic / Claude Code
https://api.anajaklabs.dev

OpenAI clients append paths to {base}/v1. The Anthropic base has no /v1 — the SDK adds /v1/messages automatically.

Authentication

Send the gateway key in either header. If you send both, Authorization wins.

Authorization: Bearer sk-xxxxxxxxxxxx
x-api-key: sk-xxxxxxxxxxxx

No key → 401 missing_api_key. Invalid/expired/revoked key → 401 invalid_api_key. Out of credit → 402 quota_exhausted.

Endpoints

MethodPathPurpose
GET/v1Health check and endpoint discovery
GET/v1/modelsList models the key may use
GET/v1/usageRemaining quota and credit
POST/v1/chat/completionsChat completions (OpenAI format)
POST/v1/responsesResponses (OpenAI format)
POST/v1/messagesMessages (Anthropic format)
POST/v1/images/generationsImage generation (OpenAI format)

Models

All model ids are listed below. For the live list your key is allowed to use, call GET /v1/models.

ModelProviderFamilyInput / Output
claude-opus-4-8anthropicopustext · vision in
claude-opus-4-7anthropicopustext · vision in
claude-sonnet-5anthropicsonnettext · vision in
claude-sonnet-4-6anthropicsonnettext · vision in
claude-haiku-4-5anthropichaikutext · vision in
gpt-5.5openaicodextext · vision in
gpt-5.4openaicodextext · vision in
gpt-5.4-miniopenaicodextext · vision in
gpt-4oopenaiothertext · vision in
gpt-4openaiothertext
gpt-image-1openaiimagetext · image out
dall-e-3openaiimagetext · image out
Aliases: autoclaude-opus-4-8; dotted forms like claude-opus-4.8 resolve to claude-opus-4-8. An unknown model → 404 invalid_model.

Requests

Chat completions · OpenAI

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

Messages · Anthropic

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

Image generation · OpenAI

curl https://api.anajaklabs.dev/v1/images/generations \
  -H "Authorization: Bearer sk-xxxxxxxxxxxx" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1",
    "prompt": "a glowing node graph, neon yellow",
    "size": "1024x1024"
  }'

Streaming

Set "stream": true — the gateway sends text/event-stream with no buffering (no-transform). If an error occurs after the stream has started (HTTP 200 already sent) it arrives as a frame:

event: error
data: {"error":{"message":"...","type":"api_error","code":"upstream_error"}}

Usage

GET /v1/usage returns the quota for the key you send:

{
  "label": "team-key",
  "tokens_total": 1000000,
  "tokens_used": 12480,
  "tokens_remaining": 987520,
  "expires_at": "2026-12-31T00:00:00.000Z",
  "status": "active",
  "rate": { "khr_per_usd": 4000 }
}

Errors

Every error uses one envelope shape. The code also comes back as the header x-gateway-error-code. Provider error text is never leaked.

{
  "error": {
    "message": "Missing API key. Add header: Authorization: Bearer <your-key>",
    "type": "authentication_error",
    "code": "missing_api_key"
  }
}
CodeHTTPTypeMeaning
missing_api_key401authentication_errorNo API key in the header
invalid_api_key401authentication_errorKey invalid / expired / revoked
permission_denied403permission_errorKey not allowed for this model
quota_exhausted402invalid_request_errorOut of credit
rate_limit_exceeded429rate_limit_errorToo many requests — over the rate limit
context_length_exceeded400invalid_request_errorContext longer than allowed
content_policy_violation400invalid_request_errorContent violates policy
invalid_model404invalid_request_errorModel doesn't exist or key not allowed
payload_too_large413invalid_request_errorRequest body too large (default 25MB)
invalid_json400invalid_request_errorBody is not valid JSON
service_unavailable503api_errorService busy — please try again
gateway_timeout504api_errorTimed out reaching the provider
upstream_error502api_errorThe provider returned an error
internal_error500api_errorUnexpected gateway error