{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ninjachat-ai/json-schema/ninjachat-ai-chat-completions-request-schema.json",
  "title": "ChatCompletionsRequest",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ninjachat-ai-openapi.json#/components/schemas/ChatCompletionsRequest",
  "type": "object",
  "properties": {
    "content_filter": {
      "type": "boolean",
      "enum": [
        true
      ],
      "description": "Optional explicit acknowledgement of mandatory server-side content filtering. Only true is accepted. Filtering remains enforced when omitted; false is rejected."
    },
    "model": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "models": {
      "type": "array",
      "items": {
        "type": "string",
        "minLength": 1,
        "maxLength": 160
      },
      "minItems": 1,
      "maxItems": 15
    },
    "messages": {
      "type": "array",
      "items": {
        "oneOf": [
          {
            "type": "object",
            "properties": {
              "role": {
                "type": "string",
                "enum": [
                  "developer"
                ]
              },
              "content": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "text"
                          ]
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1
                  }
                ]
              }
            },
            "required": [
              "role",
              "content"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "role": {
                "type": "string",
                "enum": [
                  "system"
                ]
              },
              "content": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "text"
                          ]
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1
                  }
                ]
              }
            },
            "required": [
              "role",
              "content"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "role": {
                "type": "string",
                "enum": [
                  "user"
                ]
              },
              "content": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "text"
                              ]
                            },
                            "text": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "type",
                            "text"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "image_url"
                              ]
                            },
                            "image_url": {
                              "type": "object",
                              "properties": {
                                "url": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 7000000
                                },
                                "detail": {
                                  "type": "string",
                                  "enum": [
                                    "auto",
                                    "low",
                                    "high"
                                  ]
                                }
                              },
                              "required": [
                                "url"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "image_url"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "file"
                              ]
                            },
                            "file": {
                              "type": "object",
                              "properties": {
                                "filename": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 255
                                },
                                "file_data": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 7000000
                                },
                                "file_url": {
                                  "type": "string",
                                  "maxLength": 4096,
                                  "format": "uri"
                                },
                                "media_type": {
                                  "type": "string",
                                  "enum": [
                                    "application/pdf",
                                    "text/plain",
                                    "text/markdown",
                                    "text/csv",
                                    "application/json"
                                  ]
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "file"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "minItems": 1
                  }
                ]
              }
            },
            "required": [
              "role",
              "content"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "role": {
                "type": "string",
                "enum": [
                  "assistant"
                ]
              },
              "content": {
                "anyOf": [
                  {
                    "type": "string",
                    "minLength": 1
                  },
                  {
                    "type": "array",
                    "items": {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "text"
                          ]
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ],
                      "additionalProperties": false
                    },
                    "minItems": 1
                  },
                  {
                    "type": "null"
                  }
                ]
              },
              "tool_calls": {
                "type": "array",
                "items": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string",
                      "minLength": 1,
                      "maxLength": 128
                    },
                    "type": {
                      "type": "string",
                      "enum": [
                        "function"
                      ]
                    },
                    "extra_content": {
                      "type": "object",
                      "properties": {
                        "google": {
                          "type": "object",
                          "properties": {
                            "thought_signature": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "thought_signature"
                          ],
                          "additionalProperties": false
                        }
                      },
                      "additionalProperties": false
                    },
                    "function": {
                      "type": "object",
                      "properties": {
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64
                        },
                        "arguments": {
                          "type": "string"
                        }
                      },
                      "required": [
                        "name",
                        "arguments"
                      ],
                      "additionalProperties": false
                    }
                  },
                  "required": [
                    "id",
                    "type",
                    "function"
                  ],
                  "additionalProperties": false
                }
              }
            },
            "required": [
              "role"
            ],
            "additionalProperties": false
          },
          {
            "type": "object",
            "properties": {
              "role": {
                "type": "string",
                "enum": [
                  "tool"
                ]
              },
              "content": {
                "anyOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "array",
                    "items": {
                      "anyOf": [
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "text"
                              ]
                            },
                            "text": {
                              "type": "string",
                              "minLength": 1
                            }
                          },
                          "required": [
                            "type",
                            "text"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "image_url"
                              ]
                            },
                            "image_url": {
                              "type": "object",
                              "properties": {
                                "url": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 7000000
                                },
                                "detail": {
                                  "type": "string",
                                  "enum": [
                                    "auto",
                                    "low",
                                    "high"
                                  ]
                                }
                              },
                              "required": [
                                "url"
                              ],
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "image_url"
                          ],
                          "additionalProperties": false
                        },
                        {
                          "type": "object",
                          "properties": {
                            "type": {
                              "type": "string",
                              "enum": [
                                "file"
                              ]
                            },
                            "file": {
                              "type": "object",
                              "properties": {
                                "filename": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 255
                                },
                                "file_data": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 7000000
                                },
                                "file_url": {
                                  "type": "string",
                                  "maxLength": 4096,
                                  "format": "uri"
                                },
                                "media_type": {
                                  "type": "string",
                                  "enum": [
                                    "application/pdf",
                                    "text/plain",
                                    "text/markdown",
                                    "text/csv",
                                    "application/json"
                                  ]
                                }
                              },
                              "additionalProperties": false
                            }
                          },
                          "required": [
                            "type",
                            "file"
                          ],
                          "additionalProperties": false
                        }
                      ]
                    },
                    "minItems": 1
                  }
                ]
              },
              "tool_call_id": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              }
            },
            "required": [
              "role",
              "content",
              "tool_call_id"
            ],
            "additionalProperties": false
          }
        ]
      },
      "minItems": 1
    },
    "max_completion_tokens": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991,
      "description": "Maximum completion tokens, including reasoning where the provider counts it. Must fit the selected provider's output and context limits. Defaults to 2048 when omitted."
    },
    "temperature": {
      "type": "number",
      "minimum": 0,
      "maximum": 2
    },
    "top_p": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "stop": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "string"
          },
          "minItems": 1,
          "maxItems": 4
        }
      ]
    },
    "frequency_penalty": {
      "type": "number",
      "minimum": -2,
      "maximum": 2
    },
    "presence_penalty": {
      "type": "number",
      "minimum": -2,
      "maximum": 2
    },
    "seed": {
      "type": "integer"
    },
    "user": {
      "type": "string",
      "maxLength": 256
    },
    "stream": {
      "type": "boolean",
      "default": false
    },
    "stream_options": {
      "type": "object",
      "properties": {
        "include_usage": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "response_format": {
      "oneOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "text"
              ]
            }
          },
          "required": [
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "json_object"
              ]
            }
          },
          "required": [
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "json_schema"
              ]
            },
            "json_schema": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                },
                "description": {
                  "type": "string"
                },
                "schema": {
                  "type": "object",
                  "additionalProperties": {}
                },
                "strict": {
                  "type": "boolean",
                  "default": true
                }
              },
              "required": [
                "name",
                "schema"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "type",
            "json_schema"
          ],
          "additionalProperties": false
        }
      ]
    },
    "tools": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "type": {
            "type": "string",
            "enum": [
              "function"
            ]
          },
          "function": {
            "type": "object",
            "properties": {
              "name": {
                "type": "string",
                "minLength": 1,
                "maxLength": 64,
                "pattern": "^[a-zA-Z0-9_-]+$"
              },
              "description": {
                "type": "string"
              },
              "parameters": {
                "type": "object",
                "additionalProperties": {},
                "default": {}
              },
              "strict": {
                "type": "boolean"
              }
            },
            "required": [
              "name"
            ],
            "additionalProperties": false
          }
        },
        "required": [
          "type",
          "function"
        ],
        "additionalProperties": false
      }
    },
    "tool_choice": {
      "anyOf": [
        {
          "type": "string",
          "enum": [
            "none",
            "auto",
            "required"
          ]
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "function"
              ]
            },
            "function": {
              "type": "object",
              "properties": {
                "name": {
                  "type": "string",
                  "minLength": 1,
                  "maxLength": 128
                }
              },
              "required": [
                "name"
              ],
              "additionalProperties": false
            }
          },
          "required": [
            "type",
            "function"
          ],
          "additionalProperties": false
        }
      ]
    },
    "parallel_tool_calls": {
      "type": "boolean"
    },
    "reasoning": {
      "$ref": "#/$defs/ChatReasoning"
    },
    "routing": {
      "$ref": "#/$defs/RoutingPolicy"
    }
  },
  "required": [
    "messages"
  ],
  "additionalProperties": false,
  "$defs": {
    "ChatReasoning": {
      "type": "object",
      "properties": {
        "effort": {
          "type": "string",
          "enum": [
            "none",
            "minimal",
            "low",
            "medium",
            "high",
            "xhigh"
          ]
        },
        "max_tokens": {
          "type": "integer",
          "minimum": 0,
          "maximum": 9007199254740991
        },
        "enabled": {
          "type": "boolean"
        }
      },
      "additionalProperties": false
    },
    "RoutingPolicy": {
      "type": "object",
      "properties": {
        "strategy": {
          "type": "string",
          "enum": [
            "balanced",
            "cost",
            "latency",
            "quality"
          ]
        },
        "providers": {
          "type": "object",
          "properties": {
            "only": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              "minItems": 1,
              "maxItems": 20
            },
            "exclude": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              "minItems": 1,
              "maxItems": 20
            },
            "order": {
              "type": "array",
              "items": {
                "type": "string",
                "minLength": 1,
                "maxLength": 128
              },
              "minItems": 1,
              "maxItems": 20
            }
          },
          "additionalProperties": false
        },
        "allow_fallbacks": {
          "type": "boolean",
          "default": true
        },
        "require_parameters": {
          "type": "boolean",
          "default": true
        },
        "data_policy": {
          "type": "string",
          "enum": [
            "default",
            "no_training",
            "zero_retention"
          ],
          "default": "default"
        },
        "caching": {
          "type": "string",
          "enum": [
            "auto"
          ]
        },
        "max_cost_usd": {
          "type": "number",
          "exclusiveMinimum": 0,
          "maximum": 1000
        }
      },
      "additionalProperties": false
    }
  }
}