openapi: 3.0.3
info:
  title: SLNG Gateway API - Sarvam AI STT
  version: 0.1.0
  description: Unified API for speech-to-text and text-to-speech services.
  contact:
    name: SLNG Support
    email: support@slng.ai
servers:
  - url: https://api.slng.ai
    description: Production
  - url: https://stageapi.slng.ai
    description: Staging
security:
  - BearerAuth: []
paths:
  /v1/stt/sarvam/saaras:v3:
    post:
      operationId: sarvam/saaras:v3
      summary: Saaras v3
      description: Transcribe audio using Sarvam AI Saaras with domain-aware speech recognition for 23 languages and flexible output modes.
      tags:
        - Sarvam AI Saaras
      parameters:
        - $ref: "#/components/parameters/XWorldPartSarvam"
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              $ref: "#/components/schemas/SarvamSaarasV3Request"
            examples:
              binary:
                summary: Transcribe Hindi audio
                value:
                  audio: <binary>
                  mode: transcribe
                  language_code: hi-IN
      responses:
        "200":
          $ref: "#/components/responses/SarvamSttSuccess"
        "400":
          $ref: "#/components/responses/ProviderBadRequest"
        "401":
          $ref: "#/components/responses/ProviderUnauthorized"
        "500":
          $ref: "#/components/responses/ProviderInternalServerError"
        "503":
          $ref: "#/components/responses/ProviderServiceUnavailable"
tags:
  - name: Sarvam AI Saaras
    description: Sarvam AI Saaras v3 STT with domain-aware speech recognition.
components:
  responses:
    ProviderServiceUnavailable:
      description: Service unavailable.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ProviderErrorResponse"
    ProviderInternalServerError:
      description: Internal server error from the provider.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ProviderErrorResponse"
          examples:
            processing-error:
              summary: Processing error
              value:
                error: Service error
                details: Internal processing error
    ProviderUnauthorized:
      description: Invalid or missing API key.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ProviderErrorResponse"
    ProviderBadRequest:
      description: Bad request - invalid parameters provided.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/ProviderErrorResponse"
          examples:
            validation-error:
              summary: Validation error
              value:
                error: Validation error
                details: "Missing required field: text"
    SarvamSttSuccess:
      description: Transcription successful.
      content:
        application/json:
          schema:
            $ref: "#/components/schemas/SarvamSttResponse"
          examples:
            basic:
              summary: Basic transcription
              value:
                transcript: नमस्ते, आज आप कैसे हैं?
  schemas:
    ProviderErrorResponse:
      type: object
      description: |
        Provider error response. Contains error information from the upstream provider.
        Common errors include invalid speakers, unsupported languages, or malformed requests.
      properties:
        error:
          type: string
          description: Error type or category (e.g., "TTS service error", "Validation error").
          example: TTS service error
        status:
          type: number
          description: Original HTTP status code from the provider (may differ from gateway response code).
          example: 400
        details:
          type: string
          description: |
            Detailed error message from the provider. For TTS errors, this typically includes
            the specific validation failure (e.g., invalid speaker ID for the selected model/language).
          example: "Rime TTS API error: 400 Bad Request - Invalid argument: Invalid speaker: aurelie"
      required:
        - error
    SarvamSttResponse:
      type: object
      description: Sarvam AI STT response format.
      required:
        - transcript
      properties:
        transcript:
          type: string
          description: The transcription result.
    SarvamSaarasV3Request:
      allOf:
        - $ref: "#/components/schemas/SttAudioRequestBase"
        - type: object
          required:
            - audio
          properties:
            mode:
              type: string
              description: |
                Output mode.
                - transcribe: Standard transcription in original language.
                - translate: Translate speech to English.
                - verbatim: Exact word-for-word without normalization.
                - translit: Romanization to Latin/Roman script.
                - codemix: Code-mixed (English words in English, Indic in native script).
              enum:
                - transcribe
                - translate
                - verbatim
                - translit
                - codemix
              default: transcribe
            language_code:
              type: string
              description: Language of the input audio (BCP-47). Set to 'unknown' for auto-detection.
              enum:
                - unknown
                - hi-IN
                - bn-IN
                - kn-IN
                - ml-IN
                - mr-IN
                - od-IN
                - pa-IN
                - ta-IN
                - te-IN
                - en-IN
                - gu-IN
                - as-IN
                - ur-IN
                - ne-IN
                - kok-IN
                - ks-IN
                - sd-IN
                - sa-IN
                - sat-IN
                - mni-IN
                - brx-IN
                - mai-IN
                - doi-IN
              default: unknown
    SttAudioRequestBase:
      type: object
      properties:
        audio:
          type: string
          format: binary
          description: Audio file (multipart) or base64-encoded audio (JSON).
        url:
          type: string
          description: Publicly accessible audio URL.
          example: https://docs.slng.ai/audio/hello.wav
  parameters:
    XWorldPartSarvam:
      name: X-World-Part-Override
      in: header
      required: false
      description: Target world part override. Auto-selected if not provided.
      schema:
        type: string
        enum:
          - ap
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer
      description: |
        API key issued by SLNG. Pass as `Authorization: Bearer <token>`.
