{
  "openapi": "3.1.0",
  "info": {
    "title": "Hooshi Unified API",
    "version": "1.0.0",
    "summary": "OpenAI-compatible API for 80+ AI models (GPT, Claude, Gemini, Grok, DeepSeek…), billed in Toman (IRT).",
    "description": "The Hooshi unified API mirrors the OpenAI API. Choose any model with `model = \"provider/model\"` (e.g. `openai/gpt-5.5`, `anthropic/claude-opus-5-5`, `gemini/gemini-3.1-pro-preview`, `xai/grok-4.7`). Requests are billed from the separate API wallet. Provider-native APIs (`/openai/v1`, `/anthropic`, `/gemini`, `/elevenlabs`, …) are documented at https://hooshi.ai/docs/native and are not part of this spec.\n\nHeaders: send the key as `Authorization: Bearer hk-…` (also accepted: `x-api-key`, `x-goog-api-key`, `xi-api-key`, `x-key`). Send `X-Hooshi-Identity: off` to disable the model-identity system prompt for a request.",
    "contact": {
      "name": "Hooshi support",
      "email": "support@hooshi.ai",
      "url": "https://hooshi.ai/docs"
    },
    "termsOfService": "https://hooshi.ai/terms"
  },
  "externalDocs": {
    "description": "مستندات فارسی API هوشی",
    "url": "https://hooshi.ai/docs"
  },
  "servers": [
    {
      "url": "https://api.hooshi.ai",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Models"
    },
    {
      "name": "Chat"
    },
    {
      "name": "Embeddings"
    },
    {
      "name": "Images"
    },
    {
      "name": "Audio"
    },
    {
      "name": "Account"
    }
  ],
  "paths": {
    "/v1/models": {
      "get": {
        "tags": [
          "Models"
        ],
        "operationId": "listModels",
        "summary": "List models with Toman pricing",
        "description": "Public endpoint — no API key required.",
        "security": [],
        "responses": {
          "200": {
            "description": "Model list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelList"
                }
              }
            }
          }
        }
      }
    },
    "/v1/models/{id}": {
      "get": {
        "tags": [
          "Models"
        ],
        "operationId": "retrieveModel",
        "summary": "Retrieve a model",
        "security": [],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Model id, e.g. `openai/gpt-5.5` (slashes allowed).",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Model",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "id": {
                      "type": "string"
                    },
                    "object": {
                      "const": "model"
                    },
                    "created": {
                      "type": "integer"
                    },
                    "owned_by": {
                      "type": "string"
                    }
                  },
                  "required": [
                    "id",
                    "object",
                    "created",
                    "owned_by"
                  ]
                }
              }
            }
          },
          "404": {
            "description": "Model not found"
          }
        }
      }
    },
    "/v1/chat/completions": {
      "post": {
        "tags": [
          "Chat"
        ],
        "operationId": "createChatCompletion",
        "summary": "Create a chat completion (any provider)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdentityHeader"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              },
              "example": {
                "model": "anthropic/claude-sonnet-5-5",
                "messages": [
                  {
                    "role": "user",
                    "content": "سلام!"
                  }
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Completion. With `stream: true` the body is `text/event-stream` of `chat.completion.chunk` objects terminated by `data: [DONE]`.",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletion"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string",
                  "description": "SSE lines: `data: {ChatCompletionChunk}` … `data: [DONE]`. A mid-stream failure is sent as `data: {\"error\": {…}}` followed by `data: [DONE]`."
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      }
    },
    "/v1/embeddings": {
      "post": {
        "tags": [
          "Embeddings"
        ],
        "operationId": "createEmbedding",
        "summary": "Create embeddings",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbeddingRequest"
              },
              "example": {
                "model": "openai/text-embedding-3-small",
                "input": [
                  "سلام دنیا"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Embeddings (OpenAI format)",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmbeddingResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          }
        }
      }
    },
    "/v1/images/generations": {
      "post": {
        "tags": [
          "Images"
        ],
        "operationId": "createImage",
        "summary": "Generate images (GPT Image, FLUX, Stable Image, Gemini, Grok…)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageRequest"
              },
              "example": {
                "model": "openai/gpt-image-2",
                "prompt": "a teal paper boat on a calm lake",
                "size": "1024x1024"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Images as base64 PNG",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/v1/audio/speech": {
      "post": {
        "tags": [
          "Audio"
        ],
        "operationId": "createSpeech",
        "summary": "Text to speech (OpenAI TTS, ElevenLabs)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/SpeechRequest"
              },
              "example": {
                "model": "openai/gpt-4o-mini-tts",
                "voice": "alloy",
                "input": "سلام دنیا"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "MP3 audio",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "contentMediaType": "audio/mpeg"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/v1/audio/transcriptions": {
      "post": {
        "tags": [
          "Audio"
        ],
        "operationId": "createTranscription",
        "summary": "Speech to text (GPT Transcribe, Whisper, Scribe)",
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/TranscriptionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transcription",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/TranscriptionResponse"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "404": {
            "$ref": "#/components/responses/NotFound"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "502": {
            "$ref": "#/components/responses/UpstreamError"
          },
          "422": {
            "$ref": "#/components/responses/ValidationError"
          }
        }
      }
    },
    "/v1/balance": {
      "get": {
        "tags": [
          "Account"
        ],
        "operationId": "getBalance",
        "summary": "API wallet balance (Toman)",
        "responses": {
          "200": {
            "description": "Balance",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Balance"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/usage": {
      "get": {
        "tags": [
          "Account"
        ],
        "operationId": "getUsage",
        "summary": "Daily API usage per model (all keys of the account)",
        "parameters": [
          {
            "name": "days",
            "in": "query",
            "description": "Look-back window in days (default 30, max 90).",
            "schema": {
              "type": "integer",
              "minimum": 1,
              "maximum": 90,
              "default": 30
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Usage rows",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/RateLimitLimit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/RateLimitRemaining"
              },
              "X-Request-Id": {
                "$ref": "#/components/headers/RequestId"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/UsageList"
                }
              }
            }
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          }
        }
      }
    },
    "/v1/videos": {
      "post": {
        "operationId": "createVideo",
        "summary": "Start an asynchronous text-to-video render (charged on delivery)",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "example": "xai/grok-imagine-video-1.5"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "duration": {
                    "type": "integer",
                    "default": 8
                  },
                  "aspect_ratio": {
                    "type": "string",
                    "enum": [
                      "16:9",
                      "9:16",
                      "1:1"
                    ]
                  },
                  "resolution": {
                    "type": "string",
                    "enum": [
                      "720p",
                      "1080p"
                    ]
                  }
                }
              }
            }
          }
        },
        "responses": {
          "202": {
            "description": "Render started",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Video"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient API wallet balance"
          }
        },
        "tags": [
          "Images"
        ]
      }
    },
    "/v1/videos/{id}": {
      "get": {
        "operationId": "getVideo",
        "summary": "Video render status",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Video",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Video"
                }
              }
            }
          },
          "404": {
            "description": "Not found"
          }
        },
        "tags": [
          "Images"
        ]
      }
    },
    "/v1/videos/{id}/content": {
      "get": {
        "operationId": "downloadVideo",
        "summary": "Download the finished MP4",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "MP4 file",
            "content": {
              "video/mp4": {}
            }
          },
          "404": {
            "description": "Not found or not ready"
          }
        },
        "tags": [
          "Images"
        ]
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "hk-…",
        "description": "Hooshi API key from https://hooshi.ai/console"
      }
    },
    "parameters": {
      "IdentityHeader": {
        "name": "X-Hooshi-Identity",
        "in": "header",
        "required": false,
        "description": "`off` (or `false`/`0`) disables the identity system prompt Hooshi prepends for chat models.",
        "schema": {
          "type": "string",
          "enum": [
            "off",
            "false",
            "0"
          ]
        }
      }
    },
    "headers": {
      "RateLimitLimit": {
        "description": "Requests per minute allowed for this key.",
        "schema": {
          "type": "integer"
        }
      },
      "RateLimitRemaining": {
        "description": "Requests remaining in the current 60-second window.",
        "schema": {
          "type": "integer"
        }
      },
      "RequestId": {
        "description": "Unique request id (quote it to support).",
        "schema": {
          "type": "string"
        }
      },
      "RetryAfter": {
        "description": "Seconds until the rate-limit window resets.",
        "schema": {
          "type": "integer"
        }
      }
    },
    "responses": {
      "BadRequest": {
        "description": "Invalid request (`model_required`, `invalid_request_error`)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing/invalid/disabled/expired key (`invalid_api_key`)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "`insufficient_quota` (wallet below minimum) or `spend_limit_reached` (key monthly cap)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "`ip_not_allowed` or `model_not_allowed` (type `permission_error`)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "NotFound": {
        "description": "`model_not_found`",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "ValidationError": {
        "description": "Field validation failed (Laravel validation format)",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "properties": {
                "message": {
                  "type": "string"
                },
                "errors": {
                  "type": "object",
                  "additionalProperties": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "`rate_limit_exceeded` (per-key limit; includes Retry-After) or `rate_limit_error` (upstream)",
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/RetryAfter"
          }
        },
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "UpstreamError": {
        "description": "`upstream_error` — provider failure or temporarily unavailable; retry with backoff",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "message",
              "type",
              "code"
            ],
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string",
                "enum": [
                  "invalid_request_error",
                  "invalid_api_key",
                  "insufficient_quota",
                  "spend_limit_reached",
                  "ip_not_allowed",
                  "permission_error",
                  "rate_limit_exceeded",
                  "rate_limit_error",
                  "upstream_error"
                ]
              },
              "code": {
                "type": [
                  "string",
                  "integer"
                ],
                "description": "Stable error code, e.g. model_required, model_not_found, model_not_allowed, invalid_api_key, insufficient_quota, spend_limit_reached, ip_not_allowed, rate_limit_exceeded."
              },
              "param": {
                "type": [
                  "string",
                  "null"
                ]
              }
            }
          }
        }
      },
      "Pricing": {
        "type": "object",
        "properties": {
          "currency": {
            "const": "IRT"
          },
          "unit": {
            "type": "string",
            "enum": [
              "1M_tokens",
              "1K_chars",
              "minute",
              "second",
              "image"
            ]
          },
          "input": {
            "type": "number",
            "description": "Toman per unit (per 1M input tokens for token models)"
          },
          "output": {
            "type": [
              "number",
              "null"
            ]
          },
          "cached_input": {
            "type": [
              "number",
              "null"
            ]
          }
        }
      },
      "Model": {
        "type": "object",
        "required": [
          "id",
          "object",
          "created",
          "owned_by"
        ],
        "properties": {
          "id": {
            "type": "string",
            "examples": [
              "anthropic/claude-opus-5-5"
            ]
          },
          "object": {
            "const": "model"
          },
          "created": {
            "type": "integer"
          },
          "owned_by": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "enum": [
              "chat",
              "embedding",
              "image",
              "tts",
              "stt",
              "video",
              "sound"
            ]
          },
          "context_window": {
            "type": [
              "integer",
              "null"
            ]
          },
          "max_output_tokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "capabilities": {
            "type": "array",
            "items": {
              "type": "string",
              "examples": [
                "vision",
                "tools",
                "reasoning",
                "web_search",
                "file_input",
                "flagship"
              ]
            }
          },
          "pricing": {
            "$ref": "#/components/schemas/Pricing"
          },
          "native_id": {
            "type": "string",
            "description": "Upstream model id for the native API"
          }
        }
      },
      "ModelList": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Model"
            }
          }
        }
      },
      "ContentPart": {
        "oneOf": [
          {
            "type": "object",
            "required": [
              "type",
              "text"
            ],
            "properties": {
              "type": {
                "const": "text"
              },
              "text": {
                "type": "string"
              }
            }
          },
          {
            "type": "object",
            "required": [
              "type",
              "image_url"
            ],
            "properties": {
              "type": {
                "const": "image_url"
              },
              "image_url": {
                "oneOf": [
                  {
                    "type": "string"
                  },
                  {
                    "type": "object",
                    "required": [
                      "url"
                    ],
                    "properties": {
                      "url": {
                        "type": "string",
                        "description": "https URL or data:image/…;base64,…"
                      },
                      "detail": {
                        "type": "string"
                      }
                    }
                  }
                ]
              }
            }
          },
          {
            "type": "object",
            "required": [
              "type",
              "file"
            ],
            "properties": {
              "type": {
                "const": "file"
              },
              "file": {
                "type": "object",
                "properties": {
                  "filename": {
                    "type": "string"
                  },
                  "file_data": {
                    "type": "string",
                    "description": "data:application/pdf;base64,…"
                  }
                }
              }
            }
          }
        ]
      },
      "ToolCall": {
        "type": "object",
        "required": [
          "id",
          "type",
          "function"
        ],
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "const": "function"
          },
          "function": {
            "type": "object",
            "required": [
              "name",
              "arguments"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "arguments": {
                "type": "string",
                "description": "JSON-encoded arguments"
              }
            }
          }
        }
      },
      "Message": {
        "type": "object",
        "required": [
          "role"
        ],
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "developer",
              "user",
              "assistant",
              "tool"
            ]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "$ref": "#/components/schemas/ContentPart"
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "name": {
            "type": "string"
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ToolCall"
            }
          },
          "tool_call_id": {
            "type": "string"
          }
        }
      },
      "Tool": {
        "type": "object",
        "required": [
          "type",
          "function"
        ],
        "properties": {
          "type": {
            "const": "function"
          },
          "function": {
            "type": "object",
            "required": [
              "name"
            ],
            "properties": {
              "name": {
                "type": "string"
              },
              "description": {
                "type": "string"
              },
              "parameters": {
                "type": "object",
                "description": "JSON Schema"
              },
              "strict": {
                "type": "boolean"
              }
            }
          }
        }
      },
      "ChatCompletionRequest": {
        "type": "object",
        "required": [
          "model",
          "messages"
        ],
        "properties": {
          "model": {
            "type": "string",
            "description": "`provider/model`, a bare upstream id or an alias",
            "examples": [
              "openai/gpt-5.5"
            ]
          },
          "messages": {
            "type": "array",
            "minItems": 1,
            "items": {
              "$ref": "#/components/schemas/Message"
            }
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "stream_options": {
            "type": "object",
            "properties": {
              "include_usage": {
                "type": "boolean"
              }
            }
          },
          "max_tokens": {
            "type": "integer"
          },
          "max_completion_tokens": {
            "type": "integer"
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "top_p": {
            "type": "number"
          },
          "frequency_penalty": {
            "type": "number"
          },
          "presence_penalty": {
            "type": "number"
          },
          "stop": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "seed": {
            "type": "integer"
          },
          "n": {
            "type": "integer"
          },
          "user": {
            "type": "string"
          },
          "tools": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/Tool"
            }
          },
          "tool_choice": {
            "oneOf": [
              {
                "type": "string",
                "enum": [
                  "auto",
                  "none",
                  "required"
                ]
              },
              {
                "type": "object"
              }
            ]
          },
          "parallel_tool_calls": {
            "type": "boolean"
          },
          "response_format": {
            "type": "object",
            "properties": {
              "type": {
                "type": "string",
                "enum": [
                  "text",
                  "json_object",
                  "json_schema"
                ]
              },
              "json_schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "strict": {
                    "type": "boolean"
                  },
                  "schema": {
                    "type": "object"
                  }
                }
              }
            }
          },
          "reasoning_effort": {
            "type": "string",
            "enum": [
              "none",
              "minimal",
              "low",
              "medium",
              "high",
              "xhigh",
              "max"
            ]
          },
          "web_search": {
            "type": "boolean",
            "description": "Hooshi extension: enable web search for Claude models that support it"
          },
          "web_search_options": {
            "type": "object"
          },
          "logprobs": {
            "type": "boolean"
          },
          "top_logprobs": {
            "type": "integer"
          },
          "logit_bias": {
            "type": "object"
          }
        }
      },
      "Usage": {
        "type": "object",
        "properties": {
          "prompt_tokens": {
            "type": "integer"
          },
          "completion_tokens": {
            "type": "integer"
          },
          "total_tokens": {
            "type": "integer"
          },
          "prompt_tokens_details": {
            "type": "object",
            "properties": {
              "cached_tokens": {
                "type": "integer"
              }
            }
          }
        }
      },
      "HooshiCost": {
        "type": "object",
        "description": "Charge for this request",
        "properties": {
          "model": {
            "type": "string"
          },
          "cost": {
            "type": "number",
            "description": "Toman charged from the API wallet"
          },
          "currency": {
            "const": "IRT"
          }
        }
      },
      "ChatCompletion": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "chat.completion"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "message": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "const": "assistant"
                    },
                    "content": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "tool_calls": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/ToolCall"
                      }
                    },
                    "reasoning_content": {
                      "type": "string"
                    }
                  }
                },
                "finish_reason": {
                  "type": "string",
                  "enum": [
                    "stop",
                    "length",
                    "tool_calls",
                    "content_filter"
                  ]
                },
                "logprobs": {
                  "type": [
                    "object",
                    "null"
                  ]
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          },
          "citations": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "title": {
                  "type": [
                    "string",
                    "null"
                  ]
                },
                "url": {
                  "type": "string"
                }
              }
            }
          },
          "hooshi": {
            "$ref": "#/components/schemas/HooshiCost"
          }
        }
      },
      "ChatCompletionChunk": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "const": "chat.completion.chunk"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "delta": {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": "string"
                    },
                    "content": {
                      "type": "string"
                    },
                    "reasoning_content": {
                      "type": "string"
                    },
                    "tool_calls": {
                      "type": "array",
                      "items": {
                        "type": "object"
                      }
                    }
                  }
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "EmbeddingRequest": {
        "type": "object",
        "required": [
          "model",
          "input"
        ],
        "properties": {
          "model": {
            "type": "string",
            "examples": [
              "openai/text-embedding-3-small"
            ]
          },
          "input": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "dimensions": {
            "type": "integer"
          },
          "encoding_format": {
            "type": "string",
            "enum": [
              "float",
              "base64"
            ]
          }
        }
      },
      "EmbeddingResponse": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "model": {
            "type": "string"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "object": {
                  "const": "embedding"
                },
                "index": {
                  "type": "integer"
                },
                "embedding": {
                  "oneOf": [
                    {
                      "type": "array",
                      "items": {
                        "type": "number"
                      }
                    },
                    {
                      "type": "string"
                    }
                  ]
                }
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": {
                "type": "integer"
              },
              "total_tokens": {
                "type": "integer"
              }
            }
          }
        }
      },
      "ImageRequest": {
        "type": "object",
        "required": [
          "prompt"
        ],
        "properties": {
          "model": {
            "type": "string",
            "default": "openai/gpt-image-2"
          },
          "prompt": {
            "type": "string",
            "maxLength": 32000
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 4,
            "default": 1
          },
          "size": {
            "type": "string",
            "examples": [
              "1024x1024",
              "1536x1024",
              "auto"
            ]
          },
          "quality": {
            "type": "string",
            "enum": [
              "low",
              "medium",
              "high",
              "auto"
            ]
          },
          "background": {
            "type": "string",
            "examples": [
              "transparent"
            ]
          },
          "aspect_ratio": {
            "type": "string",
            "examples": [
              "16:9",
              "1:1"
            ]
          }
        }
      },
      "ImageResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "integer"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "b64_json": {
                  "type": "string",
                  "description": "Base64 PNG"
                },
                "revised_prompt": {
                  "type": "string"
                }
              }
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "SpeechRequest": {
        "type": "object",
        "required": [
          "input",
          "voice"
        ],
        "properties": {
          "model": {
            "type": "string",
            "default": "openai/gpt-4o-mini-tts"
          },
          "input": {
            "type": "string",
            "maxLength": 10000
          },
          "voice": {
            "type": "string",
            "description": "OpenAI voice name or ElevenLabs voice_id"
          },
          "instructions": {
            "type": "string"
          },
          "speed": {
            "type": "number"
          }
        }
      },
      "TranscriptionRequest": {
        "type": "object",
        "required": [
          "file"
        ],
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "description": "Audio file, max 50 MB"
          },
          "model": {
            "type": "string",
            "default": "openai/gpt-transcribe"
          },
          "language": {
            "type": "string",
            "examples": [
              "fa"
            ]
          },
          "prompt": {
            "type": "string"
          }
        }
      },
      "TranscriptionResponse": {
        "type": "object",
        "properties": {
          "text": {
            "type": "string"
          },
          "language": {
            "type": "string"
          },
          "duration": {
            "type": "number",
            "description": "Seconds (billing basis)"
          },
          "words": {
            "type": "array",
            "items": {
              "type": "object"
            }
          }
        }
      },
      "Balance": {
        "type": "object",
        "properties": {
          "object": {
            "const": "balance"
          },
          "currency": {
            "const": "IRT"
          },
          "balance": {
            "type": "number"
          },
          "min_required": {
            "type": "number"
          }
        }
      },
      "UsageList": {
        "type": "object",
        "properties": {
          "object": {
            "const": "list"
          },
          "currency": {
            "const": "IRT"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "model": {
                  "type": "string"
                },
                "requests": {
                  "type": "integer"
                },
                "input_tokens": {
                  "type": "integer"
                },
                "output_tokens": {
                  "type": "integer"
                },
                "cost": {
                  "type": "number"
                }
              }
            }
          }
        }
      },
      "Video": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "enum": [
              "video"
            ]
          },
          "model": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "in_progress",
              "completed",
              "failed"
            ]
          },
          "seconds": {
            "type": "integer"
          },
          "aspect_ratio": {
            "type": "string"
          },
          "url": {
            "type": "string"
          },
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              }
            }
          },
          "hooshi": {
            "type": "object",
            "properties": {
              "cost": {
                "type": "number"
              },
              "currency": {
                "type": "string"
              }
            }
          }
        }
      }
    }
  }
}