{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/llm-broker-net/json-schema/llm-broker-net-chat-completion-request-schema.json",
  "title": "ChatCompletionRequest",
  "x-generated": "2026-11-17",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/llm-broker-net-openapi.json#/components/schemas/ChatCompletionRequest",
  "properties": {
    "frequency_penalty": {
      "type": "number"
    },
    "max_completion_tokens": {
      "description": "Same as max_tokens",
      "type": "integer"
    },
    "max_tokens": {
      "type": "integer"
    },
    "messages": {
      "items": {
        "type": "object"
      },
      "type": "array"
    },
    "model": {
      "description": "Our products (james, elliot, taylor, james-direct) or any market model id from GET /api/v1/broker/models (vendor/model) — served by the cheapest eligible provider.",
      "type": "string"
    },
    "presence_penalty": {
      "type": "number"
    },
    "response_format": {
      "description": "{\"type\": \"json_object\"} or {\"type\": \"json_schema\", \"json_schema\": …}",
      "type": "object"
    },
    "routing": {
      "$ref": "#/$defs/BrokerRouting"
    },
    "seed": {
      "type": "integer"
    },
    "stop": {
      "oneOf": [
        {
          "type": "string"
        },
        {
          "items": {
            "type": "string"
          },
          "type": "array"
        }
      ]
    },
    "stream": {
      "default": false,
      "type": "boolean"
    },
    "temperature": {
      "type": "number"
    },
    "tool_choice": {
      "oneOf": [
        {
          "enum": [
            "auto",
            "none",
            "required"
          ],
          "type": "string"
        },
        {
          "type": "object"
        }
      ]
    },
    "tools": {
      "items": {
        "type": "object"
      },
      "type": "array"
    },
    "top_p": {
      "type": "number"
    }
  },
  "required": [
    "model",
    "messages"
  ],
  "type": "object",
  "$defs": {
    "BrokerRouting": {
      "description": "Narrows which offer serves the request. Never loosens product guarantees. No matching offer → 409 no_matching_offer.",
      "properties": {
        "capabilities": {
          "description": "Every chosen provider must support all of these",
          "oneOf": [
            {
              "enum": [
                "reasoning",
                "structured_output",
                "tools",
                "vision"
              ],
              "type": "string"
            },
            {
              "items": {
                "enum": [
                  "reasoning",
                  "structured_output",
                  "tools",
                  "vision"
                ],
                "type": "string"
              },
              "type": "array"
            }
          ]
        },
        "category": {
          "description": "Use case for level, min_score and sort=score|value",
          "enum": [
            "coding",
            "instruction_following",
            "math",
            "reasoning"
          ],
          "type": "string"
        },
        "family": {
          "description": "Model family: vendor (anthropic), name start (claude, qwen3) or id prefix (deepseek/deepseek-v4). New generations are included automatically.",
          "type": "string"
        },
        "level": {
          "description": "Needs category. solid/strong/top = the threshold of that level; best = only the offer with the highest measured score in category (within all other filters). Not together with min_score. Also for taylor (overrides the key's level for this request).",
          "enum": [
            "solid",
            "strong",
            "top",
            "best"
          ],
          "type": "string"
        },
        "max_price": {
          "description": "Customer price cap in CHF per 1M tokens (incl. our margin)",
          "properties": {
            "input": {
              "type": "number"
            },
            "output": {
              "type": "number"
            }
          },
          "type": "object"
        },
        "min_context": {
          "description": "Minimum context window (tokens)",
          "minimum": 1,
          "type": "integer"
        },
        "min_score": {
          "description": "Only offers whose score in category (our own measurement) is at least this",
          "maximum": 1,
          "minimum": 0,
          "type": "number"
        },
        "region": {
          "description": "Execution location of the provider (eu includes ch)",
          "oneOf": [
            {
              "enum": [
                "ch",
                "eu",
                "us",
                "asia",
                "global"
              ],
              "type": "string"
            },
            {
              "items": {
                "enum": [
                  "ch",
                  "eu",
                  "us",
                  "asia",
                  "global"
                ],
                "type": "string"
              },
              "type": "array"
            }
          ]
        },
        "sort": {
          "default": "price",
          "description": "cheapest · best score per CHF · highest throughput · highest score",
          "enum": [
            "price",
            "value",
            "speed",
            "score"
          ],
          "type": "string"
        }
      },
      "title": "BrokerRouting",
      "type": "object"
    }
  }
}