openapi: 3.0.3
info:
  title: FishAudio 文字对口型
  version: 1.0.0
  description: >-
    Import this file into a private Coze cloud plugin. It generates speech from
    text with a selected Fish Audio voice, then creates and queries an
    asynchronous lip-synced video job. Every user supplies their own Fish Audio
    API key through the Authorization tool parameter.
servers:
  - url: https://fishaudio.org
paths:
  /api/open/v1/media/video-dubbing/jobs:
    post:
      operationId: create_text_lip_sync
      summary: Generate speech and create a lip-synced video
      description: >-
        Generate TTS audio from text and a Fish Audio voice ID, then create one
        asynchronous lip-sync job. Save data.id and reuse the same
        Idempotency-Key only when retrying this exact request.
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - $ref: '#/components/parameters/IdempotencyKey'
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/CreateTextLipSyncRequest'
      responses:
        '200':
          description: TTS completed and the lip-sync job was created successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoDubbingResponse'
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '402':
          $ref: '#/components/responses/ErrorResponse'
        '404':
          $ref: '#/components/responses/ErrorResponse'
        '413':
          $ref: '#/components/responses/ErrorResponse'
        '415':
          $ref: '#/components/responses/ErrorResponse'
        '422':
          $ref: '#/components/responses/ErrorResponse'
        '500':
          $ref: '#/components/responses/ErrorResponse'
  /api/open/v1/media/video-dubbing/jobs/{jobId}:
    get:
      operationId: get_text_lip_sync_job
      summary: Query a text-to-lip-sync video job
      description: >-
        Query the original job ID. Polling does not generate speech again and
        does not create or charge for another lip-sync job.
      parameters:
        - $ref: '#/components/parameters/Authorization'
        - name: jobId
          in: path
          required: true
          description: The data.id returned by create_text_lip_sync.
          schema:
            type: string
      responses:
        '200':
          description: Job status returned successfully
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/VideoDubbingResponse'
        '400':
          $ref: '#/components/responses/ErrorResponse'
        '401':
          $ref: '#/components/responses/ErrorResponse'
        '404':
          $ref: '#/components/responses/ErrorResponse'
        '500':
          $ref: '#/components/responses/ErrorResponse'
components:
  parameters:
    Authorization:
      name: Authorization
      in: header
      required: true
      description: Customer Fish Audio API key in the format Bearer YOUR_API_KEY.
      schema:
        type: string
      example: Bearer YOUR_FISH_AUDIO_API_KEY
    IdempotencyKey:
      name: Idempotency-Key
      in: header
      required: true
      description: >-
        A unique client-generated value. Reuse it only to retry the same
        request; use a new value for every new video generation.
      schema:
        type: string
        maxLength: 200
      example: coze-text-lip-sync-20260822-001
  schemas:
    CreateTextLipSyncRequest:
      type: object
      required:
        - video_url
        - text
        - reference_id
      properties:
        video_url:
          type: string
          format: uri
          description: Customer-owned or authorized video URL downloadable by Fish Audio.
        text:
          type: string
          minLength: 1
          maxLength: 5000
          description: Text used to generate the replacement speech track.
        reference_id:
          type: string
          minLength: 1
          description: Fish Audio system or private voice ID used for TTS.
        model_id:
          type: string
          default: fishaudio-s21pro-flash
          description: Fish Audio speech synthesis model. Use the default for the first test.
          enum:
            - fishaudio-s21pro
            - fishaudio-s21pro-flash
            - fishaudio-s2pro
            - fishaudio-s1
        speed:
          type: number
          minimum: 0.5
          maximum: 2
          default: 1
          description: Speech speed multiplier from 0.5 to 2.
        volume:
          type: number
          minimum: -20
          maximum: 20
          default: 0
          description: Output volume adjustment from -20 to 20.
        pitch:
          type: number
          minimum: -12
          maximum: 12
          description: Optional pitch adjustment in semitones.
        stability:
          type: number
          minimum: 0.5
          maximum: 1.5
          description: Optional voice stability control from 0.5 to 1.5.
        similarity:
          type: number
          minimum: 0.5
          maximum: 1.5
          description: Optional voice similarity control from 0.5 to 1.5.
        language:
          type: string
          maxLength: 32
          description: Optional language hint supported by the selected model.
        emotion:
          type: string
          maxLength: 64
          description: Optional emotion supported by the selected model.
        instruction:
          type: string
          maxLength: 1600
          description: Optional style, role, dialect, pacing, or emotion instruction.
        text_normalization:
          type: boolean
          default: true
          description: Normalize text before synthesis.
    VideoDubbingResponse:
      type: object
      required:
        - success
        - data
      properties:
        success:
          type: boolean
        message:
          type: string
        requestId:
          type: string
        data:
          type: object
          required:
            - id
            - status
            - stage
            - progress
          properties:
            id:
              type: string
              description: Save this value as jobId for subsequent queries.
            status:
              type: string
              enum:
                - pending
                - processing
                - completed
                - failed
            stage:
              type: string
              enum:
                - lip_sync
                - completed
                - failed
            progress:
              type: number
              minimum: 0
              maximum: 100
            result_url:
              type: string
              format: uri
              nullable: true
              description: Temporary generated video URL when the job is completed.
            audio_url:
              type: string
              format: uri
              nullable: true
              description: TTS audio URL generated during the first step.
            error_message:
              type: string
              nullable: true
            created_at:
              type: string
            updated_at:
              type: string
            completed_at:
              type: string
              nullable: true
            estimated_time:
              type: number
              nullable: true
            result_expires_at:
              type: string
              nullable: true
            result_expired:
              type: boolean
            credits_used:
              type: object
              properties:
                tts:
                  type: number
                lip_sync:
                  type: number
                total:
                  type: number
            quota_remaining:
              type: number
              nullable: true
            idempotency_replayed:
              type: boolean
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
        message:
          type: string
        requestId:
          type: string
      additionalProperties: true
  responses:
    ErrorResponse:
      description: Fish Audio API error
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
