Content-Type Header

Set the Content-Type header to application/json for all requests to ensure the server correctly interprets the request payload.

Content-Type: application/json

Why It’s Required

  • Ensures proper parsing of request bodies
  • Enables correct interpretation of JSON payloads
  • Prevents data format mismatches

Request Examples

Correct Usage

POST /api/chat/completions
Content-Type: application/json

{
  "messages": [
    {
      "role": "user",
      "content": "Hello!"
    }
  ]
}

Common Errors

If the Content-Type header is missing or incorrect, you’ll receive a 400 Bad Request response:

{
  "error": {
    "message": "Content-Type must be application/json",
    "code": 400
  }
}