{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/berget-ai/json-schema/berget-ai-chat-completion-request-input-schema.json",
  "title": "ChatCompletionRequestInput",
  "x-generated": "2026-11-24",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/berget-ai-openapi.yml#/components/schemas/ChatCompletionRequestInput",
  "type": "object",
  "properties": {
    "model": {
      "type": "string",
      "minLength": 1,
      "description": "ID of the model to use"
    },
    "messages": {
      "minItems": 1,
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "developer",
              "system",
              "user",
              "assistant",
              "tool",
              "function"
            ],
            "description": "Role of the message sender"
          },
          "content": {
            "description": "Content of the message (string, array of parts, or null). Required unless tool_calls or function_call is specified.",
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "text"
                          ]
                        },
                        "text": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "image_url"
                          ]
                        },
                        "image_url": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string"
                            },
                            "detail": {
                              "type": "string",
                              "enum": [
                                "auto",
                                "low",
                                "high"
                              ]
                            }
                          },
                          "required": [
                            "url"
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "image_url"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "input_audio"
                          ]
                        },
                        "input_audio": {
                          "type": "object",
                          "properties": {
                            "data": {
                              "type": "string"
                            },
                            "format": {
                              "type": "string",
                              "enum": [
                                "wav",
                                "mp3"
                              ]
                            }
                          },
                          "required": [
                            "data",
                            "format"
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "input_audio"
                      ]
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "video_url"
                          ]
                        },
                        "video_url": {
                          "type": "object",
                          "properties": {
                            "url": {
                              "type": "string"
                            }
                          },
                          "required": [
                            "url"
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "video_url"
                      ]
                    }
                  ]
                }
              }
            ],
            "nullable": true
          },
          "name": {
            "description": "Optional name for the sender",
            "type": "string"
          },
          "tool_calls": {
            "description": "Tool calls generated by the assistant",
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string",
                  "description": "Unique identifier for the tool call"
                },
                "type": {
                  "type": "string",
                  "enum": [
                    "function"
                  ],
                  "description": "Tool call type, always \"function\""
                },
                "function": {
                  "type": "object",
                  "properties": {
                    "name": {
                      "type": "string",
                      "description": "Name of the function"
                    },
                    "arguments": {
                      "type": "string",
                      "description": "JSON-encoded arguments for the function"
                    }
                  },
                  "required": [
                    "name",
                    "arguments"
                  ],
                  "description": "Function call details"
                }
              },
              "required": [
                "id",
                "type",
                "function"
              ],
              "additionalProperties": {}
            }
          },
          "function_call": {
            "description": "Legacy function call",
            "type": "object",
            "properties": {
              "arguments": {
                "type": "string"
              },
              "name": {
                "type": "string"
              }
            },
            "required": [
              "arguments",
              "name"
            ]
          },
          "tool_call_id": {
            "description": "ID of the tool call this message is a response to",
            "type": "string"
          },
          "reasoning_content": {
            "description": "Reasoning trace from the provider reasoning parser",
            "type": [
              "string",
              "null"
            ]
          },
          "reasoning": {
            "description": "Alias of reasoning_content",
            "type": [
              "string",
              "null"
            ]
          }
        },
        "required": [
          "role"
        ]
      },
      "description": "Array of chat messages"
    },
    "stream": {
      "default": false,
      "description": "Whether to stream the response",
      "type": "boolean"
    },
    "temperature": {
      "description": "Sampling temperature (0–2). Higher = more random",
      "type": "number",
      "minimum": 0,
      "maximum": 2
    },
    "top_p": {
      "description": "Nucleus sampling cutoff",
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "top_k": {
      "description": "Top-k sampling (vLLM & SGLang only)",
      "type": "number"
    },
    "top_logprobs": {
      "description": "Number of top log probabilities to return",
      "type": "number",
      "minimum": 0,
      "maximum": 20
    },
    "max_tokens": {
      "description": "Maximum tokens to generate",
      "type": "number"
    },
    "max_completion_tokens": {
      "description": "Maximum completion tokens (OpenAI-style alias)",
      "type": "number"
    },
    "n": {
      "description": "Number of completions to generate",
      "type": "integer",
      "minimum": 1,
      "maximum": 128
    },
    "stop": {
      "description": "Stop sequence(s)",
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      ]
    },
    "seed": {
      "description": "Random seed for determinism",
      "type": "number"
    },
    "frequency_penalty": {
      "description": "Frequency penalty (–2 to 2)",
      "type": "number",
      "minimum": -2,
      "maximum": 2
    },
    "presence_penalty": {
      "description": "Presence penalty (–2 to 2)",
      "type": "number",
      "minimum": -2,
      "maximum": 2
    },
    "logit_bias": {
      "description": "Logit bias map per token",
      "type": "object",
      "additionalProperties": {
        "type": "number"
      }
    },
    "logprobs": {
      "description": "Return log probabilities",
      "anyOf": [
        {
          "type": "boolean"
        },
        {
          "type": "number"
        }
      ]
    },
    "reasoning_effort": {
      "description": "Vendor-neutral reasoning control, converted to provider-specific parameters. Note: thinking cannot be disabled on models that always think (e.g. Kimi K3); on those, \"none\" maps to the provider's lowest thinking budget.",
      "type": "string",
      "enum": [
        "none",
        "minimal",
        "low",
        "medium",
        "high",
        "xhigh",
        "max"
      ]
    },
    "thinking": {
      "description": "Moonshot/Kimi K2-specific parameter to control reasoning. When type is \"disabled\", the model returns only final content without chain-of-thought. Not supported by Kimi K3, which always thinks — use reasoning_effort instead.",
      "type": "object",
      "properties": {
        "type": {
          "type": "string",
          "enum": [
            "disabled",
            "enabled",
            "adaptive"
          ],
          "description": "Reasoning behavior. Use \"disabled\" to get clean final content (no chain-of-thought)."
        }
      },
      "required": [
        "type"
      ]
    },
    "json_mode": {
      "description": "DEPRECATED: Use response_format instead.",
      "type": "boolean"
    },
    "function_call": {
      "description": "DEPRECATED: Use tool_choice instead. Controls how the model uses functions. Will be auto-converted to tool_choice format.",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "auto",
            "none"
          ]
        },
        {
          "type": "object",
          "properties": {
            "name": {
              "type": "string",
              "description": "The name of the function to call"
            }
          },
          "required": [
            "name"
          ]
        }
      ]
    },
    "functions": {
      "description": "DEPRECATED: Use tools instead. List of functions the model may generate JSON for. Will be auto-converted to tools format.",
      "type": "array",
      "items": {}
    },
    "modalities": {
      "description": "Output modalities",
      "type": "array",
      "items": {
        "type": "string",
        "enum": [
          "text",
          "audio"
        ]
      }
    },
    "audio": {
      "description": "Audio output settings",
      "type": "object",
      "properties": {
        "voice": {
          "type": "string"
        },
        "format": {
          "type": "string"
        }
      },
      "required": [
        "voice",
        "format"
      ]
    },
    "tools": {
      "description": "List of tools available to the model",
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "function"
            ]
          },
          "function": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "parameters": {
                "type": "object",
                "additionalProperties": {}
              },
              "strict": {
                "type": "boolean"
              }
            },
            "required": [
              "name"
            ]
          }
        },
        "required": [
          "type",
          "function"
        ]
      }
    },
    "tool_choice": {
      "description": "Tool selection strategy",
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "none",
            "auto",
            "required"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "function"
              ]
            },
            "function": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                }
              },
              "required": [
                "name"
              ]
            }
          },
          "required": [
            "type",
            "function"
          ]
        }
      ]
    },
    "parallel_tool_calls": {
      "default": true,
      "description": "Allow parallel tool calls",
      "type": "boolean"
    },
    "response_format": {
      "description": "Desired response format",
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "text"
              ]
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "json_object"
              ]
            }
          },
          "required": [
            "type"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "json_schema"
              ]
            },
            "json_schema": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string"
                },
                "description": {
                  "type": "string"
                },
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "strict": {
                  "type": "boolean"
                }
              },
              "required": [
                "name",
                "schema"
              ]
            }
          },
          "required": [
            "type",
            "json_schema"
          ]
        }
      ]
    },
    "stream_options": {
      "description": "Streaming options",
      "type": "object",
      "properties": {
        "include_usage": {
          "description": "Include usage in streaming chunks",
          "type": "boolean"
        }
      }
    },
    "service_tier": {
      "description": "Service tier preference",
      "type": "string",
      "enum": [
        "auto",
        "default"
      ]
    },
    "user": {
      "description": "End-user identifier for rate limiting",
      "type": "string"
    },
    "min_p": {
      "description": "Min-p sampling (vLLM & SGLang only)",
      "type": "number"
    },
    "repetition_penalty": {
      "description": "Repetition penalty (vLLM & SGLang only)",
      "type": "number"
    },
    "stop_token_ids": {
      "description": "Token ids that stop generation (vLLM & SGLang only)",
      "type": "array",
      "items": {
        "type": "integer",
        "minimum": -9007199254740991,
        "maximum": 9007199254740991
      }
    }
  },
  "required": [
    "model",
    "messages"
  ],
  "additionalProperties": {}
}