{
  "$schema": "https://json-schema.org/draft/2020-12/schema",
  "$id": "https://artifacts.apis.io/ninjachat-ai/json-schema/ninjachat-ai-anthropic-messages-request-schema.json",
  "title": "AnthropicMessagesRequest",
  "x-generated": "2026-11-19",
  "x-method": "derived",
  "x-generator": "derive-json-schema.py",
  "x-source": "openapi/ninjachat-ai-openapi.json#/components/schemas/AnthropicMessagesRequest",
  "type": "object",
  "properties": {
    "model": {
      "type": "string",
      "minLength": 1,
      "maxLength": 160
    },
    "max_tokens": {
      "type": "integer",
      "exclusiveMinimum": 0,
      "maximum": 9007199254740991
    },
    "messages": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "user",
              "assistant"
            ]
          },
          "content": {
            "anyOf": [
              {
                "type": "string",
                "minLength": 1,
                "maxLength": 100000
              },
              {
                "type": "array",
                "items": {
                  "anyOf": [
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "text"
                          ]
                        },
                        "text": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 100000
                        }
                      },
                      "required": [
                        "type",
                        "text"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "image"
                          ]
                        },
                        "source": {
                          "oneOf": [
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "url"
                                  ]
                                },
                                "url": {
                                  "type": "string",
                                  "format": "uri"
                                }
                              },
                              "required": [
                                "type",
                                "url"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "base64"
                                  ]
                                },
                                "media_type": {
                                  "type": "string",
                                  "enum": [
                                    "image/jpeg",
                                    "image/png",
                                    "image/gif",
                                    "image/webp"
                                  ]
                                },
                                "data": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 7000000
                                }
                              },
                              "required": [
                                "type",
                                "media_type",
                                "data"
                              ],
                              "additionalProperties": false
                            }
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "source"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "document"
                          ]
                        },
                        "source": {
                          "oneOf": [
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "base64"
                                  ]
                                },
                                "media_type": {
                                  "type": "string",
                                  "enum": [
                                    "application/pdf"
                                  ]
                                },
                                "data": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 7000000
                                }
                              },
                              "required": [
                                "type",
                                "media_type",
                                "data"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "url"
                                  ]
                                },
                                "url": {
                                  "type": "string",
                                  "maxLength": 4096,
                                  "format": "uri"
                                }
                              },
                              "required": [
                                "type",
                                "url"
                              ],
                              "additionalProperties": false
                            },
                            {
                              "type": "object",
                              "properties": {
                                "type": {
                                  "type": "string",
                                  "enum": [
                                    "text"
                                  ]
                                },
                                "media_type": {
                                  "type": "string",
                                  "enum": [
                                    "text/plain"
                                  ]
                                },
                                "data": {
                                  "type": "string",
                                  "minLength": 1,
                                  "maxLength": 100000
                                }
                              },
                              "required": [
                                "type",
                                "media_type",
                                "data"
                              ],
                              "additionalProperties": false
                            }
                          ]
                        }
                      },
                      "required": [
                        "type",
                        "source"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "tool_use"
                          ]
                        },
                        "id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128
                        },
                        "name": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 64
                        },
                        "input": {
                          "type": "object",
                          "additionalProperties": {}
                        }
                      },
                      "required": [
                        "type",
                        "id",
                        "name",
                        "input"
                      ],
                      "additionalProperties": false
                    },
                    {
                      "type": "object",
                      "properties": {
                        "type": {
                          "type": "string",
                          "enum": [
                            "tool_result"
                          ]
                        },
                        "tool_use_id": {
                          "type": "string",
                          "minLength": 1,
                          "maxLength": 128
                        },
                        "content": {
                          "anyOf": [
                            {
                              "type": "string"
                            },
                            {
                              "type": "array",
                              "items": {
                                "anyOf": [
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "text"
                                        ]
                                      },
                                      "text": {
                                        "type": "string",
                                        "minLength": 1,
                                        "maxLength": 100000
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "text"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "image"
                                        ]
                                      },
                                      "source": {
                                        "oneOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "url"
                                                ]
                                              },
                                              "url": {
                                                "type": "string",
                                                "format": "uri"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "url"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "base64"
                                                ]
                                              },
                                              "media_type": {
                                                "type": "string",
                                                "enum": [
                                                  "image/jpeg",
                                                  "image/png",
                                                  "image/gif",
                                                  "image/webp"
                                                ]
                                              },
                                              "data": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 7000000
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "media_type",
                                              "data"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "source"
                                    ],
                                    "additionalProperties": false
                                  },
                                  {
                                    "type": "object",
                                    "properties": {
                                      "type": {
                                        "type": "string",
                                        "enum": [
                                          "document"
                                        ]
                                      },
                                      "source": {
                                        "oneOf": [
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "base64"
                                                ]
                                              },
                                              "media_type": {
                                                "type": "string",
                                                "enum": [
                                                  "application/pdf"
                                                ]
                                              },
                                              "data": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 7000000
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "media_type",
                                              "data"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "url"
                                                ]
                                              },
                                              "url": {
                                                "type": "string",
                                                "maxLength": 4096,
                                                "format": "uri"
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "url"
                                            ],
                                            "additionalProperties": false
                                          },
                                          {
                                            "type": "object",
                                            "properties": {
                                              "type": {
                                                "type": "string",
                                                "enum": [
                                                  "text"
                                                ]
                                              },
                                              "media_type": {
                                                "type": "string",
                                                "enum": [
                                                  "text/plain"
                                                ]
                                              },
                                              "data": {
                                                "type": "string",
                                                "minLength": 1,
                                                "maxLength": 100000
                                              }
                                            },
                                            "required": [
                                              "type",
                                              "media_type",
                                              "data"
                                            ],
                                            "additionalProperties": false
                                          }
                                        ]
                                      }
                                    },
                                    "required": [
                                      "type",
                                      "source"
                                    ],
                                    "additionalProperties": false
                                  }
                                ]
                              }
                            }
                          ]
                        },
                        "is_error": {
                          "type": "boolean"
                        }
                      },
                      "required": [
                        "type",
                        "tool_use_id"
                      ],
                      "additionalProperties": false
                    }
                  ]
                },
                "minItems": 1,
                "maxItems": 100
              }
            ]
          }
        },
        "required": [
          "role",
          "content"
        ],
        "additionalProperties": false
      },
      "minItems": 1,
      "maxItems": 100
    },
    "system": {
      "anyOf": [
        {
          "type": "string"
        },
        {
          "type": "array",
          "items": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "text"
                ]
              },
              "text": {
                "type": "string",
                "minLength": 1,
                "maxLength": 100000
              }
            },
            "required": [
              "type",
              "text"
            ],
            "additionalProperties": false
          }
        }
      ]
    },
    "stream": {
      "type": "boolean"
    },
    "temperature": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "top_p": {
      "type": "number",
      "minimum": 0,
      "maximum": 1
    },
    "stop_sequences": {
      "type": "array",
      "items": {
        "type": "string"
      },
      "maxItems": 4
    },
    "tools": {
      "type": "array",
      "items": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "minLength": 1,
            "maxLength": 64
          },
          "description": {
            "type": "string",
            "maxLength": 1024
          },
          "input_schema": {
            "type": "object",
            "additionalProperties": {}
          },
          "strict": {
            "type": "boolean"
          }
        },
        "required": [
          "name",
          "input_schema"
        ],
        "additionalProperties": false
      },
      "maxItems": 32
    },
    "tool_choice": {
      "anyOf": [
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "auto",
                "any",
                "none"
              ]
            },
            "disable_parallel_tool_use": {
              "type": "boolean"
            }
          },
          "required": [
            "type"
          ],
          "additionalProperties": false
        },
        {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "tool"
              ]
            },
            "name": {
              "type": "string"
            },
            "disable_parallel_tool_use": {
              "type": "boolean"
            }
          },
          "required": [
            "type",
            "name"
          ],
          "additionalProperties": false
        }
      ]
    },
    "metadata": {
      "type": "object",
      "properties": {
        "user_id": {
          "type": "string",
          "maxLength": 256
        }
      },
      "additionalProperties": false
    },
    "output_config": {
      "type": "object",
      "properties": {
        "format": {
          "type": "object",
          "properties": {
            "type": {
              "type": "string",
              "enum": [
                "json_schema"
              ]
            },
            "schema": {
              "type": "object",
              "additionalProperties": {}
            }
          },
          "required": [
            "type",
            "schema"
          ],
          "additionalProperties": false
        }
      },
      "required": [
        "format"
      ],
      "additionalProperties": false
    },
    "routing": {
      "$ref": "#/$defs/RoutingPolicy"
    }
  },
  "required": [
    "model",
    "max_tokens",
    "messages"
  ],
  "additionalProperties": false,
  "$defs": {
    "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
    }
  }
}