# Speaker Diarization Transcription

> Audio Generation

Upload audio file for speaker diarization transcription.

**Endpoint**: `POST https://api.modelverse.cn/v1/audio/transcriptions`

**Content-Type**: `multipart/form-data`

**Authentication**: `Authorization: Bearer {api_key}`

## API Description

This is a standard HTTP RESTful API for speaker diarization transcription of audio files.

### Request Method
- **Method**: POST
- **Content-Type**: `multipart/form-data`
- **Authentication**: `Authorization: Bearer {api_key}`

## Endpoint

`POST https://api.modelverse.cn/v1/audio/transcriptions`

## Request Body

## Responses

- **200** — Transcription successful
- **400** — Invalid request parameters
- **401** — Authentication failed
- **500** — Internal server error

## OpenAPI Definition

```json
{
  "openapi": "3.1.0",
  "x-language": "en-US",
  "info": {
    "title": "GPT-4o Transcribe Diarize API Documentation",
    "version": "1.0.0",
    "description": "This is the API documentation for GPT-4o Transcribe Diarize speaker diarization model on ModelVerse.\n\nProtocol: HTTP POST, endpoint: `https://api.modelverse.cn/v1/audio/transcriptions`.\n\n**Features**: Speaker diarization transcription. Upload audio file, get transcription results with speaker labels.\n"
  },
  "servers": [
    {
      "url": "https://api.modelverse.cn",
      "description": "ModelVerse API endpoint"
    }
  ],
  "tags": [
    {
      "name": "GPT-4o-Transcribe-Diarize",
      "description": "GPT-4o Transcribe Diarize speaker diarization model, supporting audio file upload with speaker labels."
    }
  ],
  "security": [
    {
      "bearerAuth": []
    }
  ],
  "paths": {
    "/v1/audio/transcriptions": {
      "post": {
        "summary": "Speaker Diarization Transcription",
        "description": "Upload audio file for speaker diarization transcription.\n\n**Endpoint**: `POST https://api.modelverse.cn/v1/audio/transcriptions`\n\n**Content-Type**: `multipart/form-data`\n\n**Authentication**: `Authorization: Bearer {api_key}`\n\n## API Description\n\nThis is a standard HTTP RESTful API for speaker diarization transcription of audio files.\n\n### Request Method\n- **Method**: POST\n- **Content-Type**: `multipart/form-data`\n- **Authentication**: `Authorization: Bearer {api_key}`\n",
        "operationId": "createTranscription",
        "tags": [
          "GPT-4o-Transcribe-Diarize"
        ],
        "security": [
          {
            "bearerAuth": []
          }
        ],
        "requestBody": {
          "required": true,
          "content": {
            "multipart/form-data": {
              "schema": {
                "type": "object",
                "required": [
                  "model",
                  "file"
                ],
                "properties": {
                  "model": {
                    "type": "string",
                    "const": "gpt-4o-transcribe-diarize",
                    "description": "Model name, fixed as gpt-4o-transcribe-diarize"
                  },
                  "file": {
                    "type": "string",
                    "format": "binary",
                    "description": "Audio file (supports flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm)"
                  },
                  "response_format": {
                    "type": "string",
                    "enum": [
                      "json",
                      "diarized_json"
                    ],
                    "default": "diarized_json",
                    "description": "Response format, recommend diarized_json to get speaker information"
                  },
                  "language": {
                    "type": "string",
                    "description": "Audio language code (ISO-639-1), e.g. zh, en",
                    "example": "en"
                  },
                  "temperature": {
                    "type": "number",
                    "minimum": 0,
                    "maximum": 1,
                    "default": 0,
                    "description": "Sampling temperature"
                  }
                }
              },
              "examples": {
                "diarizedRequest": {
                  "summary": "Speaker diarization transcription request",
                  "value": {
                    "model": "gpt-4o-transcribe-diarize",
                    "file": "@audio.mp3",
                    "response_format": "diarized_json",
                    "language": "en"
                  }
                },
                "simpleRequest": {
                  "summary": "Simple transcription request",
                  "value": {
                    "model": "gpt-4o-transcribe-diarize",
                    "file": "@audio.mp3",
                    "response_format": "json"
                  }
                }
              }
            }
          }
        },
        "responses": {
          "200": {
            "description": "Transcription successful",
            "content": {
              "application/json": {
                "schema": {
                  "oneOf": [
                    {
                      "$ref": "#/components/schemas/DiarizedTranscriptionResponse"
                    },
                    {
                      "$ref": "#/components/schemas/SimpleTranscriptionResponse"
                    }
                  ]
                },
                "examples": {
                  "diarizedResponse": {
                    "summary": "Speaker diarization response",
                    "value": {
                      "text": "Hello, I'm John. Hello, I'm Mary.",
                      "segments": [
                        {
                          "type": "transcript.text.segment",
                          "text": "Hello, I'm John.",
                          "speaker": "A",
                          "start": 0,
                          "end": 2.5,
                          "id": "seg_0"
                        },
                        {
                          "type": "transcript.text.segment",
                          "text": "Hello, I'm Mary.",
                          "speaker": "B",
                          "start": 2.8,
                          "end": 5.2,
                          "id": "seg_1"
                        }
                      ],
                      "usage": {
                        "type": "tokens",
                        "total_tokens": 796,
                        "input_tokens": 216,
                        "input_token_details": {
                          "text_tokens": 0,
                          "audio_tokens": 216
                        },
                        "output_tokens": 580
                      }
                    }
                  },
                  "simpleResponse": {
                    "summary": "Simple transcription response",
                    "value": {
                      "text": "Hello, I'm John. Hello, I'm Mary.",
                      "usage": {
                        "type": "tokens",
                        "total_tokens": 796,
                        "input_tokens": 216,
                        "input_token_details": {
                          "text_tokens": 0,
                          "audio_tokens": 216
                        },
                        "output_tokens": 580
                      }
                    }
                  }
                }
              }
            }
          },
          "400": {
            "description": "Invalid request parameters",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "message": "Invalid file format",
                    "type": "invalid_request_error",
                    "param": "file",
                    "code": "invalid_file_format"
                  }
                }
              }
            }
          },
          "401": {
            "description": "Authentication failed",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "message": "Invalid API key",
                    "type": "authentication_error",
                    "code": "invalid_api_key"
                  }
                }
              }
            }
          },
          "500": {
            "description": "Internal server error",
            "content": {
              "application/json": {
                "schema": {
                  "$ref": "#/components/schemas/Error"
                },
                "example": {
                  "error": {
                    "message": "Internal server error",
                    "type": "server_error",
                    "code": "internal_error"
                  }
                }
              }
            }
          }
        }
      }
    }
  },
  "components": {
    "securitySchemes": {
      "bearerAuth": {
        "type": "http",
        "scheme": "bearer",
        "bearerFormat": "API key",
        "description": "Pass ModelVerse API Key in request headers (`Authorization: Bearer <api_key>`).\n"
      }
    },
    "schemas": {
      "DiarizedTranscriptionResponse": {
        "type": "object",
        "description": "Speaker diarization transcription response",
        "required": [
          "text",
          "segments",
          "usage"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "Full transcription text",
            "example": "Hello, I'm John. Hello, I'm Mary."
          },
          "segments": {
            "type": "array",
            "description": "Segmented transcription results with speaker info",
            "items": {
              "$ref": "#/components/schemas/TranscriptSegment"
            }
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "SimpleTranscriptionResponse": {
        "type": "object",
        "description": "Simple transcription response (no speaker info)",
        "required": [
          "text",
          "usage"
        ],
        "properties": {
          "text": {
            "type": "string",
            "description": "Full transcription text",
            "example": "Hello, I'm John. Hello, I'm Mary."
          },
          "usage": {
            "$ref": "#/components/schemas/Usage"
          }
        }
      },
      "TranscriptSegment": {
        "type": "object",
        "description": "Transcription segment",
        "required": [
          "type",
          "text",
          "speaker",
          "start",
          "end",
          "id"
        ],
        "properties": {
          "type": {
            "type": "string",
            "const": "transcript.text.segment",
            "description": "Segment type"
          },
          "text": {
            "type": "string",
            "description": "Transcription text",
            "example": "Hello, I'm John."
          },
          "speaker": {
            "type": "string",
            "description": "Speaker identifier",
            "example": "A"
          },
          "start": {
            "type": "number",
            "description": "Start time in seconds",
            "example": 0
          },
          "end": {
            "type": "number",
            "description": "End time in seconds",
            "example": 2.5
          },
          "id": {
            "type": "string",
            "description": "Segment ID",
            "example": "seg_0"
          }
        }
      },
      "Usage": {
        "type": "object",
        "description": "Usage information",
        "required": [
          "type",
          "total_tokens",
          "input_tokens",
          "output_tokens"
        ],
        "properties": {
          "type": {
            "type": "string",
            "const": "tokens",
            "description": "Usage type"
          },
          "total_tokens": {
            "type": "integer",
            "description": "Total token count",
            "example": 796
          },
          "input_tokens": {
            "type": "integer",
            "description": "Input token count",
            "example": 216
          },
          "input_token_details": {
            "type": "object",
            "description": "Input token details",
            "properties": {
              "text_tokens": {
                "type": "integer",
                "description": "Text token count",
                "example": 0
              },
              "audio_tokens": {
                "type": "integer",
                "description": "Audio token count",
                "example": 216
              }
            }
          },
          "output_tokens": {
            "type": "integer",
            "description": "Output token count",
            "example": 580
          }
        }
      },
      "Error": {
        "type": "object",
        "description": "Error response",
        "required": [
          "error"
        ],
        "properties": {
          "error": {
            "type": "object",
            "required": [
              "message",
              "type"
            ],
            "properties": {
              "message": {
                "type": "string",
                "description": "Error message"
              },
              "type": {
                "type": "string",
                "description": "Error type"
              },
              "param": {
                "type": "string",
                "description": "Related parameter"
              },
              "code": {
                "type": "string",
                "description": "Error code"
              }
            }
          }
        }
      }
    },
    "examples": {
      "CurlExample": {
        "summary": "cURL request example",
        "description": "Using cURL to call speaker diarization transcription API",
        "value": "curl -X POST https://api.modelverse.cn/v1/audio/transcriptions \\\n  -H \"Authorization: Bearer $TOKEN\" \\\n  -F \"model=gpt-4o-transcribe-diarize\" \\\n  -F \"file=@audio.mp3\" \\\n  -F \"response_format=diarized_json\" \\\n  -F \"language=en\"\n"
      },
      "PythonExample": {
        "summary": "Python request example",
        "description": "Using Python requests to call speaker diarization transcription API",
        "value": "import requests\n\nurl = \"https://api.modelverse.cn/v1/audio/transcriptions\"\nheaders = {\"Authorization\": \"Bearer your-token\"}\nfiles = {\"file\": open(\"audio.mp3\", \"rb\")}\ndata = {\n    \"model\": \"gpt-4o-transcribe-diarize\",\n    \"response_format\": \"diarized_json\",\n    \"language\": \"en\"\n}\n\nresponse = requests.post(url, headers=headers, files=files, data=data)\nresult = response.json()\n\nprint(\"Transcription text:\", result[\"text\"])\nprint(\"Speaker diarization:\")\nfor segment in result[\"segments\"]:\n    print(f\"[{segment['speaker']}] {segment['text']}\")\nprint(\"Usage:\", result[\"usage\"])\n"
      },
      "NodeExample": {
        "summary": "Node.js request example",
        "description": "Using Node.js axios to call speaker diarization transcription API",
        "value": "const axios = require('axios');\nconst FormData = require('form-data');\nconst fs = require('fs');\n\nconst form = new FormData();\nform.append('model', 'gpt-4o-transcribe-diarize');\nform.append('file', fs.createReadStream('audio.mp3'));\nform.append('response_format', 'diarized_json');\nform.append('language', 'en');\n\nconst response = await axios.post(\n  'https://api.modelverse.cn/v1/audio/transcriptions',\n  form,\n  {\n    headers: {\n      ...form.getHeaders(),\n      'Authorization': 'Bearer your-token'\n    }\n  }\n);\n\nconsole.log('Transcription text:', response.data.text);\nconsole.log('Speaker diarization:', response.data.segments);\nconsole.log('Usage:', response.data.usage);\n"
      }
    }
  }
}
```
