{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/sunbird-ai/json-schema/sunbird-ai-chat-completion-request-schema.json",
  "title": "ChatCompletionRequest",
  "description": "Request body for POST /tasks/chat/completions (OpenAI format).",
  "x-generated": "2026-11-25",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/_original/sunbird-ai-api-openapi.json#/components/schemas/ChatCompletionRequest",
  "properties": {
    "model": {
      "type": "string",
      "title": "Model",
      "description": "Model to use. Supported: sunflower-9b",
      "default": "sunflower-9b"
    },
    "messages": {
      "items": {
        "$ref": "#/$defs/ChatMessage"
      },
      "type": "array",
      "minItems": 1,
      "title": "Messages",
      "description": "Conversation messages"
    },
    "temperature": {
      "type": "number",
      "maximum": 2.0,
      "minimum": 0.0,
      "title": "Temperature",
      "description": "Sampling temperature",
      "default": 0.3
    },
    "max_tokens": {
      "anyOf": [
        {
          "type": "integer",
          "minimum": 1.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Max Tokens",
      "description": "Maximum tokens to generate"
    },
    "top_p": {
      "anyOf": [
        {
          "type": "number",
          "maximum": 1.0,
          "exclusiveMinimum": 0.0
        },
        {
          "type": "null"
        }
      ],
      "title": "Top P",
      "description": "Nucleus sampling probability"
    },
    "stop": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Stop",
      "description": "Stop sequence(s)"
    },
    "stream": {
      "type": "boolean",
      "title": "Stream",
      "description": "Stream the response as Server-Sent Events",
      "default": false
    }
  },
  "type": "object",
  "required": [
    "messages"
  ],
  "$defs": {
    "ChatMessage": {
      "properties": {
        "role": {
          "type": "string",
          "enum": [
            "system",
            "user",
            "assistant"
          ],
          "title": "Role",
          "description": "Message role"
        },
        "content": {
          "type": "string",
          "title": "Content",
          "description": "Message content"
        }
      },
      "type": "object",
      "required": [
        "role",
        "content"
      ],
      "title": "ChatMessage",
      "description": "A single message in the conversation, OpenAI format."
    }
  }
}