Skip to content

Batch Translation Methods

translate_batch()

batch = client.translate_batch([
    {"id": "1", "text": "Hello",        "target": "lug"},
    {"id": "2", "text": "Good morning", "target": "yo"},
    {"id": "3", "text": "Thank you",    "target": "ha"},
])

# Summary
print(f"{batch.succeeded}/{batch.total} succeeded")

# Iterate all
for item in batch:
    if item.success:
        print(item.translated_text)
    else:
        print(f"Error: {item.error}")

# Successful only
successes = batch.successful()

# Failed only
failures = batch.errors()

Returns a BatchResult.

async_translate_batch()

batch = await client.async_translate_batch([...])