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

# Speech to Text

<Note>
  Note: For speech model name settings, refer to the [System Supported Transcription Speech Model List](https://geekai.dev/models). The request/response parameter structure is fully compatible with [OpenAI](https://platform.openai.com/docs/api-reference/audio/createSpeech). When switching models, you only need to modify the corresponding model name. If the model request/response parameters are inconsistent with OpenAI, GeekAI will automatically convert and align them at the backend.
</Note>

The response data format is fully compatible with the OpenAI speech transcription text interface.

### cURL Request Example

```bash theme={null}
curl --location 'https://geekai.dev/api/v1/audio/transcriptions' \
    --header 'Authorization: {YOUR_GEEKAI_API_KEY}' \
    --form 'file=@"/C:/User/GeekAI/Downloads/2cd359fe642c33deaa943f7306d73f30.mp3"' \
    --form 'model="whisper-1"' \
    --form 'response_format="text"'
```


## OpenAPI

````yaml openapi.yaml POST /audio/transcriptions
openapi: 3.1.0
info:
  title: 极客智坊 API文档
  description: 极客智坊 API 消息接口规范文档
  version: 1.0.0
servers:
  - url: https://geekai.co/api/v1
    description: 国内代理入口
  - url: https://geekai.dev/api/v1
    description: 海外代理入口
security:
  - bearerAuth: []
  - apiKeyAuth: []
paths:
  /audio/transcriptions:
    post:
      tags:
        - Audio
      summary: 语音转文字接口
      description: 将音频文件转换为文字的接口，支持多种音频格式和转录选项。
      operationId: createTranscription
      requestBody:
        required: true
        content:
          multipart/form-data:
            schema:
              type: object
              required:
                - model
                - file
              properties:
                model:
                  type: string
                  description: 语音识别模型
                  default: whisper-1
                file:
                  type: string
                  format: binary
                  description: 音频文件
                prompt:
                  type: string
                  description: 提示文本，用于指导转录风格
                language:
                  type: string
                  description: 音频语言
                response_format:
                  type: string
                  description: 响应格式，
                  enum:
                    - text
                    - srt
                    - vtt
                    - json
                  default: text
                stream:
                  type: boolean
                  description: 是否返回流式响应，默认false，whisper-1 模型不支持该设置
                  default: false
                  example: true
                temperature:
                  type: number
                  description: 采样温度，控制输出的随机性
                  default: 0
                retries:
                  type: integer
                  description: 自动重试次数，默认0，表示失败不重试
                  default: 0
      responses:
        '200':
          description: 成功响应
          content:
            text/plain:
              schema:
                type: string
                description: 纯文本格式的转录结果
            application/x-subrip:
              schema:
                type: string
                description: SRT字幕格式的转录结果
            text/vtt:
              schema:
                type: string
                description: VTT字幕格式的转录结果
            application/json:
              schema:
                type: object
                required:
                  - text
                properties:
                  text:
                    type: string
                    description: 转录文本
                  segments:
                    type: array
                    description: 音频片段信息
                    items:
                      type: object
                      required:
                        - start
                        - end
                        - text
                      properties:
                        id:
                          type: integer
                          description: 片段ID
                        start:
                          type: number
                          description: 开始时间(秒)
                          format: float
                        end:
                          type: number
                          description: 结束时间(秒)
                          format: float
                        text:
                          type: string
                          description: 片段文本内容
                        words:
                          type: array
                          description: 词级别时间戳（当timestamp_granularities包含word时）
                          items:
                            type: object
                            properties:
                              word:
                                type: string
                              start:
                                type: number
                              end:
                                type: number
                  language:
                    type: string
                    description: 检测到的语言代码
                  duration:
                    type: number
                    description: 音频总时长(秒)
                  usage:
                    type: object
                    properties:
                      audio_duration:
                        type: number
                        description: 处理的音频时长(秒)
                      total_tokens:
                        type: integer
                        description: 消耗的总token数
        '400':
          $ref: '#/components/responses/ValidationError'
        '401':
          $ref: '#/components/responses/Unauthorized'
        '413':
          description: 文件大小超出限制
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '415':
          description: 不支持的文件格式
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'
        '500':
          $ref: '#/components/responses/StandardError'
components:
  responses:
    ValidationError:
      description: 参数验证错误
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: validation_error
              message:
                type: string
                example: 参数验证失败
              details:
                type: object
                additionalProperties:
                  type: string
                example:
                  field: 错误描述
    Unauthorized:
      description: 未授权
      content:
        application/json:
          schema:
            type: object
            properties:
              code:
                type: string
                example: unauthorized
              message:
                type: string
                example: Invalid API key or token
    StandardError:
      description: 标准错误响应
      content:
        application/json:
          schema:
            $ref: '#/components/schemas/Error'
  schemas:
    Error:
      type: object
      required:
        - code
        - message
      properties:
        code:
          type: string
          description: 错误代码
          example: invalid_request
        message:
          type: string
          description: 错误信息描述
          example: 请求参数不合法
  securitySchemes:
    bearerAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: API认证token
    apiKeyAuth:
      type: apiKey
      in: header
      name: GeekAI-API-Key
      description: API密钥认证

````