{
  "openapi": "3.1.0",
  "info": {
    "title": "mazdek AI API",
    "version": "2026-11-29",
    "description": "Complete API collection for mazdek AI — Kurdish-first speech recognition, text-to-speech, chat, translation, spell checking, video clips and songs.\n\nSetup:\n1. Import this collection into Postman\n2. Set the `api_key` variable to your API key (Settings › API › Create API Key)\n3. Optionally change `base_url` if self-hosting\n\nAuth: `Authorization: Bearer mazdek_sk_…`. Creating a key needs at least $5 of lifetime credit top-ups (or received gifts); up to 10 active keys per account.\n\nBilling: API-key requests are billed per unit from your credit balance (live rates: GET /api/keys/rates) — never from the plan quota, and with no daily request cap. Your monthly spending limit (Settings › Usage) applies to API keys too. Amounts in error bodies are US cents:\n- 402 PAYMENT_REQUIRED {message, estimatedCost, balance} — the balance can't cover the request\n- 402 SPENDING_LIMIT {message, estimatedCost, balance, monthlySpent, monthlyLimit} — your own monthly limit is reached\n\nRate limits: API keys have their own limits, separate from the app and independent of your plan. Defaults per account (all your keys share them): chat 120 requests/min; speech generate/stream 60/min; speech jobs created 30/min; every other endpoint 600/min; 5 transcription jobs running at once with up to 100 more waiting in your account queue; 5 speech jobs at once. GET /api/keys/limits returns the limits in force for your key; they can be raised per account on request. Every response carries X-RateLimit-Limit, X-RateLimit-Remaining and X-RateLimit-Reset. 429 bodies: {code: \"RATE_LIMITED\", message, limit, retryAfter, resetAt}, {code: \"QUEUE_FULL\" | \"JOB_LIMIT\", message, limit, active, retryAfter} — always with a Retry-After header (seconds). A refused request does not count against the limit.\n\nTranscription queue: submit a whole batch at once. Jobs beyond the running limit are accepted with status \"queued\" and start in order; GET /api/jobs/:id shows queuePosition while a job waits.\n\nWebhooks: add webhook_url (https, publicly reachable) to POST /api/jobs, POST /api/jobs/url or POST /api/tts/jobs and we POST a small signed event to it when the job ends: {id, type, created, data: {id, status, …}} with type transcription.completed | transcription.failed | speech.completed | speech.failed. Verify the X-Mazdek-Signature header: \"t=<unix seconds>,v1=<hex>\" where v1 = HMAC-SHA256(\"<t>.<raw body>\") with your signing secret (Settings › API › Webhooks). Answer 2xx within 10 s; otherwise we retry up to 8 times over about 30 minutes. GET /api/keys/webhook-deliveries lists your last 50 deliveries.\n\nSafe retries: send a unique Idempotency-Key header with any POST. Repeating the request with the same key returns the first answer (header Idempotent-Replayed: true) instead of running — and charging — again. Keys are remembered for 24 hours; the same key with a different body returns 422 IDEMPOTENCY_KEY_REUSED, a repeat while the first is still running returns 409 IDEMPOTENCY_IN_PROGRESS. Audio and streamed answers are not replayed.\n\nMixed-language lines: if your recordings can be in more than one language (e.g. a call centre taking Arabic and Soranî calls), send language \"auto\" with expected_languages \"ar,ckb\". Detection is then limited to those languages; a recording detected as anything else is transcribed again in the closest listed language.\n\nOpenAPI: the machine-readable specification is at https://mazdek.ai/openapi.json.\n\nModels:\n- Kurmancî / Soranî TTS: native Kurdish voices (1220+). Use model: \"kurmanci\" or \"sorani\"\n- Kurmancî / Soranî ASR: fine-tuned custom models. Use language: \"ku\" or \"ckb\" (Kirmanckî: \"zza\")\n- Multilingual: 32 languages TTS (model: \"multilingual\"), 90+ languages ASR"
  },
  "servers": [
    {
      "url": "https://api.mazdek.ai"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "tags": [
    {
      "name": "Text-to-Speech (TTS)",
      "description": "Generate speech from text: native Kurmancî and Soranî voices (1220+) or the multilingual engine (32 languages). Short text: POST /api/tts/generate (synchronous). Long text: POST /api/tts/jobs (async, split and stitched). Live limits: GET /api/tts/limits."
    },
    {
      "name": "Speech-to-Text (ASR)",
      "description": "Transcribe audio/video with fine-tuned Kurmancî/Soranî models or the multilingual model (90+ languages).\n\nPipeline: Upload → Vocal Separation → Noise Reduction → Transcription → Translation (optional)\n\nLimits: upload up to 100 MB per file; hard ceiling 3 hours of audio per file; with an API key 5 jobs run at once and up to 100 more wait in your account queue (GET /api/keys/limits). Add webhook_url to be called when a job ends instead of polling. Results are kept for 24 hours."
    },
    {
      "name": "Chat",
      "description": "AI chat completion with mazdek AI."
    },
    {
      "name": "Translation",
      "description": "Translate text between ~255 languages (GET /api/translate/languages). Kurdish — Kurmancî (ku), Soranî (ckb), Kirmanckî (zza) — uses dedicated high-quality engines. Billed per source character at the translation rate."
    },
    {
      "name": "Spell check (Rastnivîs)",
      "description": "Kurdish spell checking (Kurmancî, Soranî, Kirmanckî) plus 90+ other languages. Spelling, diacritics and the personal dictionary are free with an API key; grammar suggestions (AI) are billed from your credit balance at the translation rate."
    },
    {
      "name": "Songs (Stran)",
      "description": "Generate original songs with Kurdish lyrics. Two modes: standard (our own hardware) and kurdi (Awaza Kurdî, premium engine, best for Kurdish idioms). With an API key both modes bill per song from your credit balance (see GET /api/keys/rates). Generation runs in the background: create → poll status → download audio.\n\nPreset styles (styleChip): kurdish_pop, saz_ballad, govend, grani, dengbej, heyran, heyranok, sin, lori, hore, siyacemane, koma_rock, halparke, kemence, narink, payizok, maqam, dengbej_fusion, acoustic, pop, rock, hiphop."
    },
    {
      "name": "Account, limits & webhooks",
      "description": "Read-only helpers for an integration: the limits and prices that apply to your key, and the delivery log of your job webhooks. The webhook signing secret itself is shown only in Settings › API › Webhooks (it cannot be read with an API key)."
    }
  ],
  "paths": {
    "/api/tts/voices": {
      "get": {
        "operationId": "listKurmanciVoices",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "List Kurmancî Voices",
        "description": "List and filter the Kurmancî TTS voices (filters: category, gender, age; lang = description language; model=sorani for the Soranî catalog). Returns voice ids, names, categories, genders and descriptions.\n\nVoice ids are public aliases like `kvbt75jxh9`. Legacy ids such as `kmr-female-1` are still accepted as input.",
        "parameters": [
          {
            "name": "lang",
            "in": "query",
            "required": false,
            "description": "Language for voice descriptions: en, ku, tr, ar, ckb",
            "schema": {
              "type": "string"
            },
            "example": "en"
          },
          {
            "name": "category",
            "in": "query",
            "required": false,
            "description": "Filter: advertisement, characters, conversational, entertainment, educational, narrative, social_media",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "gender",
            "in": "query",
            "required": false,
            "description": "Filter: male, female",
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "age",
            "in": "query",
            "required": false,
            "description": "Filter: Young, Middle Aged, Old",
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success — 1220 voices",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "voices": [
                    {
                      "id": "kvbt75jxh9",
                      "name": "Agirî",
                      "gender": "male",
                      "category": "advertisement",
                      "age": "Middle Aged",
                      "type": "extended",
                      "is_top": true,
                      "is_featured": false,
                      "description": "Smooth Confident and Persuasive"
                    },
                    {
                      "id": "kvczc5npf4",
                      "name": "Adar",
                      "gender": "female",
                      "category": "advertisement",
                      "age": "Middle Aged",
                      "type": "extended",
                      "is_top": false,
                      "is_featured": false,
                      "description": "Engaging Convincing and Smiley"
                    }
                  ],
                  "count": 1220,
                  "categories": [
                    "advertisement",
                    "characters",
                    "conversational",
                    "entertainment",
                    "educational",
                    "narrative",
                    "social_media"
                  ],
                  "source": "database"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tts/samples/{voice_id}": {
      "get": {
        "operationId": "previewVoiceSample",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "Preview Voice Sample",
        "description": "Listen to a voice sample before generating speech. Returns WAV audio.\n\nReplace `kvbt75jxh9` with any voice id from the voices list.",
        "parameters": [
          {
            "name": "voice_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Success — WAV audio",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tts/generate": {
      "post": {
        "operationId": "generateKurmanciSpeech",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "Generate Kurmancî Speech",
        "description": "Generate Kurdish speech with the native Kurmancî (or Soranî) TTS model. Synchronous: the response is the audio itself.\n\nParameters:\n- text (required): text to synthesize — max 3,000 chars per synchronous Kurmancî/Soranî call (kurdishSyncMaxChars in GET /api/tts/limits). Longer text: POST /api/tts/jobs\n- model: \"kurmanci\" (default) | \"sorani\" | \"multilingual\". If omitted, language \"ckb\" selects sorani\n- voice_id: voice id from /api/tts/voices (default voice if omitted)\n- settings.speed: 0.5–2.0 (default 1.0)\n\nReturns: audio/wav binary data",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "examples": {
                "generateKurmanciSpeech": {
                  "summary": "Generate Kurmancî Speech",
                  "value": {
                    "text": "Rojbaş! Navê min Agirî ye. Ez ji mazdek AI im.",
                    "model": "kurmanci",
                    "voice_id": "kvbt75jxh9",
                    "settings": {
                      "speed": 1
                    }
                  }
                },
                "generateMultilingualSpeech": {
                  "summary": "Generate Multilingual Speech",
                  "value": {
                    "text": "Hello world! This is a test.",
                    "model": "multilingual",
                    "voice_id": "mvhhna4hpm",
                    "language": "en",
                    "settings": {
                      "speed": 1,
                      "emotion": "happy"
                    }
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success — WAV audio",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tts/multilingual/voices": {
      "get": {
        "operationId": "listMultilingualVoices",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "List Multilingual Voices",
        "description": "List available multilingual voices (filter with ?language=). `supportedLanguages` lists the 32 languages the multilingual engine voices — Kurdish is not among them.\n\nFor Kurdish voices, use GET /api/tts/voices instead.",
        "parameters": [
          {
            "name": "language",
            "in": "query",
            "required": false,
            "description": "Filter by language: en, ar, tr, de, fr, es, etc.",
            "schema": {
              "type": "string"
            },
            "example": "en"
          }
        ],
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "voices": [
                    {
                      "id": "mvhhna4hpm",
                      "name": "Energetic Male",
                      "gender": "male",
                      "language": "en",
                      "description": "A youthful and energetic male voice with a clear, professional American accent…",
                      "tags": [
                        "social_media",
                        "young",
                        "male"
                      ],
                      "sampleUrl": "https://api.mazdek.ai/api/tts/multilingual/voices/mvhhna4hpm/preview"
                    }
                  ],
                  "count": 200,
                  "byLanguage": {
                    "en": [
                      "…"
                    ]
                  },
                  "supportedLanguages": [
                    {
                      "code": "en",
                      "name": "English"
                    },
                    "…"
                  ],
                  "curated": false
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tts/stream": {
      "post": {
        "operationId": "streamSpeech",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "Stream Speech",
        "description": "Same body as /api/tts/generate (text, model, voice_id, language, settings). Without `progressive` the response is ONE complete audio body.\n\nWith \"progressive\": true (Kurmancî/Soranî) the text is split at sentence boundaries and the response is NDJSON: one line per chunk {seq, total, format, audio (base64)}, then {done: true, total}. Usage is metered per delivered chunk.\n\nRate limit: 20/min (shared with /generate).",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "text": "Rojbaş! Ev nivîsek dirêj e. Her hevok wekî perçeyek tê şandin.",
                "model": "kurmanci",
                "voice_id": "kvbt75jxh9",
                "progressive": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tts/jobs": {
      "post": {
        "operationId": "createLongTTSJob",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "Create Long TTS Job",
        "description": "Async TTS for long text: the text is split, synthesized and stitched into one file. Billed from credit for API keys.\n\nParameters: text (required, max 5,000 chars per job) and the same voice_id, model, language, settings as /api/tts/generate. With an API key up to 5 jobs can be queued or running at once per account (GET /api/keys/limits). Optional webhook_url: an https:// address called when the job ends.\n\nPoll GET /api/tts/jobs/:id (or SSE GET /api/tts/jobs/:id/stream); cancel with POST /api/tts/jobs/:id/cancel.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "text": "Nivîsek dirêj… (heta 5,000 tîp)",
                "model": "kurmanci",
                "voice_id": "kvbt75jxh9"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Job Created",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "ttsjob-…",
                    "status": "queued",
                    "charCount": 4200,
                    "chunkCount": 9
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tts/jobs/{tts_job_id}": {
      "get": {
        "operationId": "getTTSJob",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "Get TTS Job",
        "description": "Job status + progress. status: queued | processing | completed | failed | cancelled. When completed, result.audioUrl is a signed download link valid for 1 hour.",
        "parameters": [
          {
            "name": "tts_job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Completed",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "ttsjob-…",
                    "status": "completed",
                    "progress": {
                      "percent": 100,
                      "step": "completed"
                    },
                    "charCount": 4200,
                    "result": {
                      "generationId": "…",
                      "duration": 291.4,
                      "mimeType": "audio/wav",
                      "audioUrl": "https://… (valid for 1 hour)"
                    },
                    "error": null,
                    "errorCode": null
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tts/jobs/{tts_job_id}/stream": {
      "get": {
        "operationId": "tTSJobProgressSSE",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "TTS Job Progress (SSE)",
        "description": "Server-Sent Events with the job's progress until it completes, fails or is cancelled.",
        "parameters": [
          {
            "name": "tts_job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tts/jobs/{tts_job_id}/cancel": {
      "post": {
        "operationId": "cancelTTSJob",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "Cancel TTS Job",
        "description": "Cancel a queued or running TTS job.",
        "parameters": [
          {
            "name": "tts_job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/tts/limits": {
      "get": {
        "operationId": "tTSLimits",
        "tags": [
          "Text-to-Speech (TTS)"
        ],
        "summary": "TTS Limits",
        "description": "Live per-request limits: maxChars (UI cap), planMaxChars (your plan's cap, when signed in), apiMaxChars (API-key cap), kurdishSyncMaxChars (what one synchronous Kurmancî/Soranî /generate call accepts) and asyncEndpoint.",
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "maxChars": 5000,
                  "planMaxChars": null,
                  "apiMaxChars": 5000,
                  "kurdishSyncMaxChars": 3000,
                  "asyncEndpoint": "POST /api/tts/jobs"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/jobs": {
      "post": {
        "operationId": "transcribeKurmanciAudio",
        "tags": [
          "Speech-to-Text (ASR)"
        ],
        "summary": "Transcribe Kurmancî Audio",
        "description": "Upload audio and transcribe it with the fine-tuned Kurmancî ASR model (multipart/form-data).\n\nThe job runs asynchronously. Poll GET /api/jobs/:id (or SSE GET /api/jobs/:id/stream) for results.\n\nForm fields:\n- file (required)\n- language: default \"ku\"; \"auto\" detects the language\n- translate: \"true\" to translate after transcription\n- target_language: translation target (default \"en\")\n- clean_audio: vocal separation + noise reduction, on by default (\"false\" disables)\n- auto_optimize: on by default (\"false\" disables)\n- trim_start / trim_end: seconds, transcribe only a part of the file\n\nLanguage codes that use the Kurmancî model: ku, kmr, kurmanji, kurmanci, kirmancki, zazaki, zza, kiu, dimli",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "properties": {
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "Audio/video file (MP3, WAV, M4A, OGG, FLAC, WebM, MP4 — max 100 MB, 3 h)"
                  },
                  "language": {
                    "type": "string",
                    "example": "ku",
                    "description": "Language: ku (Kurmancî) — uses fine-tuned Kurdish model"
                  },
                  "expected_languages": {
                    "type": "string",
                    "example": "ar,ckb",
                    "description": "Optional, with language \"auto\": comma-separated languages the recording may be in, e.g. \"ar,ckb\" (max 5). Detection is limited to them; a recording detected as anything else is transcribed again in the closest listed language. One code = that language is used."
                  },
                  "clean_audio": {
                    "type": "string",
                    "example": "true",
                    "description": "Vocal separation + noise reduction (default true; \"false\" disables)"
                  },
                  "translate": {
                    "type": "string",
                    "description": "Set to 'true' to translate the transcript (needs target_language). Billed at the translation rate; the credit is set aside before the translation runs. If it cannot be covered the job still completes with the transcript, without a translation, and result.translationSkipped gives the reason (e.g. NO_CREDITS, SPENDING_LIMIT)."
                  },
                  "target_language": {
                    "type": "string",
                    "example": "en",
                    "description": "Translation target language code"
                  },
                  "auto_optimize": {
                    "type": "string",
                    "example": "true",
                    "description": "Automatic optimization (default true; \"false\" disables)"
                  },
                  "trim_start": {
                    "type": "string",
                    "example": "0",
                    "description": "Start offset in seconds"
                  },
                  "trim_end": {
                    "type": "string",
                    "example": "60",
                    "description": "End offset in seconds"
                  },
                  "webhook_url": {
                    "type": "string",
                    "example": "https://example.com/hooks/mazdek",
                    "description": "Optional https:// address called when the job ends (signed, see collection description)"
                  }
                },
                "required": [
                  "file"
                ]
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Job Created",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "abc12345",
                    "status": "queued",
                    "filename": "interview.mp3",
                    "language": "ku",
                    "translate": false,
                    "targetLanguage": "en",
                    "cleanAudio": true,
                    "autoOptimize": true,
                    "createdAt": "2026-10-09T12:00:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/jobs/url": {
      "post": {
        "operationId": "transcribeFromURL",
        "tags": [
          "Speech-to-Text (ASR)"
        ],
        "summary": "Transcribe from URL",
        "description": "Transcribe audio from a URL (YouTube, direct audio links, etc.). JSON body.\n\nParameters: url (required), language (default \"ku\"), translate (boolean), targetLanguage (camelCase here, default \"en\"), clean_audio, auto_optimize (booleans, default true), trim_start / trim_end (seconds), webhook_url (optional https:// address called when the job ends).\n\nexpected_languages (array or comma-separated string): Optional, with language \"auto\": comma-separated languages the recording may be in, e.g. \"ar,ckb\" (max 5). Detection is limited to them; a recording detected as anything else is transcribed again in the closest listed language. One code = that language is used.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "url": "https://www.youtube.com/watch?v=example",
                "language": "ku",
                "translate": true,
                "targetLanguage": "en",
                "clean_audio": true
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Job Created",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "url12345",
                    "status": "queued",
                    "filename": "Video title",
                    "language": "ku",
                    "sourceType": "url",
                    "createdAt": "2026-10-09T12:00:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/jobs/{job_id}": {
      "get": {
        "operationId": "getJobStatusResults",
        "tags": [
          "Speech-to-Text (ASR)"
        ],
        "summary": "Get Job Status & Results",
        "description": "Poll this endpoint to get the transcription result. The transcript is in data.result.text.\n\nStatus flow: queued → processing → completed / failed. While a job waits for one of your running slots the answer also carries queuePosition (1 = next). Results are kept for 24 hours.\n\nFor real-time progress, use SSE: GET /api/jobs/:id/stream",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Completed",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "data": {
                    "id": "abc12345",
                    "status": "completed",
                    "filename": "interview.mp3",
                    "language": "ku",
                    "translate": true,
                    "targetLanguage": "en",
                    "result": {
                      "text": "Silav, navê min Bager e.",
                      "segments": [
                        {
                          "start": 0,
                          "end": 2.1,
                          "text": "Silav,"
                        },
                        {
                          "start": 2.1,
                          "end": 4.8,
                          "text": "navê min Bager e."
                        }
                      ],
                      "language": "ku",
                      "duration": 4.8,
                      "translation": "Hello, my name is Bager."
                    },
                    "createdAt": "2026-10-09T12:00:00.000Z"
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "delete": {
        "operationId": "deleteJob",
        "tags": [
          "Speech-to-Text (ASR)"
        ],
        "summary": "Delete Job",
        "description": "Delete a job and its result.",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/jobs/{job_id}/stream": {
      "get": {
        "operationId": "jobProgressSSE",
        "tags": [
          "Speech-to-Text (ASR)"
        ],
        "summary": "Job Progress (SSE)",
        "description": "Server-Sent Events with progress updates for one job until it completes or fails (alternative to polling GET /api/jobs/:id).",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/jobs/precheck": {
      "post": {
        "operationId": "precheckUpload",
        "tags": [
          "Speech-to-Text (ASR)"
        ],
        "summary": "Precheck Upload",
        "description": "Optional: check a file against your limits before uploading. Body: fileSizeBytes (required), mimeType, fileName, durationSeconds. Advisory only — the real check runs on the uploaded file.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "fileSizeBytes": 4800000,
                "mimeType": "audio/mpeg",
                "fileName": "interview.mp3",
                "durationSeconds": 300
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "estimatedDurationSeconds": 300,
                  "durationIsMeasured": true,
                  "perFileLimitSeconds": 10800
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/jobs/active": {
      "get": {
        "operationId": "activeJobs",
        "tags": [
          "Speech-to-Text (ASR)"
        ],
        "summary": "Active Jobs",
        "description": "Your queued and running transcription jobs, with maxConcurrent (jobs running at once) and, for API keys, maxQueued (jobs that may wait behind them).",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/jobs/{job_id}/cancel": {
      "post": {
        "operationId": "cancelJob",
        "tags": [
          "Speech-to-Text (ASR)"
        ],
        "summary": "Cancel Job",
        "description": "Cancel a queued or running job.",
        "parameters": [
          {
            "name": "job_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/chat/v2": {
      "post": {
        "operationId": "chatCompletion",
        "tags": [
          "Chat"
        ],
        "summary": "Chat Completion",
        "description": "Send messages and receive an AI response.\n\nParameters:\n- messages (required): array of {role, content} objects\n- model: \"mazdek-ai\" (optional, default; the legacy id \"maz\" is still accepted)\n- temperature: 0.0–1.0 (optional)\n- maxTokens: max output tokens (default 4096)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "messages": [
                  {
                    "role": "user",
                    "content": "Rojbaş! Çawa yî?"
                  }
                ],
                "model": "mazdek-ai",
                "temperature": 0.7,
                "maxTokens": 4096
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "content": "Silav! Ez baş im, spas. Tu çawa yî?",
                  "model": "mazdek AI",
                  "modelId": "mazdek-ai",
                  "usage": {
                    "inputTokens": 24,
                    "outputTokens": 12
                  },
                  "latencyMs": 1250
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/chat/v2/stream": {
      "post": {
        "operationId": "chatCompletionStream",
        "tags": [
          "Chat"
        ],
        "summary": "Chat Completion (stream)",
        "description": "Same body as /api/chat/v2; the answer arrives as Server-Sent Events: `data: {\"content\": \"…\"}` deltas, ending with `data: [DONE]`.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "messages": [
                  {
                    "role": "user",
                    "content": "Rojbaş! Çawa yî?"
                  }
                ],
                "model": "mazdek-ai"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "text/event-stream": {
                "schema": {
                  "type": "string"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/translate": {
      "post": {
        "operationId": "translateText",
        "tags": [
          "Translation"
        ],
        "summary": "Translate Text",
        "description": "Translate text between languages.\n\nParameters:\n- text (required): max 10,000 chars per request with an API key (live: apiMaxChars in GET /api/translate/limits)\n- sourceLanguage: source language code; omit it or send \"auto\" to detect — the response then carries the detected sourceLanguage and \"detected\": true\n- targetLanguage (required): target language code\n- polish: fix punctuation/grammar before translating\n\nMany short strings at once: POST /api/translate/segments",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "text": "Rojbaş! Navê min Bager e. Ez ji Diyarbekirê me.",
                "sourceLanguage": "ku",
                "targetLanguage": "en"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "translation": "Hello! My name is Bager. I am from Diyarbakır.",
                  "sourceLanguage": "ku",
                  "targetLanguage": "en",
                  "engine": "mazdek-ai"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/translate/segments": {
      "post": {
        "operationId": "translateSegmentsBatch",
        "tags": [
          "Translation"
        ],
        "summary": "Translate Segments (batch)",
        "description": "Translate many short strings in one request; translations[] comes back in the same order.\n\nParameters:\n- segments (required): array of 1–2,000 strings, each ≤ 5,000 chars; total ≤ 100,000 chars (transcriptMaxChars in GET /api/translate/limits)\n- sourceLanguage (required — no \"auto\" here)\n- targetLanguage (required)\n\nBilled at the translation rate on the total character count.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "segments": [
                  "Mercimek çorbası",
                  "Izgara köfte",
                  "Ayran"
                ],
                "sourceLanguage": "tr",
                "targetLanguage": "ku"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "translations": [
                    "Şorbeya nîskê",
                    "Kufteya biraştî",
                    "Dew"
                  ],
                  "sourceLanguage": "tr",
                  "targetLanguage": "ku",
                  "engine": "mazdek-ai"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/translate/summarize": {
      "post": {
        "operationId": "summarizeExplain",
        "tags": [
          "Translation"
        ],
        "summary": "Summarize / Explain",
        "description": "Summarize a text or transcript, explain what a text means, or draft a news article / social posts from it. Billed at the translation rate on the input characters.\n\nParameters:\n- text (required)\n- language: input language (default \"ku\")\n- outputLanguage: output language (default \"en\")\n- mode: summary (default) | meaning | news | social\n\nResponses: summary/meaning → {summary, keyPoints, topic}; news → {headline, body}; social → {x, instagram, facebook, hashtags}.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "text": "Silav, navê min Bager e. Ez ji Amedê me û li Zürichê dixebitim.",
                "language": "ku",
                "outputLanguage": "en",
                "mode": "summary"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "summary": "…",
                  "keyPoints": [
                    "…"
                  ],
                  "topic": "personal",
                  "engine": "mazdek-ai"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/translate/languages": {
      "get": {
        "operationId": "listSupportedLanguages",
        "tags": [
          "Translation"
        ],
        "summary": "List Supported Languages",
        "description": "All supported translation languages (~256 entries). Alias codes that name one language are grouped: Kurmancî `ku` (aliases kmr, kurmanji), Soranî `ckb`, Kirmanckî `zza`. No auth needed.",
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "count": 256,
                  "languages": [
                    {
                      "code": "ku",
                      "name": "Kurmanji Kurdish",
                      "aliases": [
                        "kmr",
                        "kurmanji"
                      ]
                    },
                    {
                      "code": "en",
                      "name": "English"
                    },
                    "…"
                  ]
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/translate/limits": {
      "get": {
        "operationId": "translationLimits",
        "tags": [
          "Translation"
        ],
        "summary": "Translation Limits",
        "description": "Live per-request limits: maxChars (first-party UI), apiMaxChars (API-key requests to POST /api/translate), transcriptMaxChars (total for POST /api/translate/segments).",
        "responses": {
          "200": {
            "description": "Success",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                },
                "example": {
                  "success": true,
                  "maxChars": 5000,
                  "apiMaxChars": 10000,
                  "transcriptMaxChars": 100000
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/spellcheck": {
      "post": {
        "operationId": "checkSpelling",
        "tags": [
          "Spell check (Rastnivîs)"
        ],
        "summary": "Check Spelling",
        "description": "Find spelling, letter-form, punctuation, capitalization and context issues.\n\nParameters:\n- text (required): Text to check\n- lang (required): kmr (Kurmancî), ckb (Soranî), zza (Kirmanckî) or a code from GET /api/spellcheck/languages (en-GB, de, tr...)\n- script: auto | latin | arabic (Soranî only)\n- profile: common | krg (Soranî letter forms)\n- categories: filter, e.g. [\"spelling\", \"punctuation\"]\n\nOffsets (start/end) are UTF-16 code units, like JavaScript string indexes.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "text": "Ez ji bajare Amedê hatim.",
                "lang": "kmr"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/spellcheck/diacritics": {
      "post": {
        "operationId": "completeDiacritics",
        "tags": [
          "Spell check (Rastnivîs)"
        ],
        "summary": "Complete Diacritics",
        "description": "Restore missing î, ê, û, ş, ç in Kurmancî or Kirmanckî text. Ambiguous words are left unchanged and listed.\n\nParameters:\n- text (required)\n- lang (required): kmr | zza",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "text": "ez ji kurdistane hatim",
                "lang": "kmr"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/spellcheck/grammar": {
      "post": {
        "operationId": "grammarSuggestionsAI",
        "tags": [
          "Spell check (Rastnivîs)"
        ],
        "summary": "Grammar Suggestions (AI)",
        "description": "AI grammar and style suggestions as word-level issues. Billed from the credit balance at the translation rate (per character); returns 402 PAYMENT_REQUIRED when the balance can't cover it.\n\nParameters:\n- text (required): max 5,000 chars\n- lang (required)",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "text": "Ez ji bajare Amedê hatim.",
                "lang": "kmr"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/spellcheck/languages": {
      "get": {
        "operationId": "listLanguages",
        "tags": [
          "Spell check (Rastnivîs)"
        ],
        "summary": "List Languages",
        "description": "Supported languages: Kurdish dialects (languages) and other languages (otherLanguages), plus the maximum text length for your account.",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/spellcheck/dictionary": {
      "get": {
        "operationId": "listDictionaryWords",
        "tags": [
          "Spell check (Rastnivîs)"
        ],
        "summary": "List Dictionary Words",
        "description": "Words you added to your personal dictionary. They are never flagged for your account.",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "post": {
        "operationId": "addDictionaryWord",
        "tags": [
          "Spell check (Rastnivîs)"
        ],
        "summary": "Add Dictionary Word",
        "description": "Add a word to your personal dictionary.\n\nParameters:\n- lang (required)\n- word (required): max 64 chars",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "lang": "kmr",
                "word": "Bager"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "delete": {
        "operationId": "removeDictionaryWord",
        "tags": [
          "Spell check (Rastnivîs)"
        ],
        "summary": "Remove Dictionary Word",
        "description": "Remove a word from your personal dictionary.",
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "lang": "kmr",
                "word": "Bager"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/songs": {
      "post": {
        "operationId": "createSong",
        "tags": [
          "Songs (Stran)"
        ],
        "summary": "Create song",
        "description": "Queue a song. Either styleChip or style is required. Give lyrics with [Verse]/[Chorus]/[Bridge] tags, or leave lyrics empty and set topic so the lyrics are written for you. Set instrumental=true for no vocals.\n\nParameters:\n- lyrics: optional (default \"\"); the server keeps the first 3,000 chars; words in (parentheses) are backing vocals\n- mode: standard (default) | kurdi\n- styleChip: a preset style id (see folder description)\n- style: free-text style description, may be combined with styleChip\n- language: content language code (ku default, ckb, zza, tr, en, …)\n- instrumental: true | false (default false)\n- vocal: auto | female_high | female_low | male_high | male_low | raspy\n- length: short (~1 min) | normal (~2 min) | long (~3 min)\n- topic: what the song is about (used when lyrics is empty, at least 2 chars)\n- title: optional title (max 160)\n\nReturns { id } — poll GET /api/songs/{id}.",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "title": "Bihara Amedê",
                "mode": "kurdi",
                "styleChip": "kurdish_pop",
                "language": "ku",
                "vocal": "auto",
                "length": "normal",
                "lyrics": "[Verse]\nBihar hat, çiya kesk bûn\nDilê min li te digere\n\n[Chorus]\nAmed, Amed, bajarê min\nTu ronahiya rojên min"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "get": {
        "operationId": "listMySongs",
        "tags": [
          "Songs (Stran)"
        ],
        "summary": "List my songs",
        "description": "Your songs, newest first.",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/songs/{song_id}": {
      "get": {
        "operationId": "getSongStatus",
        "tags": [
          "Songs (Stran)"
        ],
        "summary": "Get song status",
        "description": "Status and metadata of a song: status (queued | processing | ready | failed), title, duration, style chip, lyrics, timed lyrics when available. Poll every few seconds until status is ready; failed jobs are not billed.",
        "parameters": [
          {
            "name": "song_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      },
      "delete": {
        "operationId": "deleteSong",
        "tags": [
          "Songs (Stran)"
        ],
        "summary": "Delete song",
        "description": "Deletes the song and its audio.",
        "parameters": [
          {
            "name": "song_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/songs/{song_id}/audio": {
      "get": {
        "operationId": "downloadAudio",
        "tags": [
          "Songs (Stran)"
        ],
        "summary": "Download audio",
        "description": "Downloads the MP3 of a ready song. Responds with a 302 redirect to a short-lived signed URL (Postman and `curl -L` follow it automatically); 404 until the song is ready. The same file is also available as `audioUrl` in the status response.",
        "parameters": [
          {
            "name": "song_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "audio/mpeg": {
                "schema": {
                  "type": "string",
                  "format": "binary"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/songs/lyrics": {
      "post": {
        "operationId": "writeLyricsWithMazdekAI",
        "tags": [
          "Songs (Stran)"
        ],
        "summary": "Write lyrics with mazdek AI",
        "description": "Ask mazdek AI to write original lyrics for a topic in the given language, shaped to the chosen style (verse/chorus structure, or no chorus for dengbêj/heyran). Uses chat quota.\n\nParameters:\n- language: ku | ckb | zza | tr | en …\n- topic: what the song is about (2-500 chars)\n- styleChip: optional preset style id\n- style: optional free-text style",
        "parameters": [
          {
            "$ref": "#/components/parameters/IdempotencyKey"
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "type": "object",
                "additionalProperties": true
              },
              "example": {
                "language": "ku",
                "topic": "Hesreta gundê min di payîzê de",
                "styleChip": "payizok"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "409": {
            "$ref": "#/components/responses/IdempotencyInProgress"
          },
          "422": {
            "$ref": "#/components/responses/Unprocessable"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/keys/limits": {
      "get": {
        "operationId": "aPILimits",
        "tags": [
          "Account, limits & webhooks"
        ],
        "summary": "API Limits",
        "description": "The rate and concurrency limits in force for your key: chatPerMinute, ttsPerMinute, ttsJobsPerMinute, requestsPerMinute, asrConcurrent, asrQueued, ttsJobsConcurrent, plus customLimitKeys (the ones raised for your account). Size your worker pool from this answer instead of hard-coding the defaults.",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "type": "object",
                  "properties": {
                    "success": {
                      "const": true
                    },
                    "data": {
                      "$ref": "#/components/schemas/ApiLimits"
                    }
                  }
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        },
        "security": [
          {
            "bearerAuth": []
          },
          {}
        ]
      }
    },
    "/api/keys/rates": {
      "get": {
        "operationId": "aPIPrices",
        "tags": [
          "Account, limits & webhooks"
        ],
        "summary": "API Prices",
        "description": "The prices your key is charged, in US cents per unit. Without ?scope=mine the published list prices are returned.",
        "parameters": [
          {
            "name": "scope",
            "in": "query",
            "required": false,
            "schema": {
              "type": "string"
            },
            "example": "mine"
          }
        ],
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    },
    "/api/keys/webhook-deliveries": {
      "get": {
        "operationId": "webhookDeliveries",
        "tags": [
          "Account, limits & webhooks"
        ],
        "summary": "Webhook Deliveries",
        "description": "Your last 50 webhook deliveries: event, jobId, url, status (pending | delivered | failed), attempts, lastStatusCode, lastError, createdAt, deliveredAt.",
        "responses": {
          "200": {
            "description": "OK",
            "headers": {
              "X-RateLimit-Limit": {
                "$ref": "#/components/headers/X-RateLimit-Limit"
              },
              "X-RateLimit-Remaining": {
                "$ref": "#/components/headers/X-RateLimit-Remaining"
              },
              "X-RateLimit-Reset": {
                "$ref": "#/components/headers/X-RateLimit-Reset"
              }
            },
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Success"
                }
              }
            }
          },
          "400": {
            "$ref": "#/components/responses/BadRequest"
          },
          "401": {
            "$ref": "#/components/responses/Unauthorized"
          },
          "402": {
            "$ref": "#/components/responses/PaymentRequired"
          },
          "403": {
            "$ref": "#/components/responses/Forbidden"
          },
          "429": {
            "$ref": "#/components/responses/TooManyRequests"
          },
          "503": {
            "$ref": "#/components/responses/Unavailable"
          }
        }
      }
    }
  },
  "webhooks": {
    "jobEnded": {
      "post": {
        "summary": "A job that carried webhook_url ended",
        "description": "Sent to the webhook_url of POST /api/jobs, POST /api/jobs/url or POST /api/tts/jobs. Signed: X-Mazdek-Signature is `t=<unix seconds>,v1=<hex>` with v1 = HMAC-SHA256(`<t>.<raw body>`) keyed with the account's signing secret. Answer 2xx within 10 seconds; otherwise the delivery is retried up to 8 times over about 30 minutes.",
        "parameters": [
          {
            "name": "X-Mazdek-Signature",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Mazdek-Event",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string"
            }
          },
          {
            "name": "X-Mazdek-Delivery",
            "in": "header",
            "required": true,
            "schema": {
              "type": "string",
              "format": "uuid"
            }
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/WebhookEvent"
              },
              "example": {
                "id": "5b1f0c0e-6d0a-4c57-9f0e-1c2f6f0b7a11",
                "type": "transcription.completed",
                "created": 1763299998,
                "data": {
                  "id": "a1b2c3d4",
                  "status": "completed",
                  "durationSeconds": 184.2,
                  "language": "ku"
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Any 2xx acknowledges the event"
          }
        }
      }
    }
  },
  "components": {
    "responses": {
      "BadRequest": {
        "description": "Invalid parameters",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unauthorized": {
        "description": "Missing, invalid or revoked API key",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "PaymentRequired": {
        "description": "PAYMENT_REQUIRED (balance too low) or SPENDING_LIMIT (monthly limit reached)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Forbidden": {
        "description": "API_SERVICE_UNAVAILABLE (no API price for this service) or FORBIDDEN",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "IdempotencyInProgress": {
        "description": "IDEMPOTENCY_IN_PROGRESS — the first request with this Idempotency-Key is still running",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "Unprocessable": {
        "description": "IDEMPOTENCY_KEY_REUSED (same key, different request) or TRANSLATION_REFUSED",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      },
      "TooManyRequests": {
        "description": "RATE_LIMITED, QUEUE_FULL (transcription queue full) or JOB_LIMIT (too many speech jobs)",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        },
        "headers": {
          "Retry-After": {
            "$ref": "#/components/headers/Retry-After"
          },
          "X-RateLimit-Limit": {
            "$ref": "#/components/headers/X-RateLimit-Limit"
          },
          "X-RateLimit-Remaining": {
            "$ref": "#/components/headers/X-RateLimit-Remaining"
          },
          "X-RateLimit-Reset": {
            "$ref": "#/components/headers/X-RateLimit-Reset"
          }
        }
      },
      "Unavailable": {
        "description": "Temporarily busy or under maintenance",
        "content": {
          "application/json": {
            "schema": {
              "$ref": "#/components/schemas/Error"
            }
          }
        }
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key: Authorization: Bearer mazdek_sk_…"
      }
    },
    "parameters": {
      "IdempotencyKey": {
        "name": "Idempotency-Key",
        "in": "header",
        "required": false,
        "description": "Unique string (1–255 printable ASCII characters). A repeat of the same request with the same key returns the first answer (header Idempotent-Replayed: true) instead of running again. Remembered for 24 hours per account. Audio and streamed answers are not replayed.",
        "schema": {
          "type": "string",
          "maxLength": 255
        }
      }
    },
    "headers": {
      "X-RateLimit-Limit": {
        "description": "Requests allowed in the current window",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Remaining": {
        "description": "Requests left in the current window",
        "schema": {
          "type": "integer"
        }
      },
      "X-RateLimit-Reset": {
        "description": "Unix seconds when the window resets",
        "schema": {
          "type": "integer"
        }
      },
      "Retry-After": {
        "description": "Seconds to wait before sending the request again",
        "schema": {
          "type": "integer"
        }
      }
    },
    "schemas": {
      "Success": {
        "type": "object",
        "required": [
          "success"
        ],
        "properties": {
          "success": {
            "const": true
          },
          "data": {}
        },
        "additionalProperties": true
      },
      "Error": {
        "type": "object",
        "required": [
          "success",
          "error"
        ],
        "properties": {
          "success": {
            "const": false
          },
          "error": {
            "description": "An object with a machine-readable code; a few older endpoints answer with a plain message string.",
            "oneOf": [
              {
                "type": "string"
              },
              {
                "type": "object",
                "required": [
                  "code"
                ],
                "properties": {
                  "code": {
                    "type": "string",
                    "examples": [
                      "RATE_LIMITED",
                      "QUEUE_FULL",
                      "PAYMENT_REQUIRED"
                    ]
                  },
                  "message": {
                    "type": "string"
                  },
                  "limit": {
                    "type": "integer"
                  },
                  "active": {
                    "type": "integer"
                  },
                  "retryAfter": {
                    "type": "integer",
                    "description": "Seconds"
                  },
                  "resetAt": {
                    "type": "string",
                    "format": "date-time"
                  },
                  "estimatedCost": {
                    "type": "number",
                    "description": "US cents"
                  },
                  "balance": {
                    "type": "number",
                    "description": "US cents"
                  }
                },
                "additionalProperties": true
              }
            ]
          }
        }
      },
      "ApiLimits": {
        "type": "object",
        "properties": {
          "chatPerMinute": {
            "type": "integer",
            "description": "Chat requests per minute"
          },
          "ttsPerMinute": {
            "type": "integer",
            "description": "Speech requests per minute (/api/tts/generate, /api/tts/stream)"
          },
          "ttsJobsPerMinute": {
            "type": "integer",
            "description": "Speech jobs created per minute (/api/tts/jobs)"
          },
          "requestsPerMinute": {
            "type": "integer",
            "description": "Every other request per minute"
          },
          "asrConcurrent": {
            "type": "integer",
            "description": "Transcription jobs running at once"
          },
          "asrQueued": {
            "type": "integer",
            "description": "Transcription jobs that may wait in the account queue"
          },
          "ttsJobsConcurrent": {
            "type": "integer",
            "description": "Speech jobs queued or running at once"
          },
          "customLimitKeys": {
            "type": "array",
            "items": {
              "type": "string"
            },
            "description": "Limits raised for this account"
          }
        }
      },
      "WebhookEvent": {
        "type": "object",
        "required": [
          "id",
          "type",
          "created",
          "data"
        ],
        "properties": {
          "id": {
            "type": "string",
            "format": "uuid",
            "description": "Delivery id — use it to ignore repeats"
          },
          "type": {
            "type": "string",
            "enum": [
              "transcription.completed",
              "transcription.failed",
              "speech.completed",
              "speech.failed"
            ]
          },
          "created": {
            "type": "integer",
            "description": "Unix seconds the event happened"
          },
          "data": {
            "type": "object",
            "required": [
              "id",
              "status"
            ],
            "properties": {
              "id": {
                "type": "string",
                "description": "Job id"
              },
              "status": {
                "type": "string",
                "enum": [
                  "completed",
                  "failed"
                ]
              },
              "durationSeconds": {
                "type": "number"
              },
              "language": {
                "type": "string",
                "description": "transcription.completed"
              },
              "generationId": {
                "type": "string",
                "description": "speech.completed"
              },
              "errorCode": {
                "type": "string",
                "description": "*.failed"
              }
            }
          }
        }
      }
    }
  }
}
