{
  "openapi": "3.1.0",
  "info": {
    "title": "UltraGPT API",
    "version": "2026-10-02",
    "description": "OpenAI- and Anthropic-compatible API for every model on UltraGPT. Billed per request from your prepaid credit balance. Docs: https://developers.ultragpt.pro/docs"
  },
  "servers": [
    {
      "url": "https://api.ultragpt.pro/v1"
    }
  ],
  "security": [
    {
      "bearer": []
    },
    {
      "apiKey": []
    }
  ],
  "components": {
    "securitySchemes": {
      "bearer": {
        "type": "http",
        "scheme": "bearer",
        "description": "ugpt_live_... / ugpt_test_..."
      },
      "apiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key"
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string",
          "maxLength": 255
        }
      },
      "XTitle": {
        "name": "X-Title",
        "in": "header",
        "required": false,
        "schema": {
          "type": "string"
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error",
        "content": {
          "application/json": {
            "schema": {
              "type": "object",
              "required": [
                "error"
              ],
              "properties": {
                "error": {
                  "type": "object",
                  "required": [
                    "message",
                    "type"
                  ],
                  "properties": {
                    "message": {
                      "type": "string"
                    },
                    "type": {
                      "type": "string"
                    },
                    "code": {
                      "type": [
                        "string",
                        "null"
                      ]
                    },
                    "param": {
                      "type": [
                        "string",
                        "null"
                      ]
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "schemas": {
      "KeyLimits": {
        "type": "object",
        "properties": {
          "limit": {
            "type": [
              "number",
              "null"
            ]
          },
          "limit_reset": {
            "type": [
              "string",
              "null"
            ],
            "enum": [
              "daily",
              "weekly",
              "monthly",
              "never",
              null
            ]
          },
          "limit_remaining": {
            "type": [
              "number",
              "null"
            ]
          },
          "limit_resets_at": {
            "type": [
              "string",
              "null"
            ],
            "format": "date-time"
          },
          "usage": {
            "type": [
              "number",
              "null"
            ],
            "description": "Lifetime spend (USD)"
          },
          "usage_daily": {
            "type": [
              "number",
              "null"
            ]
          },
          "usage_weekly": {
            "type": [
              "number",
              "null"
            ]
          },
          "usage_monthly": {
            "type": [
              "number",
              "null"
            ]
          }
        }
      },
      "Video": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string",
            "example": "video_66f..."
          },
          "object": {
            "type": "string",
            "enum": [
              "video"
            ]
          },
          "model": {
            "type": "string"
          },
          "status": {
            "type": "string",
            "enum": [
              "queued",
              "in_progress",
              "completed",
              "failed",
              "cancelled"
            ]
          },
          "progress": {
            "type": "integer"
          },
          "created_at": {
            "type": "integer"
          },
          "completed_at": {
            "type": [
              "integer",
              "null"
            ]
          },
          "prompt": {
            "type": "string"
          },
          "seconds": {
            "type": "string"
          },
          "aspect_ratio": {
            "type": "string"
          },
          "resolution": {
            "type": [
              "string",
              "null"
            ]
          },
          "error": {
            "type": [
              "object",
              "null"
            ],
            "properties": {
              "code": {
                "type": "string"
              },
              "message": {
                "type": "string"
              }
            }
          },
          "url": {
            "type": [
              "string",
              "null"
            ],
            "description": "Direct MP4 URL once completed"
          },
          "thumbnail_url": {
            "type": [
              "string",
              "null"
            ]
          },
          "usage": {
            "type": "object",
            "properties": {
              "cost": {
                "type": "number"
              },
              "estimated_cost": {
                "type": "number"
              }
            }
          }
        }
      }
    }
  },
  "paths": {
    "/chat/completions": {
      "post": {
        "summary": "Create a chat completion",
        "tags": [
          "Chat"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "description": "Model id; append :online for web search"
                  },
                  "models": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "stream_options": {
                    "type": "object"
                  },
                  "max_tokens": {
                    "type": "integer"
                  },
                  "max_completion_tokens": {
                    "type": "integer"
                  },
                  "temperature": {
                    "type": "number"
                  },
                  "top_p": {
                    "type": "number"
                  },
                  "top_k": {
                    "type": "integer"
                  },
                  "stop": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "seed": {
                    "type": "integer"
                  },
                  "presence_penalty": {
                    "type": "number"
                  },
                  "frequency_penalty": {
                    "type": "number"
                  },
                  "tools": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "tool_choice": {},
                  "parallel_tool_calls": {
                    "type": "boolean"
                  },
                  "response_format": {
                    "type": "object"
                  },
                  "reasoning": {
                    "type": "object"
                  },
                  "reasoning_effort": {
                    "type": "string"
                  },
                  "plugins": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "provider": {
                    "type": "object"
                  },
                  "user": {
                    "type": "string"
                  }
                }
              }
            }
          }
        },
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          },
          {
            "$ref": "#/components/parameters/XTitle"
          }
        ]
      }
    },
    "/messages": {
      "post": {
        "summary": "Create a message (Anthropic Messages API)",
        "tags": [
          "Chat"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "max_tokens",
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "max_tokens": {
                    "type": "integer"
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "system": {},
                  "tools": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "tool_choice": {
                    "type": "object"
                  },
                  "thinking": {
                    "type": "object"
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "temperature": {
                    "type": "number"
                  },
                  "top_p": {
                    "type": "number"
                  },
                  "top_k": {
                    "type": "integer"
                  },
                  "stop_sequences": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "metadata": {
                    "type": "object"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/messages/count_tokens": {
      "post": {
        "summary": "Estimate prompt tokens",
        "tags": [
          "Chat"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "messages"
                ],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "messages": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "system": {},
                  "tools": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/responses": {
      "post": {
        "summary": "Create a response (OpenAI Responses API)",
        "tags": [
          "Chat"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "input"
                ],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "input": {},
                  "instructions": {
                    "type": "string"
                  },
                  "previous_response_id": {
                    "type": "string"
                  },
                  "store": {
                    "type": "boolean"
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "max_output_tokens": {
                    "type": "integer"
                  },
                  "tools": {
                    "type": "array",
                    "items": {
                      "type": "object"
                    }
                  },
                  "tool_choice": {},
                  "text": {
                    "type": "object"
                  },
                  "reasoning": {
                    "type": "object"
                  },
                  "temperature": {
                    "type": "number"
                  },
                  "top_p": {
                    "type": "number"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/responses/{id}": {
      "get": {
        "summary": "Retrieve a stored response",
        "tags": [
          "Chat"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "delete": {
        "summary": "Delete a stored response",
        "tags": [
          "Chat"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/responses/{id}/input_items": {
      "get": {
        "summary": "List a response's input items",
        "tags": [
          "Chat"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/completions": {
      "post": {
        "summary": "Create a text completion (legacy)",
        "tags": [
          "Chat"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "max_tokens": {
                    "type": "integer"
                  },
                  "stream": {
                    "type": "boolean"
                  },
                  "echo": {
                    "type": "boolean"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/embeddings": {
      "post": {
        "summary": "Create embeddings",
        "tags": [
          "Embeddings"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "input"
                ],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "input": {},
                  "dimensions": {
                    "type": "integer"
                  },
                  "encoding_format": {
                    "enum": [
                      "float",
                      "base64"
                    ]
                  }
                }
              }
            }
          }
        }
      }
    },
    "/images/generations": {
      "post": {
        "summary": "Generate images",
        "tags": [
          "Images"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "n": {
                    "type": "integer"
                  },
                  "size": {
                    "type": "string"
                  },
                  "quality": {
                    "type": "string"
                  },
                  "response_format": {
                    "enum": [
                      "b64_json",
                      "url"
                    ]
                  },
                  "image": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                }
              }
            }
          }
        }
      }
    },
    "/audio/speech": {
      "post": {
        "summary": "Text to speech",
        "tags": [
          "Audio"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "input"
                ],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "input": {
                    "type": "string"
                  },
                  "voice": {
                    "type": "string"
                  },
                  "response_format": {
                    "enum": [
                      "mp3",
                      "opus",
                      "aac",
                      "flac",
                      "wav",
                      "pcm"
                    ]
                  },
                  "speed": {
                    "type": "number"
                  },
                  "instructions": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/audio/transcriptions": {
      "post": {
        "summary": "Speech to text",
        "tags": [
          "Audio"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "model"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "model": {
                    "type": "string"
                  },
                  "language": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string"
                  },
                  "response_format": {
                    "type": "string"
                  },
                  "temperature": {
                    "type": "number"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/audio/translations": {
      "post": {
        "summary": "Translate speech to English text",
        "tags": [
          "Audio"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "model"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "model": {
                    "type": "string"
                  }
                }
              }
            }
          }
        }
      }
    },
    "/files": {
      "post": {
        "summary": "Upload a batch input file",
        "tags": [
          "Batch"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "file",
                  "purpose"
                ],
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary"
                  },
                  "purpose": {
                    "enum": [
                      "batch"
                    ]
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List files",
        "tags": [
          "Batch"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/files/{id}": {
      "get": {
        "summary": "Retrieve a file",
        "tags": [
          "Batch"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "delete": {
        "summary": "Delete a file",
        "tags": [
          "Batch"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/files/{id}/content": {
      "get": {
        "summary": "Download a file's content",
        "tags": [
          "Batch"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/batches": {
      "post": {
        "summary": "Create a batch",
        "tags": [
          "Batch"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "input_file_id",
                  "endpoint"
                ],
                "properties": {
                  "input_file_id": {
                    "type": "string"
                  },
                  "endpoint": {
                    "enum": [
                      "/v1/chat/completions",
                      "/v1/embeddings"
                    ]
                  },
                  "completion_window": {
                    "enum": [
                      "24h"
                    ]
                  },
                  "metadata": {
                    "type": "object"
                  }
                }
              }
            }
          }
        }
      },
      "get": {
        "summary": "List batches",
        "tags": [
          "Batch"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "after",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/batches/{id}": {
      "get": {
        "summary": "Retrieve a batch",
        "tags": [
          "Batch"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/batches/{id}/cancel": {
      "post": {
        "summary": "Cancel a batch",
        "tags": [
          "Batch"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/models": {
      "get": {
        "summary": "List models",
        "tags": [
          "Models"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "supported_parameters",
            "in": "query",
            "required": false,
            "description": "Comma-separated, all must match (e.g. tools,reasoning)",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "input_modalities",
            "in": "query",
            "required": false,
            "description": "Comma-separated",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "output_modalities",
            "in": "query",
            "required": false,
            "description": "Comma-separated",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/models/{id}": {
      "get": {
        "summary": "Retrieve a model",
        "tags": [
          "Models"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/key": {
      "get": {
        "summary": "The calling key",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "data": {
                      "allOf": [
                        {
                          "$ref": "#/components/schemas/KeyLimits"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "id": {
                              "type": "string"
                            },
                            "name": {
                              "type": "string"
                            },
                            "scope": {
                              "type": "string"
                            },
                            "rate_limit": {
                              "type": "object",
                              "properties": {
                                "requests_per_minute": {
                                  "type": "integer"
                                },
                                "tokens_per_minute": {
                                  "type": "integer"
                                },
                                "concurrent_requests": {
                                  "type": "integer"
                                }
                              }
                            }
                          }
                        }
                      ]
                    }
                  }
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "description": "Limits (requests and tokens per minute, spend limit) and spend per period of the calling key."
      }
    },
    "/credits": {
      "get": {
        "summary": "Credit balance",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/generation": {
      "get": {
        "summary": "Stats and cost of one request",
        "tags": [
          "Account"
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/rerank": {
      "post": {
        "summary": "Rerank documents",
        "description": "Order documents by relevance to a query (Cohere-compatible). Billed per search unit.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "query": {
                    "type": "string"
                  },
                  "documents": {
                    "type": "array",
                    "items": {
                      "oneOf": [
                        {
                          "type": "string"
                        },
                        {
                          "type": "object",
                          "properties": {
                            "text": {
                              "type": "string"
                            }
                          },
                          "required": []
                        }
                      ]
                    }
                  },
                  "top_n": {
                    "type": "integer"
                  },
                  "return_documents": {
                    "type": "boolean"
                  }
                },
                "required": [
                  "model",
                  "query",
                  "documents"
                ]
              }
            }
          }
        }
      }
    },
    "/moderations": {
      "post": {
        "summary": "Create moderation",
        "description": "Classify text / image input for harmful content (OpenAI shape). Free.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "input": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      }
                    ]
                  }
                },
                "required": [
                  "input"
                ]
              }
            }
          }
        }
      }
    },
    "/search": {
      "post": {
        "summary": "Web search",
        "description": "Standalone web search; pass the engine in search_tool_name. Billed per query.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "search_tool_name": {
                    "type": "string"
                  },
                  "max_results": {
                    "type": "integer"
                  },
                  "search_domain_filter": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "country": {
                    "type": "string"
                  },
                  "max_tokens_per_page": {
                    "type": "integer"
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        }
      }
    },
    "/search/{engine}": {
      "post": {
        "summary": "Web search with an engine",
        "description": "Standalone web search on one engine (GET /models?type=search lists them).",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "query": {
                    "oneOf": [
                      {
                        "type": "string"
                      },
                      {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      }
                    ]
                  },
                  "search_tool_name": {
                    "type": "string"
                  },
                  "max_results": {
                    "type": "integer"
                  },
                  "search_domain_filter": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "country": {
                    "type": "string"
                  },
                  "max_tokens_per_page": {
                    "type": "integer"
                  }
                },
                "required": [
                  "query"
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "name": "engine",
            "in": "path",
            "required": true,
            "description": "Search engine model id, e.g. tavily-search",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/models/count": {
      "get": {
        "summary": "Count models",
        "description": "Number of models /models returns for the same filters.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "parameters": [
          {
            "name": "type",
            "in": "query",
            "required": false,
            "description": "Model type",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "supported_parameters",
            "in": "query",
            "required": false,
            "description": "Comma-separated",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "input_modalities",
            "in": "query",
            "required": false,
            "description": "Comma-separated",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "output_modalities",
            "in": "query",
            "required": false,
            "description": "Comma-separated",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/presets": {
      "get": {
        "summary": "List presets",
        "description": "Presets of the key's workspace. Use as model \"@preset/{slug}\".",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "summary": "Create preset",
        "description": "Management keys only.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "slug": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "config": {
                    "type": "object",
                    "properties": {
                      "model": {
                        "type": "string"
                      },
                      "models": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "system_prompt": {
                        "type": "string"
                      },
                      "params": {
                        "type": "object"
                      },
                      "provider": {
                        "type": "object"
                      },
                      "reasoning": {
                        "type": "object"
                      },
                      "plugins": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      },
                      "tools": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      },
                      "cache": {
                        "type": "object",
                        "properties": {
                          "enabled": {
                            "type": "boolean"
                          },
                          "ttl_seconds": {
                            "type": "integer"
                          }
                        },
                        "required": []
                      }
                    },
                    "required": []
                  }
                },
                "required": [
                  "slug"
                ]
              }
            }
          }
        }
      }
    },
    "/presets/{slug}": {
      "get": {
        "summary": "Get preset",
        "description": "With version history.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Preset slug",
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Update preset",
        "description": "Management keys only; a config change creates a new version.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "slug": {
                    "type": "string"
                  },
                  "name": {
                    "type": "string"
                  },
                  "description": {
                    "type": "string"
                  },
                  "config": {
                    "type": "object",
                    "properties": {
                      "model": {
                        "type": "string"
                      },
                      "models": {
                        "type": "array",
                        "items": {
                          "type": "string"
                        }
                      },
                      "system_prompt": {
                        "type": "string"
                      },
                      "params": {
                        "type": "object"
                      },
                      "provider": {
                        "type": "object"
                      },
                      "reasoning": {
                        "type": "object"
                      },
                      "plugins": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      },
                      "tools": {
                        "type": "array",
                        "items": {
                          "type": "object"
                        }
                      },
                      "cache": {
                        "type": "object",
                        "properties": {
                          "enabled": {
                            "type": "boolean"
                          },
                          "ttl_seconds": {
                            "type": "integer"
                          }
                        },
                        "required": []
                      }
                    },
                    "required": []
                  }
                },
                "required": [
                  "slug"
                ]
              }
            }
          }
        },
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Preset slug",
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "delete": {
        "summary": "Delete preset",
        "description": "Management keys only.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "parameters": [
          {
            "name": "slug",
            "in": "path",
            "required": true,
            "description": "Preset slug",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/keys": {
      "get": {
        "summary": "List keys",
        "description": "Management keys only: keys of the workspace with monthly usage and remaining limit.",
        "responses": {
          "200": {
            "description": "OK"
          }
        }
      },
      "post": {
        "summary": "Create key",
        "description": "Management keys only. `limit` + `limit_reset` set a spend limit per day, ISO week, month or lifetime. The key string is returned once.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "project": {
                    "type": "string"
                  },
                  "environment": {
                    "type": "string",
                    "enum": [
                      "live",
                      "test"
                    ]
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "full",
                      "read_only"
                    ]
                  },
                  "limit": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Spend limit in USD per limit_reset period."
                  },
                  "allowed_models": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "allowed_ips": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "allowed_referrers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "rpm_limit": {
                    "type": "integer"
                  },
                  "expires_in_days": {
                    "type": "integer"
                  },
                  "limit_reset": {
                    "type": "string",
                    "enum": [
                      "daily",
                      "weekly",
                      "monthly",
                      "never"
                    ],
                    "description": "When the spend limit starts over (default monthly). never = a lifetime budget."
                  },
                  "tpm_limit": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Tokens per minute; can only lower the default."
                  }
                },
                "required": []
              }
            }
          }
        }
      }
    },
    "/keys/{id}": {
      "get": {
        "summary": "Get key",
        "description": "Management keys only.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Key id",
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "patch": {
        "summary": "Update key",
        "description": "Management keys only.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "name": {
                    "type": "string"
                  },
                  "project": {
                    "type": "string"
                  },
                  "environment": {
                    "type": "string",
                    "enum": [
                      "live",
                      "test"
                    ]
                  },
                  "scope": {
                    "type": "string",
                    "enum": [
                      "full",
                      "read_only"
                    ]
                  },
                  "limit": {
                    "type": [
                      "number",
                      "null"
                    ],
                    "description": "Spend limit in USD per limit_reset period."
                  },
                  "allowed_models": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "allowed_ips": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "allowed_referrers": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  },
                  "rpm_limit": {
                    "type": "integer"
                  },
                  "expires_in_days": {
                    "type": "integer"
                  },
                  "limit_reset": {
                    "type": "string",
                    "enum": [
                      "daily",
                      "weekly",
                      "monthly",
                      "never"
                    ],
                    "description": "When the spend limit starts over (default monthly). never = a lifetime budget."
                  },
                  "tpm_limit": {
                    "type": [
                      "integer",
                      "null"
                    ],
                    "description": "Tokens per minute; can only lower the default."
                  }
                },
                "required": []
              }
            }
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Key id",
            "schema": {
              "type": "string"
            }
          }
        ]
      },
      "delete": {
        "summary": "Revoke key",
        "description": "Management keys only.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "description": "Key id",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/activity": {
      "get": {
        "summary": "Activity",
        "description": "Daily usage per model and endpoint over the last 30 days.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "parameters": [
          {
            "name": "date",
            "in": "query",
            "required": false,
            "description": "YYYY-MM-DD",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "key_id",
            "in": "query",
            "required": false,
            "description": "Management keys: one key",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "user",
            "in": "query",
            "required": false,
            "description": "End user (user / safety_identifier)",
            "schema": {
              "type": "string"
            }
          }
        ]
      }
    },
    "/generations/lookup": {
      "post": {
        "summary": "Look up generations",
        "description": "Stats and billed cost of up to 1000 requests by id. Read-only keys allowed.",
        "responses": {
          "200": {
            "description": "OK"
          }
        },
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "properties": {
                  "ids": {
                    "type": "array",
                    "items": {
                      "type": "string"
                    }
                  }
                },
                "required": [
                  "ids"
                ]
              }
            }
          }
        }
      }
    },
    "/videos": {
      "post": {
        "summary": "Create a video",
        "tags": [
          "Videos"
        ],
        "description": "Starts an asynchronous text- or image-to-video job. Billed the provider cost when it completes; failed clips are free.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "prompt"
                ],
                "properties": {
                  "model": {
                    "type": "string"
                  },
                  "prompt": {
                    "type": "string",
                    "maxLength": 4000
                  },
                  "seconds": {
                    "oneOf": [
                      {
                        "type": "integer"
                      },
                      {
                        "type": "string"
                      }
                    ],
                    "description": "Clip length; see the model's video.durations"
                  },
                  "aspect_ratio": {
                    "type": "string",
                    "example": "16:9"
                  },
                  "size": {
                    "type": "string",
                    "example": "1280x720",
                    "description": "Alternative to aspect_ratio"
                  },
                  "resolution": {
                    "type": "string"
                  },
                  "image_url": {
                    "type": "string",
                    "format": "uri",
                    "description": "Public https first frame (models with image input)"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "The queued video",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Video"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "get": {
        "summary": "List videos",
        "tags": [
          "Videos"
        ],
        "parameters": [
          {
            "name": "limit",
            "in": "query",
            "schema": {
              "type": "integer",
              "maximum": 100
            }
          },
          {
            "name": "after",
            "in": "query",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "object": {
                      "type": "string"
                    },
                    "data": {
                      "type": "array",
                      "items": {
                        "$ref": "#/components/schemas/Video"
                      }
                    },
                    "has_more": {
                      "type": "boolean"
                    }
                  }
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/videos/{id}": {
      "get": {
        "summary": "Retrieve a video",
        "tags": [
          "Videos"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Video"
                }
              }
            }
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      },
      "delete": {
        "summary": "Delete a video",
        "tags": [
          "Videos"
        ],
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK"
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/videos/{id}/content": {
      "get": {
        "summary": "Download a video",
        "tags": [
          "Videos"
        ],
        "description": "302 redirect to the MP4 (or the poster with ?variant=thumbnail). 409 video_not_ready until completed.",
        "parameters": [
          {
            "name": "id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "variant",
            "in": "query",
            "schema": {
              "type": "string",
              "enum": [
                "thumbnail"
              ]
            }
          }
        ],
        "responses": {
          "302": {
            "description": "Redirect to the file"
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    },
    "/realtime": {
      "get": {
        "summary": "Realtime session (WebSocket)",
        "tags": [
          "Realtime"
        ],
        "description": "Upgrade to a WebSocket (wss://api.ultragpt.pro/v1/realtime?model=<id>) and speak the OpenAI Realtime protocol. Auth: Authorization header, or the subprotocol `openai-insecure-api-key.<key>` from browsers. Each response.done is billed from upstream usage. Sessions end after 60 minutes, 10 idle minutes or when funds run out (close code 1008).",
        "parameters": [
          {
            "name": "model",
            "in": "query",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "101": {
            "description": "Switching protocols"
          },
          "4XX": {
            "$ref": "#/components/responses/Error"
          },
          "5XX": {
            "$ref": "#/components/responses/Error"
          }
        }
      }
    }
  }
}