Skip to main content

Required Request Headers

HeaderRequiredDescription
AuthorizationYesBearer <API_KEY> project-scoped token
Content-TypeJSON routesTypically application/json

Core Request Examples

Chat Completions

{
  "model": "YOUR_MODEL_NAME",
  "messages": [{ "role": "user", "content": "Hello" }],
  "max_tokens": 256
}

Embeddings

{
  "model": "YOUR_MODEL_NAME",
  "input": "Text to embed"
}

Audio Transcription (multipart)

  • file: binary upload
  • model: model name
  • optional format fields

Status Code Handling

StatusMeaningAction
200SuccessParse response and continue
400/422Invalid payloadFix input schema or fields
401/403Auth/permission errorVerify key, scope, and access
404Endpoint not foundConfirm base URL and route path
429Rate limitedRetry with backoff
5xxServer/transient issueRetry with bounded attempts

Response Validation Checklist

Response status and JSON schema are validated
Error payloads are logged with status code
Sensitive fields are redacted before logging