{
  "openapi": "3.1.0",
  "info": {
    "title": "ErgeNext Speech API",
    "description": "Text-to-speech, speech-to-text and instant voice cloning for Uzbek, Russian, Tajik, Kyrgyz, Karakalpak and English. Docs: https://ergenextflow.uz/docs",
    "version": "1.0.0",
    "contact": {
      "name": "ErgeNext",
      "url": "https://ergenextflow.uz/docs"
    }
  },
  "paths": {
    "/v1/account": {
      "get": {
        "tags": [
          "Account"
        ],
        "summary": "Account balance, prices and limits",
        "operationId": "account_v1_account_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      }
    },
    "/v1/auth/token": {
      "post": {
        "tags": [
          "Account"
        ],
        "summary": "Create a short-lived token for mobile/browser clients",
        "operationId": "create_token_v1_auth_token_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "anyOf": [
                  {
                    "$ref": "#/components/schemas/TokenRequest"
                  },
                  {
                    "type": "null"
                  }
                ],
                "title": "Body"
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/voices": {
      "get": {
        "tags": [
          "Voices"
        ],
        "summary": "List available voices",
        "operationId": "list_voices_v1_voices_get",
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          }
        }
      },
      "post": {
        "tags": [
          "Voices"
        ],
        "summary": "Create an instant voice clone",
        "operationId": "create_voice_v1_voices_post",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_create_voice_v1_voices_post"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/voices/{voice_id}": {
      "get": {
        "tags": [
          "Voices"
        ],
        "summary": "Get one voice",
        "operationId": "get_voice_v1_voices__voice_id__get",
        "parameters": [
          {
            "name": "voice_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Voice Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      },
      "delete": {
        "tags": [
          "Voices"
        ],
        "summary": "Delete a custom voice",
        "operationId": "delete_voice_v1_voices__voice_id__delete",
        "parameters": [
          {
            "name": "voice_id",
            "in": "path",
            "required": true,
            "schema": {
              "type": "string",
              "title": "Voice Id"
            }
          }
        ],
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/tts": {
      "post": {
        "tags": [
          "Text to speech"
        ],
        "summary": "Text to speech",
        "operationId": "tts_v1_tts_post",
        "requestBody": {
          "content": {
            "application/json": {
              "schema": {
                "$ref": "#/components/schemas/TTSRequest"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              },
              "audio/mpeg": {},
              "audio/wav": {},
              "audio/ogg": {},
              "audio/L16": {}
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    },
    "/v1/stt": {
      "post": {
        "tags": [
          "Speech to text"
        ],
        "summary": "Speech to text (file)",
        "operationId": "stt_v1_stt_post",
        "requestBody": {
          "content": {
            "multipart/form-data": {
              "schema": {
                "$ref": "#/components/schemas/Body_stt_v1_stt_post"
              }
            }
          },
          "required": true
        },
        "responses": {
          "200": {
            "description": "Successful Response",
            "content": {
              "application/json": {
                "schema": {}
              }
            }
          },
          "422": {
            "description": "Validation Error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/HTTPValidationError"
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "schemas": {
      "Body_create_voice_v1_voices_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File",
            "description": "Voice sample, 5-30 s of clean speech by ONE speaker"
          },
          "name": {
            "type": "string",
            "maxLength": 60,
            "minLength": 1,
            "title": "Name"
          },
          "language": {
            "type": "string",
            "title": "Language",
            "description": "Language the voice will speak: uz, ru, en, tg, ky, kaa, kk, tr",
            "default": "uz"
          },
          "text": {
            "anyOf": [
              {
                "type": "string"
              },
              {
                "type": "null"
              }
            ],
            "title": "Text",
            "description": "Exact transcript of the sample (recommended). If omitted it is transcribed automatically (uz, ru, en, tg, ky, kaa)."
          },
          "consent": {
            "type": "string",
            "title": "Consent",
            "description": "Must be 'true': you confirm you have the speaker's permission to clone this voice"
          }
        },
        "type": "object",
        "required": [
          "file",
          "name",
          "consent"
        ],
        "title": "Body_create_voice_v1_voices_post"
      },
      "Body_stt_v1_stt_post": {
        "properties": {
          "file": {
            "type": "string",
            "contentMediaType": "application/octet-stream",
            "title": "File",
            "description": "Audio or video file (mp3, wav, ogg, m4a, mp4, webm, flac, amr ...)"
          },
          "language": {
            "type": "string",
            "title": "Language",
            "description": "auto, uz, ru, en, tg, ky, kaa",
            "default": "auto"
          },
          "response_format": {
            "type": "string",
            "enum": [
              "json",
              "text",
              "srt",
              "vtt"
            ],
            "title": "Response Format",
            "default": "json"
          },
          "prompt": {
            "anyOf": [
              {
                "type": "string",
                "maxLength": 400
              },
              {
                "type": "null"
              }
            ],
            "title": "Prompt",
            "description": "Optional vocabulary hint: names, brands, terms (uz)"
          }
        },
        "type": "object",
        "required": [
          "file"
        ],
        "title": "Body_stt_v1_stt_post"
      },
      "HTTPValidationError": {
        "properties": {
          "detail": {
            "items": {
              "$ref": "#/components/schemas/ValidationError"
            },
            "type": "array",
            "title": "Detail"
          }
        },
        "type": "object",
        "title": "HTTPValidationError"
      },
      "TTSRequest": {
        "properties": {
          "text": {
            "type": "string",
            "maxLength": 5000,
            "minLength": 1,
            "title": "Text",
            "description": "Text to speak (up to 5000 characters)"
          },
          "voice": {
            "type": "string",
            "title": "Voice",
            "description": "Voice id from GET /v1/voices",
            "default": "uz_maqsuda"
          },
          "speed": {
            "type": "number",
            "maximum": 1.4,
            "minimum": 0.7,
            "title": "Speed",
            "description": "Speaking rate, 0.7-1.4",
            "default": 1.0
          },
          "format": {
            "type": "string",
            "enum": [
              "mp3",
              "wav",
              "ogg",
              "flac",
              "pcm",
              "mulaw",
              "alaw"
            ],
            "title": "Format",
            "description": "Output audio format",
            "default": "mp3"
          },
          "sample_rate": {
            "anyOf": [
              {
                "type": "integer"
              },
              {
                "type": "null"
              }
            ],
            "title": "Sample Rate",
            "description": "8000, 16000, 22050, 24000, 44100 or 48000 (default: voice native)"
          },
          "stream": {
            "type": "boolean",
            "title": "Stream",
            "description": "Send audio progressively as sentences are ready (mp3, pcm, mulaw, alaw)",
            "default": false
          }
        },
        "type": "object",
        "required": [
          "text"
        ],
        "title": "TTSRequest"
      },
      "TokenRequest": {
        "properties": {
          "ttl_seconds": {
            "type": "integer",
            "maximum": 3600.0,
            "minimum": 60.0,
            "title": "Ttl Seconds",
            "description": "Token lifetime in seconds (60-3600)",
            "default": 600
          }
        },
        "type": "object",
        "title": "TokenRequest"
      },
      "ValidationError": {
        "properties": {
          "loc": {
            "items": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "integer"
                }
              ]
            },
            "type": "array",
            "title": "Location"
          },
          "msg": {
            "type": "string",
            "title": "Message"
          },
          "type": {
            "type": "string",
            "title": "Error Type"
          },
          "input": {
            "title": "Input"
          },
          "ctx": {
            "type": "object",
            "title": "Context"
          }
        },
        "type": "object",
        "required": [
          "loc",
          "msg",
          "type"
        ],
        "title": "ValidationError"
      }
    },
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "description": "API key (en_live_...) or temporary token (et_...)"
      }
    }
  },
  "servers": [
    {
      "url": "https://api.ergenextflow.uz",
      "description": "Production"
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "externalDocs": {
    "description": "Full docs incl. WebSocket streaming",
    "url": "https://ergenextflow.uz/docs"
  }
}