{
  "openapi": "3.1.0",
  "info": {
    "title": "LLMTR Gateway API",
    "version": "1.0.0",
    "description": "Public LLMTR gateway and anonymous model-discovery API. Model-specific capabilities remain discoverable through GET /v1/models.",
    "license": {
      "name": "LLMTR Terms of Service",
      "url": "https://llmtr.com/terms"
    }
  },
  "servers": [
    {
      "url": "https://llmtr.com",
      "description": "Production"
    }
  ],
  "externalDocs": {
    "description": "LLMTR API documentation",
    "url": "/docs/api-reference/openapi-postman/"
  },
  "security": [
    {
      "bearerAuth": []
    },
    {
      "apiKeyAuth": []
    }
  ],
  "tags": [
    { "name": "Text and agents", "description": "OpenAI- and Anthropic-compatible text and agent request surfaces." },
    { "name": "Images", "description": "Model-dependent image generation and editing operations." },
    { "name": "Audio", "description": "Model-dependent speech, music, and transcription operations." },
    { "name": "Retrieval", "description": "Embedding and reranking operations." },
    { "name": "Specialized operations", "description": "Research, robotics, video, and realtime session operations." },
    { "name": "Files", "description": "Reusable provider file uploads." },
    { "name": "Models", "description": "Anonymous, cacheable public model discovery." }
  ],
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "tags": ["Text and agents"],
        "operationId": "createChatCompletion",
        "summary": "Create a chat completion",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ChatCompletionRequest" },
              "example": {
                "model": "provider/model",
                "messages": [{ "role": "user", "content": "Hello" }]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Completion JSON, or an SSE stream when stream is true.",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ChatCompletionResponse" } },
              "text/event-stream": { "schema": { "type": "string" } }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "tags": ["Text and agents"],
        "operationId": "createAnthropicMessage",
        "summary": "Create an Anthropic-compatible message",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AnthropicMessagesRequest" },
              "example": {
                "model": "provider/model",
                "max_tokens": 512,
                "messages": [{ "role": "user", "content": "Hello" }]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Anthropic message JSON, or Anthropic SSE events when stream is true.",
            "content": {
              "application/json": { "schema": { "type": "object", "additionalProperties": true } },
              "text/event-stream": { "schema": { "type": "string" } }
            }
          },
          "400": { "$ref": "#/components/responses/AnthropicInvalidRequest" },
          "401": { "$ref": "#/components/responses/AnthropicAuthError" }
        }
      }
    },
    "/v1/responses": {
      "post": {
        "tags": ["Text and agents"],
        "operationId": "createResponse",
        "summary": "Create an OpenAI-compatible response",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ResponsesRequest" },
              "example": { "model": "provider/model", "input": "Explain this briefly." }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Response JSON, or an SSE stream when supported and stream is true.",
            "content": {
              "application/json": { "schema": { "type": "object", "additionalProperties": true } },
              "text/event-stream": { "schema": { "type": "string" } }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/images/generations": {
      "post": {
        "tags": ["Images"],
        "operationId": "createImage",
        "summary": "Generate images",
        "description": "Optional controls and reference-image fields depend on the selected model. Check supported_operations and supported_endpoints in model discovery.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ImageGenerationRequest" },
              "example": { "model": "provider/model", "prompt": "A geometric poster" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/images/edits": {
      "post": {
        "tags": ["Images"],
        "operationId": "editImage",
        "summary": "Edit images",
        "description": "This endpoint accepts JSON image references. Availability is model-specific.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ImageEditRequest" },
              "example": {
                "model": "provider/model",
                "prompt": "Keep the composition and change the background color.",
                "image": "https://example.com/input.png"
              }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/audio/speech": {
      "post": {
        "tags": ["Audio"],
        "operationId": "createSpeech",
        "summary": "Generate speech audio",
        "description": "Voice and output details are model-specific. Successful calls normally return raw audio bytes.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AudioSpeechRequest" },
              "example": { "model": "provider/model", "input": "Hello from LLMTR." }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated audio bytes. A JSON envelope is retained for transports that do not return bytes.",
            "content": {
              "audio/mpeg": { "schema": { "type": "string", "contentEncoding": "binary" } },
              "audio/wav": { "schema": { "type": "string", "contentEncoding": "binary" } },
              "audio/ogg": { "schema": { "type": "string", "contentEncoding": "binary" } },
              "audio/aac": { "schema": { "type": "string", "contentEncoding": "binary" } },
              "audio/flac": { "schema": { "type": "string", "contentEncoding": "binary" } },
              "application/json": { "schema": { "type": "object", "additionalProperties": true } }
            }
          },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/audio/music": {
      "post": {
        "tags": ["Audio"],
        "operationId": "createMusic",
        "summary": "Generate music",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AudioMusicRequest" },
              "example": { "model": "provider/model", "input": "A short instrumental theme" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/research/runs": {
      "post": {
        "tags": ["Specialized operations"],
        "operationId": "createResearchRun",
        "summary": "Run a research task",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/ResearchRunRequest" },
              "example": { "model": "provider/model", "input": "Research the topic and cite sources." }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/audio/transcriptions": {
      "post": {
        "tags": ["Audio"],
        "operationId": "createTranscription",
        "summary": "Transcribe audio",
        "description": "The current gateway wire format is JSON with audio_base64 or file_id.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/AudioTranscriptionRequest" },
              "example": { "model": "provider/model", "file_id": "file_PLACEHOLDER" }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/robotics/sessions": {
      "post": {
        "tags": ["Specialized operations"],
        "operationId": "createRoboticsSession",
        "summary": "Create a robotics planning session",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RoboticsSessionRequest" },
              "example": { "model": "provider/model", "input": { "instruction": "Inspect the workspace." } }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/embeddings": {
      "post": {
        "tags": ["Retrieval"],
        "operationId": "createEmbeddings",
        "summary": "Create embeddings",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/EmbeddingsRequest" },
              "example": { "model": "provider/model", "input": ["First document", "Second document"] }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/rerank": {
      "post": {
        "tags": ["Retrieval"],
        "operationId": "rerankDocuments",
        "summary": "Rerank documents",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RerankRequest" },
              "example": {
                "model": "provider/model",
                "query": "Which document is relevant?",
                "documents": ["Candidate A", "Candidate B"]
              }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/video/generations": {
      "post": {
        "tags": ["Specialized operations"],
        "operationId": "createVideo",
        "summary": "Generate video",
        "description": "Reference-media types, durations and resolutions are model-specific.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/VideoGenerationRequest" },
              "example": { "model": "provider/model", "prompt": "A calm abstract animation", "duration_seconds": 5 }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/realtime/sessions": {
      "post": {
        "tags": ["Specialized operations"],
        "operationId": "createRealtimeSession",
        "summary": "Create a signed realtime session",
        "description": "Returns a signed WebSocket URL; this HTTP endpoint is not itself a WebSocket connection.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": { "$ref": "#/components/schemas/RealtimeSessionRequest" },
              "example": { "model": "provider/model", "max_duration_seconds": 300, "max_budget_usd": 1 }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/files": {
      "post": {
        "tags": ["Files"],
        "operationId": "uploadFile",
        "summary": "Upload a reusable provider file",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": { "$ref": "#/components/schemas/FileUploadMultipart" }
            },
            "application/json": {
              "schema": { "$ref": "#/components/schemas/FileUploadJson" },
              "example": {
                "filename": "document.txt",
                "mime_type": "text/plain",
                "purpose": "user_upload",
                "content_base64": "BASE64_CONTENT"
              }
            }
          }
        },
        "responses": {
          "200": { "$ref": "#/components/responses/JsonSuccess" },
          "400": { "$ref": "#/components/responses/InvalidRequest" },
          "401": { "$ref": "#/components/responses/AuthError" }
        }
      }
    },
    "/v1/models": {
      "get": {
        "tags": ["Models"],
        "operationId": "listModels",
        "summary": "List public models",
        "description": "Anonymous, cacheable model discovery. Use supported_endpoints and supported_parameters before selecting a model.",
        "security": [],
        "parameters": [
          {
            "name": "supported_parameters",
            "in": "query",
            "required": false,
            "description": "Comma-separated parameters that every returned model must support.",
            "schema": { "type": "string" },
            "example": "tools,reasoning"
          }
        ],
        "responses": {
          "200": {
            "description": "Public model list",
            "headers": {
              "ETag": { "schema": { "type": "string" }, "description": "Cache validator" }
            },
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ModelList" } }
            }
          },
          "429": { "$ref": "#/components/responses/RateLimited" }
        }
      }
    },
    "/v1/models/{provider}/{model}": {
      "get": {
        "tags": ["Models"],
        "operationId": "getModel",
        "summary": "Get one public model",
        "security": [],
        "parameters": [
          { "$ref": "#/components/parameters/ProviderPath" },
          { "$ref": "#/components/parameters/ModelPath" }
        ],
        "responses": {
          "200": {
            "description": "Public model card",
            "content": {
              "application/json": { "schema": { "$ref": "#/components/schemas/ModelCard" } }
            }
          },
          "404": { "$ref": "#/components/responses/NotFound" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "LLMTR API key",
        "description": "Send the LLMTR API key as Authorization: Bearer <key>."
      },
      "apiKeyAuth": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Alternative header used by Anthropic-compatible clients."
      }
    },
    "parameters": {
      "ProviderPath": {
        "name": "provider",
        "in": "path",
        "required": true,
        "description": "Provider segment of the canonical model ID.",
        "schema": { "type": "string", "minLength": 1 },
        "example": "provider"
      },
      "ModelPath": {
        "name": "model",
        "in": "path",
        "required": true,
        "description": "Model segment of the canonical model ID.",
        "schema": { "type": "string", "minLength": 1 },
        "example": "model"
      }
    },
    "responses": {
      "JsonSuccess": {
        "description": "Successful JSON response. Fields vary by operation and selected model.",
        "content": {
          "application/json": { "schema": { "type": "object", "additionalProperties": true } }
        }
      },
      "InvalidRequest": {
        "description": "Invalid request or unsupported operation",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } }
        }
      },
      "AuthError": {
        "description": "Missing or invalid API key",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } }
        }
      },
      "NotFound": {
        "description": "Resource not found",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } }
        }
      },
      "AnthropicInvalidRequest": {
        "description": "Invalid Anthropic-compatible request",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/AnthropicErrorEnvelope" } }
        }
      },
      "AnthropicAuthError": {
        "description": "Missing or invalid API key in Anthropic error format",
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/AnthropicErrorEnvelope" } }
        }
      },
      "RateLimited": {
        "description": "Anonymous discovery rate limit exceeded",
        "headers": {
          "Retry-After": {
            "description": "Seconds until the client may retry.",
            "schema": { "type": "integer", "minimum": 1 }
          }
        },
        "content": {
          "application/json": { "schema": { "$ref": "#/components/schemas/ErrorEnvelope" } }
        }
      }
    },
    "schemas": {
      "ModelId": {
        "type": "string",
        "minLength": 1,
        "description": "Canonical provider/model identifier. Discover current values with GET /v1/models.",
        "example": "provider/model"
      },
      "ChatMessage": {
        "type": "object",
        "required": ["role"],
        "properties": {
          "role": { "type": "string", "enum": ["system", "user", "assistant", "tool"] },
          "content": {
            "oneOf": [
              { "type": "string" },
              { "type": "array", "items": { "type": "object", "additionalProperties": true } },
              { "type": "null" }
            ]
          },
          "tool_calls": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
          "tool_call_id": { "type": "string" },
          "name": { "type": "string" }
        },
        "additionalProperties": true
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": ["model", "messages"],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "messages": { "type": "array", "minItems": 1, "items": { "$ref": "#/components/schemas/ChatMessage" } },
          "temperature": { "type": "number", "minimum": 0, "maximum": 2 },
          "top_p": { "type": "number", "minimum": 0, "maximum": 1 },
          "max_tokens": { "type": "integer", "minimum": 1 },
          "max_completion_tokens": { "type": "integer", "minimum": 1 },
          "stream": { "type": "boolean", "default": false },
          "stream_options": { "type": "object", "properties": { "include_usage": { "type": "boolean" } }, "additionalProperties": true },
          "tools": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
          "tool_choice": {},
          "parallel_tool_calls": { "type": "boolean" }
        },
        "additionalProperties": true
      },
      "ChatCompletionResponse": {
        "type": "object",
        "required": ["id", "object", "created", "model", "choices", "usage"],
        "properties": {
          "id": { "type": "string" },
          "object": { "const": "chat.completion" },
          "created": { "type": "integer" },
          "model": { "type": "string" },
          "choices": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
          "usage": { "type": "object", "additionalProperties": true },
          "citations": { "type": "array", "items": { "type": "string", "format": "uri" } }
        },
        "additionalProperties": true
      },
      "AnthropicMessagesRequest": {
        "type": "object",
        "required": ["model", "messages", "max_tokens"],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "messages": {
            "type": "array",
            "minItems": 1,
            "items": {
              "type": "object",
              "required": ["role", "content"],
              "properties": {
                "role": { "type": "string", "enum": ["user", "assistant", "system"] },
                "content": {
                  "oneOf": [
                    { "type": "string" },
                    { "type": "array", "items": { "type": "object", "additionalProperties": true } }
                  ]
                }
              }
            }
          },
          "max_tokens": { "type": "integer", "minimum": 1 },
          "system": {},
          "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" } },
          "tools": { "type": "array", "items": { "type": "object", "additionalProperties": true } },
          "tool_choice": { "type": "object", "additionalProperties": true }
        },
        "additionalProperties": true
      },
      "ResponsesRequest": {
        "type": "object",
        "required": ["model"],
        "anyOf": [
          { "required": ["input"] },
          { "required": ["messages"] }
        ],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "input": {},
          "messages": { "type": "array", "items": { "$ref": "#/components/schemas/ChatMessage" } },
          "instructions": { "type": "string" },
          "modalities": { "type": "array", "maxItems": 1, "items": { "type": "string", "enum": ["text", "image", "audio", "video", "document"] } },
          "temperature": { "type": "number", "minimum": 0, "maximum": 2 },
          "top_p": { "type": "number", "minimum": 0, "maximum": 1 },
          "max_output_tokens": { "type": "integer", "minimum": 1 },
          "stream": { "type": "boolean", "default": false },
          "store": { "type": "boolean" },
          "background": { "type": "boolean" },
          "service_tier": { "type": "string", "enum": ["standard", "flex", "priority"] },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 },
          "reasoning": {
            "type": "object",
            "properties": {
              "effort": { "type": "string", "enum": ["none", "minimal", "low", "medium", "high", "xhigh", "max"] },
              "summary": { "type": "string", "enum": ["auto", "concise", "detailed"] },
              "mode": { "type": "string" }
            },
            "additionalProperties": true
          },
          "speech_config": { "type": "object", "additionalProperties": true },
          "image_config": { "type": "object", "additionalProperties": true }
        },
        "additionalProperties": true
      },
      "ImageGenerationRequest": {
        "type": "object",
        "required": ["model", "prompt"],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "prompt": { "type": "string", "minLength": 1 },
          "image_url": { "type": "string" },
          "image_urls": { "type": "array", "items": { "type": "string" } },
          "file_id": { "type": "string" },
          "file_ids": { "type": "array", "items": { "type": "string" } },
          "n": { "type": "integer", "minimum": 1, "maximum": 6 },
          "size": { "type": "string" },
          "resolution": { "type": "string", "enum": ["1k", "2k", "1K", "2K"] },
          "aspect_ratio": { "type": "string" },
          "quality": { "type": "string", "enum": ["low", "medium", "high"] },
          "creativity": { "type": "string", "enum": ["raw", "low", "medium", "high"] },
          "seed": { "type": "integer" },
          "output_format": { "type": "string", "enum": ["png", "jpeg", "webp"] },
          "response_format": { "type": "string", "enum": ["url", "b64_json"] },
          "background": { "type": "string", "enum": ["opaque", "auto", "transparent"] },
          "mask": { "type": "string" },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 }
        },
        "additionalProperties": true
      },
      "ImageEditInput": {
        "anyOf": [
          { "type": "string", "format": "uri" },
          { "type": "object", "required": ["url"], "properties": { "url": { "type": "string", "format": "uri" } } },
          { "type": "object", "required": ["type", "url"], "properties": { "type": { "const": "image_url" }, "url": { "type": "string", "format": "uri" } } }
        ]
      },
      "ImageEditRequest": {
        "type": "object",
        "required": ["model", "prompt"],
        "anyOf": [{ "required": ["image"] }, { "required": ["images"] }],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "prompt": { "type": "string", "minLength": 1 },
          "image": { "$ref": "#/components/schemas/ImageEditInput" },
          "images": { "type": "array", "minItems": 1, "maxItems": 5, "items": { "$ref": "#/components/schemas/ImageEditInput" } },
          "aspect_ratio": { "type": "string" },
          "resolution": { "type": "string", "enum": ["1k", "2k", "1K", "2K"] },
          "response_format": { "type": "string", "enum": ["url", "b64_json"] },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 }
        },
        "additionalProperties": true
      },
      "AudioSpeechRequest": {
        "type": "object",
        "required": ["model", "input"],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "input": { "type": "string", "minLength": 1 },
          "voice": { "type": "string" },
          "language": { "type": "string" },
          "speaker": { "type": "string" },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 }
        },
        "additionalProperties": true
      },
      "AudioMusicRequest": {
        "type": "object",
        "required": ["model", "input"],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "input": { "type": "string", "minLength": 1 },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 }
        },
        "additionalProperties": true
      },
      "AudioTranscriptionRequest": {
        "type": "object",
        "required": ["model"],
        "anyOf": [{ "required": ["audio_base64"] }, { "required": ["file_id"] }],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "audio_base64": { "type": "string", "contentEncoding": "base64" },
          "audio_format": { "type": "string" },
          "file_id": { "type": "string" },
          "prompt": { "type": "string" },
          "language": { "type": "string" },
          "format": { "type": "boolean" },
          "duration_seconds": { "type": "number", "exclusiveMinimum": 0 },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 }
        },
        "additionalProperties": true
      },
      "ResearchRunRequest": {
        "type": "object",
        "required": ["model", "input"],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "input": { "oneOf": [{ "type": "string" }, { "type": "array", "items": { "$ref": "#/components/schemas/ChatMessage" } }] },
          "instructions": { "type": "string" },
          "max_output_tokens": { "type": "integer", "minimum": 1 },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 }
        },
        "additionalProperties": true
      },
      "RoboticsSessionRequest": {
        "type": "object",
        "required": ["model"],
        "anyOf": [{ "required": ["input"] }, { "required": ["messages"] }],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "input": {},
          "messages": { "type": "array", "items": { "$ref": "#/components/schemas/ChatMessage" } },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 }
        },
        "additionalProperties": true
      },
      "EmbeddingsRequest": {
        "type": "object",
        "required": ["model", "input"],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "input": {},
          "output_dimensionality": { "type": "integer", "minimum": 1 },
          "dimensions": { "type": "integer", "minimum": 1 },
          "output_dimension": { "type": "integer", "minimum": 1 },
          "input_type": { "type": "string", "enum": ["query", "document"] },
          "output_dtype": { "type": "string", "enum": ["float", "int8", "uint8", "binary", "ubinary"] },
          "truncation": { "type": "boolean" },
          "encoding_format": { "type": "string" }
        },
        "additionalProperties": true
      },
      "RerankRequest": {
        "type": "object",
        "required": ["model", "query", "documents"],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "query": { "type": "string", "minLength": 1 },
          "documents": { "type": "array", "minItems": 1, "maxItems": 1000, "items": { "type": "string", "minLength": 1 } },
          "top_k": { "type": "integer", "minimum": 1 },
          "top_n": { "type": "integer", "minimum": 1 },
          "return_documents": { "type": "boolean" },
          "truncation": { "type": "boolean" }
        },
        "additionalProperties": false
      },
      "VideoGenerationRequest": {
        "type": "object",
        "required": ["model", "duration_seconds"],
        "anyOf": [{ "required": ["prompt"] }, { "required": ["media"] }],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "prompt": { "type": "string", "minLength": 1 },
          "duration_seconds": { "type": "number", "exclusiveMinimum": 0 },
          "aspect_ratio": { "type": "string" },
          "resolution": { "type": "string" },
          "negative_prompt": { "type": "string" },
          "image_url": { "type": "string" },
          "media": {
            "type": "array",
            "minItems": 1,
            "maxItems": 8,
            "items": {
              "type": "object",
              "required": ["type", "url"],
              "properties": { "type": { "type": "string" }, "url": { "type": "string" } }
            }
          },
          "max_wait_seconds": { "type": "integer", "minimum": 1 },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 }
        },
        "additionalProperties": true
      },
      "RealtimeSessionRequest": {
        "type": "object",
        "required": ["model", "max_duration_seconds", "max_budget_usd"],
        "properties": {
          "model": { "$ref": "#/components/schemas/ModelId" },
          "max_duration_seconds": { "type": "number", "exclusiveMinimum": 0, "maximum": 3600 },
          "max_budget_usd": { "type": "number", "exclusiveMinimum": 0 }
        },
        "additionalProperties": true
      },
      "FileUploadMultipart": {
        "type": "object",
        "required": ["file"],
        "properties": {
          "file": { "type": "string", "contentEncoding": "binary" },
          "provider": { "type": "string", "default": "google" },
          "purpose": { "type": "string", "enum": ["user_upload", "vision_reference"], "default": "user_upload" }
        }
      },
      "FileUploadJson": {
        "type": "object",
        "required": ["content_base64"],
        "properties": {
          "content_base64": { "type": "string", "contentEncoding": "base64" },
          "filename": { "type": "string", "default": "upload.bin" },
          "mime_type": { "type": "string", "default": "application/octet-stream" },
          "provider": { "type": "string", "default": "google" },
          "purpose": { "type": "string", "enum": ["user_upload", "vision_reference"], "default": "user_upload" }
        },
        "additionalProperties": false
      },
      "ModelCard": {
        "type": "object",
        "required": ["id", "object", "created", "owned_by"],
        "properties": {
          "id": { "type": "string" },
          "object": { "const": "model" },
          "created": { "type": "integer" },
          "owned_by": { "type": "string" },
          "name": { "type": "string" },
          "description": { "type": "string" },
          "context_length": { "type": "integer" },
          "supported_operations": { "type": "array", "items": { "type": "string" } },
          "supported_endpoints": { "type": "array", "items": { "type": "string" } },
          "supported_parameters": { "type": "array", "items": { "type": "string" } },
          "architecture": { "type": "object", "additionalProperties": true },
          "pricing": { "type": "object", "additionalProperties": { "type": "string" } },
          "top_provider": { "type": "object", "additionalProperties": true },
          "reasoning": { "type": "object", "additionalProperties": true },
          "per_request_limits": { "type": ["object", "null"] }
        },
        "additionalProperties": true
      },
      "ModelList": {
        "type": "object",
        "required": ["object", "data"],
        "properties": {
          "object": { "const": "list" },
          "data": { "type": "array", "items": { "$ref": "#/components/schemas/ModelCard" } }
        }
      },
      "ErrorEnvelope": {
        "type": "object",
        "required": ["error"],
        "properties": {
          "error": {
            "type": "object",
            "required": ["message", "type"],
            "properties": {
              "message": { "type": "string" },
              "type": { "type": "string" },
              "code": { "type": ["string", "null"] },
              "details": { "type": "object", "additionalProperties": true }
            },
            "additionalProperties": true
          }
        }
      },
      "AnthropicErrorEnvelope": {
        "type": "object",
        "required": ["type", "error"],
        "properties": {
          "type": { "const": "error" },
          "error": {
            "type": "object",
            "required": ["type", "message"],
            "properties": { "type": { "type": "string" }, "message": { "type": "string" } },
            "additionalProperties": true
          }
        }
      }
    }
  }
}
