> ## Documentation Index
> Fetch the complete documentation index at: https://apidoc.cometapi.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 建立轉錄

> 使用 CometAPI POST /v1/audio/transcriptions，搭配選定的轉錄模型與回應格式，將音訊轉錄為文字。

使用此端點可將音訊以來源語言轉錄為文字。適用於會議記錄、語音訊息、媒體索引、字幕，以及需要可搜尋文字的支援工作流程。

## First request

傳送受支援的音訊檔案，並附上 `model` 與 `file`。在驗證上傳處理、驗證機制與回應剖析之前，請先使用較短的第一個檔案。

## Read the response

預設回應會包含轉錄後的 `text`。如果你要求其他回應格式，請確認你的用戶端會剖析該格式，而不是假設為預設的 JSON 結構。

## Next steps

* 當你需要文字轉語音輸出時，請使用 [建立語音](/api/audio/create-speech)。
* 當目標輸出應為英文時，請使用 [建立翻譯](/api/audio/create-translation)。


## OpenAPI

````yaml api/openapi/audio/post-create-transcription.openapi.json POST /v1/audio/transcriptions
openapi: 3.1.0
info:
  title: Create transcription API
  version: 1.0.0
servers:
  - url: https://api.cometapi.com
security:
  - bearerAuth: []
paths:
  /v1/audio/transcriptions:
    post:
      summary: Create transcription
      operationId: create_transcription
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              properties:
                file:
                  format: binary
                  type: string
                  description: >-
                    The audio file to transcribe. Supported formats: flac, mp3,
                    mp4, mpeg, mpga, m4a, ogg, wav, webm.
                model:
                  type: string
                  description: >-
                    The speech-to-text model to use. Choose a current speech
                    model from the [Models page](/overview/models).
                  default: whisper-1
                language:
                  type: string
                  description: >-
                    The language of the input audio in ISO-639-1 format (e.g.,
                    `en`, `zh`, `ja`). Supplying the language improves accuracy
                    and latency.
                prompt:
                  type: string
                  description: >-
                    Optional text to guide the model's style or continue a
                    previous audio segment. The prompt should match the audio
                    language.
                response_format:
                  type: string
                  description: The output format for the transcription.
                  enum:
                    - json
                    - text
                    - srt
                    - verbose_json
                    - vtt
                  default: json
                temperature:
                  type: number
                  description: >-
                    Sampling temperature between 0 and 1. Higher values produce
                    more random output; lower values are more focused. When set
                    to 0, the model auto-adjusts temperature using log
                    probability.
                  minimum: 0
                  maximum: 1
                  default: 0
              required:
                - file
                - model
      responses:
        '200':
          description: The transcription result.
          content:
            application/json:
              schema:
                type: object
                required:
                  - text
                properties:
                  text:
                    type: string
                    description: The transcribed text.
              examples:
                Default:
                  summary: Transcription result
                  value:
                    text: Hello, welcome to CometAPI.
      x-codeSamples:
        - lang: python
          label: Create transcription
          source: |-
            import os
            from openai import OpenAI

            client = OpenAI(
                api_key=os.environ["COMETAPI_KEY"],
                base_url="https://api.cometapi.com/v1"
            )

            audio_file = open("audio.mp3", "rb")
            transcription = client.audio.transcriptions.create(
                model="whisper-1",
                file=audio_file
            )
            print(transcription.text)
        - lang: javascript
          label: Create transcription
          source: |-
            import OpenAI from "openai";
            import fs from "fs";

            const client = new OpenAI({
              apiKey: process.env.COMETAPI_KEY,
              baseURL: "https://api.cometapi.com/v1"
            });

            const transcription = await client.audio.transcriptions.create({
              model: "whisper-1",
              file: fs.createReadStream("audio.mp3")
            });
            console.log(transcription.text);
        - lang: shell
          label: Create transcription
          source: |-
            curl -X POST https://api.cometapi.com/v1/audio/transcriptions \
              -H "Authorization: Bearer $COMETAPI_KEY" \
              -F model="whisper-1" \
              -F file="@audio.mp3"
components:
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      description: Bearer token authentication. Use your CometAPI key.

````