v1/audio/speech and v1/audio/transcriptions formats.
Text-to-speech
Here is an example of text-to-speech: Parameters:model: The model ID of the model you want to useinput: The text to convert to speechresponse_format: The format of the audio output (default: “mp3”, options: “mp3”, “opus”, “aac”, “flac”, “wav”, “pcm”)speed: The speed of the generated audio (0.25 to 4.0, default: 1.0)
Audio transcription
Here is an example of audio transcription with the updated API: Parameters:model: The model ID of the model you want to use (required)file: The audio file to transcribe (required)language: The language of the audio input in ISO-639-1 format (e.g. “en”) (optional, auto-detected if not specified)prompt: Optional prompt to guide transcription (max 244 characters)response_format: Output format - “json”, “text”, “str”, “verbose_json”, “vtt” (default: “json”)temperature: The sampling temperature (0.0 to 1.0, default: 0.0)stream: Enable real-time streaming of transcription chunks (default: false)timestamp_granularities: The timestamp granularities to include (optional, options: “word”, “segment”, “char”)- Advanced parameters:
seed,top_p,top_k,n,frequency_penalty,presence_penalty,max_completion_tokens,to_language,repetition_penalty
Audio translation
Here is an example of audio translation with the new API: Parameters:model: The model ID of the model you want to use (required)file: The audio file to translate (required)language: The source language in ISO-639-1 format (optional, auto-detected if not specified)prompt: Optional prompt to guide translation (max 244 characters)response_format: Output format - “json”, “text”, “str”, “verbose_json”, “vtt” (default: “json”)temperature: The sampling temperature (0.0 to 1.0, default: 0.0)stream: Enable real-time streaming of translation chunks (default: false)- Advanced parameters:
seed,top_p,top_k,n,frequency_penalty,presence_penalty,max_completion_tokens,to_language,repetition_penalty
Error Handling
Common Errors
- Invalid audio format: Ensure file is WAV, MP3, M4A, etc.
- File too large: Check model limits (typically 25MB)
- Unsupported language: Verify language codes are ISO-639-1
- Stream parsing errors: Chunks are logged and skipped automatically
Error Response Example
Best Practices
For Accuracy
- Use
promptwith context about the audio content - Set
temperaturelow (0.0-0.3) for consistent results - Specify
languagewhen known to improve accuracy
For Performance
- Use streaming (
stream=True) for long audio files - Set appropriate
max_completion_tokensto limit output - Consider
top_p/top_kfor faster generation
For Real-time Applications
- Always use streaming with
timestamp_granularities=["word"] - Handle chunk parsing errors gracefully
- Accumulate text chunks for complete transcription

