{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "#/components/schemas/ApiChatCompletionsRequest",
  "title": "ApiChatCompletionsRequest",
  "properties": {
    "max_tokens": {
      "anyOf": [
        {
          "type": "integer",
          "maximum": 128000,
          "exclusiveMinimum": 0
        },
        {
          "type": "null"
        }
      ],
      "title": "Max Tokens",
      "description": "Maximum number of completion tokens to generate"
    },
    "model": {
      "type": "string",
      "title": "Model",
      "description": "Model to use, for example, sonar-pro",
      "enum": [
        "sonar",
        "sonar-pro",
        "sonar-deep-research",
        "sonar-reasoning-pro"
      ]
    },
    "stream": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Stream",
      "description": "If true, returns streaming SSE response",
      "default": false
    },
    "stop": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Stop",
      "description": "Stop sequences. Generation stops when one of these strings is produced"
    },
    "temperature": {
      "anyOf": [
        {
          "type": "number",
          "minimum": 0,
          "maximum": 2
        },
        {
          "type": "null"
        }
      ],
      "title": "Temperature",
      "description": "Controls randomness in the response. Higher values make output more random. Range: 0-2"
    },
    "top_p": {
      "anyOf": [
        {
          "type": "number",
          "minimum": 0,
          "maximum": 1
        },
        {
          "type": "null"
        }
      ],
      "title": "Top P",
      "description": "Nucleus sampling parameter. Controls diversity via nucleus sampling"
    },
    "response_format": {
      "anyOf": [
        {
          "$ref": "#/components/schemas/ResponseFormatText"
        },
        {
          "$ref": "#/components/schemas/ResponseFormatJSONSchema"
        },
        {
          "type": "null"
        }
      ],
      "title": "Response Format",
      "description": "Optional. Controls the output format. Omit for default text output. Set `type` to `json_schema` for structured output.",
      "discriminator": {
        "propertyName": "type",
        "mapping": {
          "text": "#/components/schemas/ResponseFormatText",
          "json_schema": "#/components/schemas/ResponseFormatJSONSchema"
        }
      }
    },
    "messages": {
      "items": {
        "$ref": "#/components/schemas/ChatMessage-Input"
      },
      "type": "array",
      "title": "Messages",
      "description": "Array of messages forming the conversation history"
    },
    "web_search_options": {
      "$ref": "#/components/schemas/WebSearchOptions"
    },
    "search_mode": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "web",
            "academic",
            "sec"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Search Mode",
      "description": "Source of search results (web, academic, or sec)"
    },
    "return_images": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Return Images",
      "description": "When true, include image results in the response"
    },
    "return_related_questions": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Return Related Questions",
      "description": "When true, generates suggested follow-up queries based on the search results"
    },
    "enable_search_classifier": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Enable Search Classifier",
      "description": "When true, uses a classifier to determine if web search is needed for the query"
    },
    "disable_search": {
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "null"
        }
      ],
      "title": "Disable Search",
      "description": "When true, disables all web search capabilities. The model responds based solely on its training data"
    },
    "search_domain_filter": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Search Domain Filter",
      "description": "Limit search results to specific domains (e.g. github.com, wikipedia.org)"
    },
    "search_language_filter": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Search Language Filter",
      "description": "Filter results by language using ISO 639-1 codes (e.g. en, fr, de)"
    },
    "search_recency_filter": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "hour",
            "day",
            "week",
            "month",
            "year"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Search Recency Filter",
      "description": "Filter by publication recency (hour, day, week, month, or year)"
    },
    "search_after_date_filter": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Search After Date Filter",
      "description": "Return results published after this date (MM/DD/YYYY)"
    },
    "search_before_date_filter": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Search Before Date Filter",
      "description": "Return results published before this date (MM/DD/YYYY)"
    },
    "last_updated_before_filter": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Updated Before Filter",
      "description": "Return results last updated before this date (MM/DD/YYYY)"
    },
    "last_updated_after_filter": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Last Updated After Filter",
      "description": "Return results last updated after this date (MM/DD/YYYY)"
    },
    "image_format_filter": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Image Format Filter",
      "description": "Filter image results by format (e.g. png, jpg)"
    },
    "image_domain_filter": {
      "anyOf": [
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        },
        {
          "type": "null"
        }
      ],
      "title": "Image Domain Filter",
      "description": "Limit image results to specific domains"
    },
    "stream_mode": {
      "type": "string",
      "enum": [
        "full",
        "concise"
      ],
      "title": "Stream Mode",
      "description": "Controls the format of streaming events. 'full' suppresses reasoning events and includes metadata inline; 'concise' emits reasoning events separately",
      "default": "full"
    },
    "reasoning_effort": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "minimal",
            "low",
            "medium",
            "high"
          ]
        },
        {
          "type": "null"
        }
      ],
      "title": "Reasoning Effort",
      "description": "Controls how much effort the model spends on reasoning"
    },
    "language_preference": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "null"
        }
      ],
      "title": "Language Preference",
      "description": "ISO 639-1 language code for preferred response language"
    }
  },
  "type": "object",
  "required": [
    "model",
    "messages"
  ]
}