Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:Groq Groq python Translations Create

From Leeroopedia
Knowledge Sources
Domains Audio, Translation
Last Updated 2026-02-15 16:00 GMT

Overview

Concrete tool for translating audio into English provided by the Groq Python SDK's audio translation resource.

Description

The Translations class (and its async counterpart AsyncTranslations) provides the create() method to translate audio content into English using Groq-hosted Whisper models. It sends a multipart POST request to the /openai/v1/audio/translations endpoint. The method accepts audio as a file upload or URL, and supports configuring the model variant, output format, sampling temperature, and an optional English-language prompt for style guidance.

Usage

Import and use this when you need to translate non-English audio into English text. Access it via client.audio.translations.create(). For transcription (same language) use client.audio.transcriptions.create() instead.

Code Reference

Source Location

Signature

class Translations(SyncAPIResource):
    def create(
        self,
        *,
        model: Union[str, Literal["whisper-large-v3", "whisper-large-v3-turbo"]],
        file: FileTypes | Omit = omit,
        prompt: str | Omit = omit,
        response_format: Literal["json", "text", "verbose_json"] | Omit = omit,
        temperature: float | Omit = omit,
        url: str | Omit = omit,
        extra_headers: Headers | None = None,
        extra_query: Query | None = None,
        extra_body: Body | None = None,
        timeout: float | httpx.Timeout | None | NotGiven = not_given,
    ) -> Translation:
        """Translates audio into English."""

Import

from groq import Groq

client = Groq()
# Access via: client.audio.translations.create(...)

I/O Contract

Inputs

Name Type Required Description
model str or Literal["whisper-large-v3", "whisper-large-v3-turbo"] Yes Whisper model ID to use for translation
file FileTypes No* Audio file (flac, mp3, mp4, mpeg, mpga, m4a, ogg, wav, webm). *Either file or url required.
url str No* Audio URL (supports Base64URL). *Either file or url required.
prompt str No English text to guide model style or continue a previous segment
response_format Literal["json", "text", "verbose_json"] No Output format for the translation
temperature float No Sampling temperature (0-1); 0 uses log-probability auto-increase
extra_headers Headers or None No Additional HTTP headers
timeout float or Timeout or None No Per-request timeout override

Outputs

Name Type Description
return Translation Translation result containing the translated English text

Usage Examples

Translate an Audio File

from groq import Groq

client = Groq()

# Translate a French audio file to English
with open("french_audio.mp3", "rb") as audio_file:
    translation = client.audio.translations.create(
        model="whisper-large-v3-turbo",
        file=audio_file,
        response_format="json",
    )

print(translation.text)

Translate from URL

from groq import Groq

client = Groq()

translation = client.audio.translations.create(
    model="whisper-large-v3",
    url="https://example.com/spanish_audio.mp3",
    prompt="This is a conversation about technology.",
    temperature=0.2,
)

print(translation.text)

Async Translation

import asyncio
from groq import AsyncGroq

async def translate_audio():
    client = AsyncGroq()

    with open("german_audio.wav", "rb") as f:
        translation = await client.audio.translations.create(
            model="whisper-large-v3-turbo",
            file=f,
        )

    return translation.text

result = asyncio.run(translate_audio())

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment