{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://raw.githubusercontent.com/api-evangelist/cloudflare/main/json-schema/cloudflare-chat-completion-request-schema.json",
  "title": "ChatCompletionRequest",
  "x-generated": "2026-10-03",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/cloudflare-openai-compatible-api-openapi.yml#/components/schemas/ChatCompletionRequest",
  "type": "object",
  "required": [
    "model",
    "messages"
  ],
  "properties": {
    "model": {
      "type": "string",
      "description": "The model identifier, e.g. @cf/meta/llama-3.1-8b-instruct."
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "object",
        "required": [
          "role",
          "content"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "user",
              "assistant"
            ]
          },
          "content": {
            "type": "string"
          }
        }
      }
    },
    "max_tokens": {
      "type": "integer",
      "description": "Maximum number of tokens to generate."
    },
    "temperature": {
      "type": "number",
      "description": "Sampling temperature between 0 and 2.",
      "minimum": 0,
      "maximum": 2
    },
    "top_p": {
      "type": "number",
      "description": "Nucleus sampling parameter.",
      "minimum": 0,
      "maximum": 1
    },
    "stream": {
      "type": "boolean",
      "description": "Whether to stream the response via server-sent events."
    }
  }
}