{
  "openapi": "3.1.0",
  "info": {
    "title": "LLMASS API",
    "version": "2.0.0",
    "summary": "Unified OpenAI-compatible and Anthropic Messages LLM API gateway",
    "description": "One API key and pay-as-you-go balance for Claude, GPT, Gemini, DeepSeek, GLM, Kimi, Qwen, and more. Supports OpenAI-compatible endpoints under /v1, native Anthropic Messages API under /v1/messages (base URL https://llmass.arbitron.dev without /v1), speed/cost routing suffixes (@cheap, @fast, @ultrafast), prompt caching, and $0 billing on failed requests. Issue keys in https://t.me/llmassbot.",
    "contact": {
      "name": "LLMASS Bot & Support",
      "url": "https://t.me/llmassbot"
    }
  },
  "externalDocs": {
    "description": "Client setup guides and machine-readable catalog",
    "url": "https://llmass.arbitron.dev/guides"
  },
  "servers": [
    {
      "url": "https://llmass.arbitron.dev",
      "description": "Production API gateway (use https://llmass.arbitron.dev/v1 as OpenAI SDK base_url, or https://llmass.arbitron.dev as Anthropic SDK base_url)"
    }
  ],
  "tags": [
    {
      "name": "Inference",
      "description": "OpenAI-compatible and Anthropic Messages inference endpoints"
    },
    {
      "name": "Public Catalog",
      "description": "Unauthenticated live model catalog, pricing, and uptime stats"
    },
    {
      "name": "API Keys",
      "description": "Master API key management for scoped child keys"
    },
    {
      "name": "System",
      "description": "Service health check"
    }
  ],
  "components": {
    "securitySchemes": {
      "BearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "LLMASS API Key",
        "description": "API key issued by @llmassbot sent in the Authorization: Bearer <key> header."
      },
      "AnthropicApiKey": {
        "type": "apiKey",
        "in": "header",
        "name": "x-api-key",
        "description": "Anthropic SDK API key header for /v1/messages and /v1/messages/count_tokens. Authorization: Bearer is also accepted."
      }
    },
    "schemas": {
      "ModelId": {
        "type": "string",
        "description": "Catalog model slug with optional routing mode suffix: @cheap (base minimal price, default), @fast (interactive speed), or @ultrafast (minimum TTFT and highest TPS). Query /v1/models or /api/public/models for live IDs.",
        "examples": [
          "claude-opus-5-5@fast",
          "claude-sonnet-5@cheap",
          "claude-fable-5@ultrafast",
          "gpt-6.2-astra@fast",
          "glm-5.3-flash@cheap"
        ]
      },
      "ErrorResponse": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": {
              "message": {
                "type": "string"
              },
              "type": {
                "type": "string"
              },
              "code": {
                "type": [
                  "string",
                  "null"
                ]
              }
            },
            "required": [
              "message"
            ]
          }
        },
        "required": [
          "error"
        ]
      },
      "ChatMessage": {
        "type": "object",
        "properties": {
          "role": {
            "type": "string",
            "enum": [
              "system",
              "developer",
              "user",
              "assistant",
              "tool"
            ]
          },
          "content": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              },
              {
                "type": "null"
              }
            ]
          },
          "name": {
            "type": "string"
          },
          "tool_call_id": {
            "type": "string"
          },
          "tool_calls": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "required": [
          "role"
        ]
      },
      "ChatCompletionRequest": {
        "type": "object",
        "properties": {
          "model": {
            "$ref": "#/components/schemas/ModelId"
          },
          "messages": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChatMessage"
            },
            "minItems": 1
          },
          "temperature": {
            "type": "number",
            "minimum": 0,
            "maximum": 2
          },
          "top_p": {
            "type": "number",
            "minimum": 0,
            "maximum": 1
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "max_completion_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "tool_choice": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "additionalProperties": true
              }
            ]
          },
          "response_format": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "model",
          "messages"
        ]
      },
      "ChatCompletionResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "object": {
            "type": "string",
            "const": "chat.completion"
          },
          "created": {
            "type": "integer"
          },
          "model": {
            "type": "string"
          },
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {
                  "type": "integer"
                },
                "message": {
                  "$ref": "#/components/schemas/ChatMessage"
                },
                "finish_reason": {
                  "type": [
                    "string",
                    "null"
                  ]
                }
              }
            }
          },
          "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"
                  }
                },
                "additionalProperties": true
              }
            }
          }
        }
      },
      "AnthropicMessagesRequest": {
        "type": "object",
        "properties": {
          "model": {
            "$ref": "#/components/schemas/ModelId"
          },
          "max_tokens": {
            "type": "integer",
            "minimum": 1
          },
          "system": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            ]
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "role": {
                  "type": "string",
                  "enum": [
                    "user",
                    "assistant"
                  ]
                },
                "content": {
                  "oneOf": [
                    {
                      "type": "string"
                    },
                    {
                      "type": "array",
                      "items": {
                        "type": "object",
                        "additionalProperties": true
                      }
                    }
                  ]
                }
              },
              "required": [
                "role",
                "content"
              ]
            },
            "minItems": 1
          },
          "stream": {
            "type": "boolean",
            "default": false
          },
          "temperature": {
            "type": "number"
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "tool_choice": {
            "type": "object",
            "additionalProperties": true
          },
          "thinking": {
            "type": "object",
            "additionalProperties": true
          }
        },
        "required": [
          "model",
          "max_tokens",
          "messages"
        ]
      },
      "AnthropicMessagesResponse": {
        "type": "object",
        "properties": {
          "id": {
            "type": "string"
          },
          "type": {
            "type": "string",
            "const": "message"
          },
          "role": {
            "type": "string",
            "const": "assistant"
          },
          "model": {
            "type": "string"
          },
          "content": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          },
          "stop_reason": {
            "type": [
              "string",
              "null"
            ]
          },
          "usage": {
            "type": "object",
            "properties": {
              "input_tokens": {
                "type": "integer"
              },
              "output_tokens": {
                "type": "integer"
              },
              "cache_creation_input_tokens": {
                "type": "integer"
              },
              "cache_read_input_tokens": {
                "type": "integer"
              }
            }
          }
        }
      },
      "CountTokensRequest": {
        "type": "object",
        "properties": {
          "model": {
            "$ref": "#/components/schemas/ModelId"
          },
          "system": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "object",
                  "additionalProperties": true
                }
              }
            ]
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            },
            "minItems": 1
          },
          "tools": {
            "type": "array",
            "items": {
              "type": "object",
              "additionalProperties": true
            }
          }
        },
        "required": [
          "model",
          "messages"
        ]
      },
      "CountTokensResponse": {
        "type": "object",
        "properties": {
          "input_tokens": {
            "type": "integer"
          }
        },
        "required": [
          "input_tokens"
        ]
      },
      "ModelListResponse": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {
                  "type": "string"
                },
                "object": {
                  "type": "string",
                  "const": "model"
                },
                "created": {
                  "type": "integer"
                },
                "owned_by": {
                  "type": "string"
                },
                "context_window": {
                  "type": "integer"
                },
                "max_output_tokens": {
                  "type": "integer"
                },
                "routing_profile": {
                  "type": "string",
                  "enum": [
                    "cheap",
                    "fast",
                    "ultrafast"
                  ]
                }
              },
              "required": [
                "id",
                "object"
              ]
            }
          }
        },
        "required": [
          "object",
          "data"
        ]
      },
      "EmbeddingRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "description": "Embedding model slug"
          },
          "input": {
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "array",
                "items": {
                  "type": "string"
                }
              }
            ]
          },
          "encoding_format": {
            "type": "string",
            "enum": [
              "float",
              "base64"
            ]
          },
          "dimensions": {
            "type": "integer",
            "minimum": 1
          }
        },
        "required": [
          "model",
          "input"
        ]
      },
      "EmbeddingResponse": {
        "type": "object",
        "properties": {
          "object": {
            "type": "string",
            "const": "list"
          },
          "model": {
            "type": "string"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "object": {
                  "type": "string",
                  "const": "embedding"
                },
                "index": {
                  "type": "integer"
                },
                "embedding": {
                  "type": "array",
                  "items": {
                    "type": "number"
                  }
                }
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": {
                "type": "integer"
              },
              "total_tokens": {
                "type": "integer"
              }
            }
          }
        }
      },
      "ImageGenerationRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "description": "Image generation model slug (e.g. gpt-image-2)"
          },
          "prompt": {
            "type": "string",
            "description": "Text prompt describing the desired image"
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 1
          },
          "size": {
            "type": "string",
            "enum": [
              "1024x1024",
              "1536x1024",
              "1024x1536",
              "1792x1024",
              "1024x1792",
              "auto"
            ],
            "default": "1024x1024",
            "description": "Output dimensions for GPT Image models (1:1, 3:2 landscape, 2:3 portrait, 16:9 widescreen, 9:16 vertical, or auto). Omit size when passing aspect_ratio so the aspect ratio is honored directly."
          },
          "aspect_ratio": {
            "type": "string",
            "enum": [
              "1:1",
              "16:9",
              "9:16",
              "3:2",
              "2:3",
              "4:3",
              "3:4",
              "4:5",
              "5:4",
              "21:9",
              "auto"
            ],
            "description": "Optional aspect ratio (e.g. '16:9', '9:16', '3:2', '21:9'). When provided without size, forwarded directly without defaulting size to 1024x1024."
          },
          "quality": {
            "type": "string",
            "enum": [
              "standard",
              "low",
              "medium",
              "high",
              "auto"
            ],
            "default": "standard",
            "description": "Rendering quality tier (low/medium/auto map to standard pricing; high uses high tier)."
          },
          "response_format": {
            "type": "string",
            "enum": [
              "b64_json",
              "url"
            ],
            "description": "GPT Image models require 'b64_json' (defaulted automatically when omitted)."
          }
        },
        "required": [
          "model",
          "prompt"
        ]
      },
      "ImageEditRequest": {
        "type": "object",
        "properties": {
          "model": {
            "type": "string",
            "description": "Image editing model slug (e.g. gpt-image-2)"
          },
          "prompt": {
            "type": "string",
            "description": "Edit instruction for the source image"
          },
          "image": {
            "type": "string",
            "format": "binary",
            "description": "Source PNG, JPEG, or WEBP image (max 25 MB)"
          },
          "mask": {
            "type": "string",
            "format": "binary",
            "description": "Optional PNG, JPEG, or WEBP mask image (max 25 MB)"
          },
          "n": {
            "type": "integer",
            "minimum": 1,
            "maximum": 10,
            "default": 1
          },
          "size": {
            "type": "string",
            "enum": [
              "1024x1024",
              "1536x1024",
              "1024x1536",
              "1792x1024",
              "1024x1792",
              "auto"
            ],
            "default": "1024x1024"
          },
          "aspect_ratio": {
            "type": "string",
            "enum": [
              "1:1",
              "16:9",
              "9:16",
              "3:2",
              "2:3",
              "4:3",
              "3:4",
              "4:5",
              "5:4",
              "21:9",
              "auto"
            ]
          },
          "quality": {
            "type": "string",
            "enum": [
              "standard",
              "low",
              "medium",
              "high",
              "auto"
            ],
            "default": "standard"
          },
          "response_format": {
            "type": "string",
            "enum": [
              "b64_json",
              "url"
            ]
          }
        },
        "required": [
          "model",
          "prompt",
          "image"
        ]
      },
      "ImageGenerationResponse": {
        "type": "object",
        "properties": {
          "created": {
            "type": "integer"
          },
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "b64_json": {
                  "type": "string"
                },
                "url": {
                  "type": "string"
                },
                "revised_prompt": {
                  "type": "string"
                }
              }
            }
          }
        }
      },
      "RoutingProfile": {
        "type": "object",
        "properties": {
          "mode": {
            "type": "string",
            "enum": [
              "cheap",
              "fast",
              "ultrafast"
            ]
          },
          "status": {
            "type": "string",
            "enum": [
              "ready",
              "testing",
              "unavailable"
            ]
          },
          "available": {
            "type": "boolean"
          },
          "model_id": {
            "type": "string"
          },
          "price_in_per_1m": {
            "type": [
              "number",
              "null"
            ]
          },
          "price_out_per_1m": {
            "type": [
              "number",
              "null"
            ]
          },
          "price_cache_read_per_1m": {
            "type": [
              "number",
              "null"
            ]
          },
          "ttft_ms": {
            "type": [
              "number",
              "null"
            ]
          },
          "tokens_per_second": {
            "type": [
              "number",
              "null"
            ]
          },
          "protocols": {
            "type": "array",
            "items": {
              "type": "string",
              "enum": [
                "openai",
                "anthropic"
              ]
            }
          }
        }
      },
      "PublicModelItem": {
        "type": "object",
        "properties": {
          "slug": {
            "type": "string"
          },
          "display_name": {
            "type": "string"
          },
          "vendor": {
            "type": "string"
          },
          "category": {
            "type": "string"
          },
          "lifecycle": {
            "type": "string"
          },
          "context_window": {
            "type": [
              "integer",
              "null"
            ]
          },
          "max_output_tokens": {
            "type": [
              "integer",
              "null"
            ]
          },
          "supports_tools": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "supports_thinking": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "supports_vision": {
            "type": [
              "boolean",
              "null"
            ]
          },
          "price_in_per_1m": {
            "type": "number"
          },
          "price_cache_read_per_1m": {
            "type": "number"
          },
          "price_out_per_1m": {
            "type": "number"
          },
          "official_in_per_1m": {
            "type": [
              "number",
              "null"
            ]
          },
          "official_out_per_1m": {
            "type": [
              "number",
              "null"
            ]
          },
          "routing_profiles": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/RoutingProfile"
            }
          },
          "avg_ttft_ms": {
            "type": [
              "number",
              "null"
            ]
          },
          "avg_tps": {
            "type": [
              "number",
              "null"
            ]
          },
          "uptime_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "available_now": {
            "type": "boolean"
          }
        }
      },
      "PublicModelsResponse": {
        "type": "object",
        "properties": {
          "models": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicModelItem"
            }
          }
        },
        "required": [
          "models"
        ]
      },
      "PublicStatsResponse": {
        "type": "object",
        "properties": {
          "models": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/PublicModelItem"
            }
          },
          "totals": {
            "type": "object",
            "properties": {
              "calls_24h": {
                "type": "integer"
              },
              "errors_24h": {
                "type": "integer"
              },
              "probes_24h": {
                "type": "integer"
              },
              "uptime_pct": {
                "type": [
                  "number",
                  "null"
                ]
              },
              "tokens_24h": {
                "type": "integer"
              },
              "models": {
                "type": "integer"
              }
            }
          }
        },
        "required": [
          "models",
          "totals"
        ]
      },
      "PublicDailyResponse": {
        "type": "object",
        "properties": {
          "from": {
            "type": [
              "string",
              "null"
            ]
          },
          "to": {
            "type": "string"
          },
          "uptime_pct": {
            "type": [
              "number",
              "null"
            ]
          },
          "days": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "date": {
                  "type": "string",
                  "format": "date"
                },
                "uptime_pct": {
                  "type": [
                    "number",
                    "null"
                  ]
                }
              }
            }
          }
        }
      },
      "ChildKeyCreateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string",
            "description": "Human-readable label for the child key"
          },
          "rpm_limit": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1,
            "description": "Optional per-minute rate limit"
          },
          "allowed_models": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            },
            "description": "Optional allowlist of model slugs"
          }
        },
        "required": [
          "name"
        ]
      },
      "ChildKeyUpdateRequest": {
        "type": "object",
        "properties": {
          "name": {
            "type": "string"
          },
          "rpm_limit": {
            "type": [
              "integer",
              "null"
            ],
            "minimum": 1
          },
          "allowed_models": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          }
        }
      },
      "ChildKeyItem": {
        "type": "object",
        "properties": {
          "public_id": {
            "type": "string"
          },
          "name": {
            "type": "string"
          },
          "prefix": {
            "type": "string"
          },
          "rpm_limit": {
            "type": [
              "integer",
              "null"
            ]
          },
          "allowed_models": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": "string"
            }
          },
          "revoked": {
            "type": "boolean"
          },
          "created_at": {
            "type": "string",
            "format": "date-time"
          },
          "api_key": {
            "type": "string",
            "description": "Returned once on creation only."
          }
        }
      },
      "ChildKeyListResponse": {
        "type": "object",
        "properties": {
          "items": {
            "type": "array",
            "items": {
              "$ref": "#/components/schemas/ChildKeyItem"
            }
          },
          "next_cursor": {
            "type": [
              "string",
              "null"
            ]
          }
        }
      },
      "HealthResponse": {
        "type": "object",
        "properties": {
          "status": {
            "type": "string",
            "examples": [
              "ok"
            ]
          }
        }
      }
    }
  },
  "paths": {
    "/v1/chat/completions": {
      "post": {
        "tags": [
          "Inference"
        ],
        "operationId": "createChatCompletion",
        "summary": "Create a chat completion (OpenAI-compatible)",
        "description": "OpenAI-compatible chat completion endpoint supporting streaming (SSE), tool calls, reasoning, and @cheap/@fast/@ultrafast model suffixes. Failed requests are billed $0.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChatCompletionRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Chat completion response (JSON or text/event-stream when stream=true)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChatCompletionResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Invalid or missing API key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "429": {
            "description": "Rate limit exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/messages": {
      "post": {
        "tags": [
          "Inference"
        ],
        "operationId": "createAnthropicMessage",
        "summary": "Create a message (Anthropic Messages API)",
        "description": "Native Anthropic Messages API endpoint for Anthropic SDKs and Claude Code (configure base URL https://llmass.arbitron.dev without /v1). Supports streaming, prompt caching, tool calling, extended thinking, and @cheap/@fast/@ultrafast suffixes. Failed requests are billed $0.",
        "security": [
          {
            "AnthropicApiKey": []
          },
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "anthropic-version",
            "in": "header",
            "required": false,
            "schema": {
              "type": "string",
              "default": "2023-06-01"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/AnthropicMessagesRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Anthropic Message response (JSON or SSE stream when stream=true)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/AnthropicMessagesResponse"
                }
              },
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "description": "Invalid request",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "402": {
            "description": "Insufficient balance",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/messages/count_tokens": {
      "post": {
        "tags": [
          "Inference"
        ],
        "operationId": "countAnthropicMessageTokens",
        "summary": "Count input tokens for an Anthropic Messages payload",
        "security": [
          {
            "AnthropicApiKey": []
          },
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/CountTokensRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Estimated input token count",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/CountTokensResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/models": {
      "get": {
        "tags": [
          "Inference"
        ],
        "operationId": "listModels",
        "summary": "List available models (OpenAI-compatible)",
        "description": "Returns active models including speed routing profile IDs (@fast, @ultrafast where ready).",
        "security": [
          {
            "BearerAuth": []
          },
          {}
        ],
        "responses": {
          "200": {
            "description": "Model list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ModelListResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/embeddings": {
      "post": {
        "tags": [
          "Inference"
        ],
        "operationId": "createEmbedding",
        "summary": "Create vector embeddings (OpenAI-compatible)",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/EmbeddingRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Embedding vectors",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/EmbeddingResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/images/generations": {
      "post": {
        "tags": [
          "Inference"
        ],
        "operationId": "createImageGeneration",
        "summary": "Generate images (OpenAI-compatible)",
        "description": "Per-image pricing. Supports GPT Image sizes (1024x1024, 1536x1024, 1024x1536, 1792x1024, 1024x1792, auto) and aspect_ratio (1:1, 16:9, 9:16, 3:2, 2:3, 4:3, 3:4, 4:5, 5:4, 21:9, auto). GPT Image models return b64_json payloads. Avoid blind retries on ambiguous timeouts.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ImageGenerationRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Generated image payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageGenerationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters or unsupported size/aspect_ratio",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/v1/images/edits": {
      "post": {
        "tags": [
          "Inference"
        ],
        "operationId": "createImageEdit",
        "summary": "Edit images (OpenAI-compatible multipart/form-data)",
        "description": "Per-image pricing. Accepts PNG/JPEG/WEBP image (and optional mask) with GPT Image sizes or aspect_ratio. GPT Image models return b64_json payloads. Avoid blind retries on ambiguous timeouts.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/ImageEditRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Edited image payload",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ImageGenerationResponse"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters or unsupported size/aspect_ratio",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Unauthorized",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/models": {
      "get": {
        "tags": [
          "Public Catalog"
        ],
        "operationId": "getPublicModels",
        "summary": "Get live public model catalog",
        "description": "Unauthenticated JSON catalog of active models with capabilities, limits, and prices.",
        "responses": {
          "200": {
            "description": "Active models list",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicModelsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/stats": {
      "get": {
        "tags": [
          "Public Catalog"
        ],
        "operationId": "getPublicStats",
        "summary": "Get live model pricing, routing profiles, TTFT, TPS, and 24h uptime stats",
        "description": "Unauthenticated live catalog snapshot including @cheap/@fast/@ultrafast profiles, official reference prices, TTFT, and TPS.",
        "responses": {
          "200": {
            "description": "Models and 24h aggregate statistics",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicStatsResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/public/daily": {
      "get": {
        "tags": [
          "Public Catalog"
        ],
        "operationId": "getPublicDailyUptime",
        "summary": "Get daily historical availability series",
        "responses": {
          "200": {
            "description": "Daily availability cells",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/PublicDailyResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys": {
      "get": {
        "tags": [
          "API Keys"
        ],
        "operationId": "listChildKeys",
        "summary": "List child API keys owned by the master key",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "cursor",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "description": "Pagination cursor from previous response"
          }
        ],
        "responses": {
          "200": {
            "description": "Paginated list of child keys and aggregated usage",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChildKeyListResponse"
                }
              }
            }
          },
          "401": {
            "description": "Master API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "API Keys"
        ],
        "operationId": "createChildKey",
        "summary": "Create a scoped child API key",
        "description": "Requires master access enabled on your primary key in @llmassbot. Up to 20 active / 100 total child keys per master key. The secret is returned once.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChildKeyCreateRequest"
              }
            }
          }
        },
        "responses": {
          "201": {
            "description": "Created child key (includes one-time secret)",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChildKeyItem"
                }
              }
            }
          },
          "400": {
            "description": "Invalid parameters or quota exceeded",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          },
          "401": {
            "description": "Master API key required",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/api/v1/keys/{public_id}": {
      "patch": {
        "tags": [
          "API Keys"
        ],
        "operationId": "updateChildKey",
        "summary": "Update a child API key's name, RPM limit, or model allowlist",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "public_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Public identifier of the child key"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/ChildKeyUpdateRequest"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Updated child key",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChildKeyItem"
                }
              }
            }
          },
          "404": {
            "description": "Child key not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "API Keys"
        ],
        "operationId": "revokeChildKey",
        "summary": "Permanently revoke a child API key",
        "description": "Idempotent revocation. Once revoked, a child key cannot be re-enabled.",
        "security": [
          {
            "BearerAuth": []
          }
        ],
        "parameters": [
          {
            "name": "public_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            },
            "description": "Public identifier of the child key"
          }
        ],
        "responses": {
          "200": {
            "description": "Child key revoked",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ChildKeyItem"
                }
              }
            }
          },
          "404": {
            "description": "Child key not found",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/ErrorResponse"
                }
              }
            }
          }
        }
      }
    },
    "/health": {
      "get": {
        "tags": [
          "System"
        ],
        "operationId": "getHealth",
        "summary": "Gateway health status",
        "responses": {
          "200": {
            "description": "Gateway is healthy",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HealthResponse"
                }
              }
            }
          }
        }
      }
    }
  }
}