{
  "openapi": "3.1.0",
  "info": {
    "title": "Sautna API",
    "version": "1.0.0",
    "description": "Sudanese Arabic text-to-speech. One endpoint: send text with your API key, receive audio. Docs: https://sautna.com/docs",
    "contact": { "email": "hello@sautna.com" }
  },
  "servers": [{ "url": "https://sautna.com" }],
  "paths": {
    "/api/v1/tts": {
      "post": {
        "summary": "Synthesize speech",
        "operationId": "synthesize",
        "security": [{ "bearerAuth": [] }],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "required": ["text"],
                "properties": {
                  "text": {
                    "type": "string",
                    "description": "Arabic text to speak. Per-request length depends on your plan (1,000–3,000 chars)."
                  },
                  "voice": {
                    "type": "string",
                    "enum": ["zol", "zola"],
                    "default": "zol",
                    "description": "zol (male) or zola (female)."
                  },
                  "format": {
                    "type": "string",
                    "enum": ["wav", "mp3", "opus", "ulaw_8000", "pcm"],
                    "default": "wav",
                    "description": "Output encoding. ulaw_8000 is 8 kHz μ-law for telephony; pcm is headerless 24 kHz s16le. Ignored when stream is true."
                  },
                  "stream": {
                    "type": "boolean",
                    "default": false,
                    "description": "true streams raw 24 kHz s16le mono PCM, one chunk per rendered sentence — recommended for anything interactive."
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Audio. Headers: X-Characters-Billed, X-Quota-Remaining, X-RateLimit-Limit, X-RateLimit-Remaining, X-Cache (HIT/MISS); streaming adds X-Sample-Rate and X-Audio-Format.",
            "content": {
              "audio/wav": { "schema": { "type": "string", "format": "binary" } },
              "audio/mpeg": { "schema": { "type": "string", "format": "binary" } },
              "audio/ogg": { "schema": { "type": "string", "format": "binary" } },
              "application/octet-stream": { "schema": { "type": "string", "format": "binary" } }
            }
          },
          "400": { "$ref": "#/components/responses/Error" },
          "401": { "$ref": "#/components/responses/Error" },
          "402": { "$ref": "#/components/responses/Error" },
          "403": { "$ref": "#/components/responses/Error" },
          "404": { "$ref": "#/components/responses/Error" },
          "413": { "$ref": "#/components/responses/Error" },
          "429": {
            "description": "Rate limited — respect Retry-After (seconds).",
            "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
          },
          "502": { "$ref": "#/components/responses/Error" }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key from https://sautna.com/dashboard/keys — `Authorization: Bearer sautna_sk_...`"
      }
    },
    "schemas": {
      "Error": {
        "type": "object",
        "properties": {
          "error": {
            "type": "object",
            "properties": { "code": { "type": "string" }, "message": { "type": "string" } }
          }
        }
      }
    },
    "responses": {
      "Error": {
        "description": "Error — see error.code and error.message.",
        "content": { "application/json": { "schema": { "$ref": "#/components/schemas/Error" } } }
      }
    }
  }
}
