{
  "openapi": "3.1.0",
  "info": {
    "title": "Brainiall AI Gateway API",
    "version": "1.0.0",
    "description": "OpenAI-compatible API gateway providing 104 AI models (Claude 4.7, GPT-5, Gemini 3, Llama 4, DeepSeek, Mistral, Qwen) at $5.99/mo flat. Multi-modal: 60 chat + 12 image + 5 video + 6 audio models. EU-hosted (Frankfurt+Madrid), GDPR Art 28 DPA + AI Act Art 50 compliant.",
    "contact": {
      "name": "Fabio Suizu",
      "email": "fabiosuizu@gmail.com",
      "url": "https://chat.brainiall.com"
    },
    "license": {
      "name": "Commercial — chat.brainiall.com/terms",
      "url": "https://chat.brainiall.com/terms"
    },
    "termsOfService": "https://chat.brainiall.com/terms"
  },
  "servers": [
    {
      "url": "https://api.brainiall.com/v1",
      "description": "Production API (EU-hosted Frankfurt+Madrid)"
    }
  ],
  "tags": [
    {"name": "Chat", "description": "Chat completions (Claude, GPT, Gemini, Llama, etc)"},
    {"name": "Images", "description": "Image generation (gpt-5-image, Flux 2, Seedream)"},
    {"name": "Videos", "description": "Video generation (Seedance 2.0, Veo)"},
    {"name": "Audio", "description": "TTS, STT, voice cloning, voice translate"},
    {"name": "Embeddings", "description": "Embeddings for RAG (1k, 3k dimensions)"},
    {"name": "Models", "description": "Model catalog and capabilities"},
    {"name": "Moderations", "description": "Content moderation (Claude Haiku classifier)"}
  ],
  "paths": {
    "/chat/completions": {
      "post": {
        "tags": ["Chat"],
        "summary": "Create chat completion (OpenAI-compatible)",
        "description": "Drop-in replacement for OpenAI /v1/chat/completions. Supports streaming, tool calls, JSON mode. 60 chat models available.",
        "security": [{"bearerAuth": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {"$ref": "#/components/schemas/ChatCompletionRequest"}
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful chat completion",
            "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ChatCompletionResponse"}}}
          },
          "401": {"description": "Unauthorized — invalid api_key"},
          "429": {"description": "Rate limit — upgrade plan or wait"}
        }
      }
    },
    "/models": {
      "get": {
        "tags": ["Models"],
        "summary": "List available models",
        "description": "Returns catalog of 104 models with capabilities, pricing tier, context window.",
        "responses": {
          "200": {
            "description": "Model catalog",
            "content": {"application/json": {"schema": {"$ref": "#/components/schemas/ModelList"}}}
          }
        }
      }
    },
    "/images/generations": {
      "post": {
        "tags": ["Images"],
        "summary": "Generate images (12 models)",
        "security": [{"bearerAuth": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["model", "prompt"],
                "properties": {
                  "model": {"type": "string", "example": "gpt-5-image"},
                  "prompt": {"type": "string", "example": "Sunset over mountains"},
                  "n": {"type": "integer", "default": 1},
                  "size": {"type": "string", "default": "1024x1024", "enum": ["256x256", "512x512", "1024x1024", "1792x1024", "1024x1792"]},
                  "quality": {"type": "string", "enum": ["standard", "hd"]}
                }
              }
            }
          }
        },
        "responses": {"200": {"description": "Image URLs returned"}}
      }
    },
    "/videos/generations": {
      "post": {
        "tags": ["Videos"],
        "summary": "Generate videos (Seedance 2.0, Veo) — async",
        "security": [{"bearerAuth": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["model", "prompt"],
                "properties": {
                  "model": {"type": "string", "example": "seedance-2.0"},
                  "prompt": {"type": "string", "example": "Person walking on beach at sunset"},
                  "duration": {"type": "integer", "default": 5, "maximum": 10}
                }
              }
            }
          }
        },
        "responses": {
          "200": {"description": "Job ID returned (polling required for completion)"},
          "202": {"description": "Video generation queued"}
        }
      }
    },
    "/audio/speech": {
      "post": {
        "tags": ["Audio"],
        "summary": "Text-to-speech (Brainiall TTS, voice cloning)",
        "security": [{"bearerAuth": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["model", "voice", "input"],
                "properties": {
                  "model": {"type": "string", "example": "brainiall-tts"},
                  "voice": {"type": "string", "example": "alloy"},
                  "input": {"type": "string", "example": "Hello world"},
                  "response_format": {"type": "string", "default": "mp3", "enum": ["mp3", "opus", "aac", "flac", "wav"]}
                }
              }
            }
          }
        },
        "responses": {"200": {"description": "Audio binary stream", "content": {"audio/mpeg": {}}}}
      }
    },
    "/audio/transcriptions": {
      "post": {
        "tags": ["Audio"],
        "summary": "Speech-to-text (Whisper-large-v3, 99+ languages)",
        "security": [{"bearerAuth": []}],
        "responses": {"200": {"description": "Transcript JSON"}}
      }
    },
    "/audio/translations": {
      "post": {
        "tags": ["Audio"],
        "summary": "Voice translate (keep original voice)",
        "description": "Translate audio between languages while preserving the original voice characteristics. 9 target languages supported.",
        "security": [{"bearerAuth": []}],
        "responses": {"200": {"description": "Translated audio binary"}}
      }
    },
    "/embeddings": {
      "post": {
        "tags": ["Embeddings"],
        "summary": "Generate embeddings (1k or 3k dimensions)",
        "security": [{"bearerAuth": []}],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["model", "input"],
                "properties": {
                  "model": {"type": "string", "example": "brainiall-embeddings-1k"},
                  "input": {"type": "string", "example": "Embed this text for RAG"}
                }
              }
            }
          }
        },
        "responses": {"200": {"description": "Embedding vector"}}
      }
    },
    "/moderations": {
      "post": {
        "tags": ["Moderations"],
        "summary": "Content moderation (Claude Haiku classifier)",
        "security": [{"bearerAuth": []}],
        "requestBody": {
          "required": true,
          "content": {"application/json": {"schema": {"type": "object", "properties": {"input": {"type": "string"}}}}}
        },
        "responses": {"200": {"description": "Moderation flags + categories"}}
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API Key (brnl-...)",
        "description": "Get your API key at https://chat.brainiall.com/api"
      }
    },
    "schemas": {
      "ChatCompletionRequest": {
        "type": "object",
        "required": ["model", "messages"],
        "properties": {
          "model": {
            "type": "string",
            "example": "claude-sonnet-4-7",
            "description": "Any of 60+ chat models. See /models for full catalog."
          },
          "messages": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "role": {"type": "string", "enum": ["system", "user", "assistant", "tool"]},
                "content": {"type": "string"}
              }
            }
          },
          "temperature": {"type": "number", "default": 1, "minimum": 0, "maximum": 2},
          "max_tokens": {"type": "integer"},
          "stream": {"type": "boolean", "default": false},
          "tools": {"type": "array", "description": "OpenAI function-calling tool definitions"},
          "response_format": {"type": "object", "description": "JSON mode etc"}
        }
      },
      "ChatCompletionResponse": {
        "type": "object",
        "properties": {
          "id": {"type": "string"},
          "object": {"type": "string", "enum": ["chat.completion"]},
          "created": {"type": "integer"},
          "model": {"type": "string"},
          "choices": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "index": {"type": "integer"},
                "message": {"type": "object"},
                "finish_reason": {"type": "string"}
              }
            }
          },
          "usage": {
            "type": "object",
            "properties": {
              "prompt_tokens": {"type": "integer"},
              "completion_tokens": {"type": "integer"},
              "total_tokens": {"type": "integer"}
            }
          }
        }
      },
      "ModelList": {
        "type": "object",
        "properties": {
          "object": {"type": "string", "enum": ["list"]},
          "data": {
            "type": "array",
            "items": {
              "type": "object",
              "properties": {
                "id": {"type": "string", "example": "claude-sonnet-4-7"},
                "object": {"type": "string", "enum": ["model"]},
                "owned_by": {"type": "string"},
                "context_window": {"type": "integer"}
              }
            }
          }
        }
      }
    }
  },
  "externalDocs": {
    "description": "Full documentation",
    "url": "https://chat.brainiall.com/api"
  },
  "x-brainiall-extensions": {
    "pricing-model": "flat-rate",
    "pricing-tiers": [
      {"name": "Pro", "price_usd": 5.99, "description": "Chat unlimited (fair-use ~10k req/day)"},
      {"name": "Pro Team", "price_usd": 99, "description": "50k req/day, priority support, DPA"},
      {"name": "Business", "price_usd": 499, "description": "500k req/day, custom SLA, dedicated support"}
    ],
    "compliance": ["GDPR-Article-28", "AI-Act-Article-50", "DPDP", "APPI", "CCPA", "LGPD"],
    "hosting": ["Frankfurt-EU", "Madrid-EU"],
    "free-trial": "7 days, no credit card required"
  }
}
