Create Translation Stream
Convert text between languages in real-time with contextual adaptations, delivering translated content as it’s generated for immediate use in conversational interfaces and live applications.
This endpoint provides instantaneous text translation with adaptive context handling, streaming results character-by-character as they’re processed. This approach enables real-time subtitling, live chat translation, and dynamic content localization without waiting for full document processing.
Customizing Your translation
Contextual Adaptation Parameters
Enhance your translations with linguistic context controls:
-
Formality Level (Optional):
Setting Value Use Case Formal 1 Business documents, academic papers, official correspondence Casual 2 Chat messages, social media, casual communication -
Grammatical Gender (Optional):
Applies to languages with gender-specific grammar
Setting Value Not Specified 0 Male 1 Female 2 Neutral 9
Language Support
-
Configure your translation pipeline using:
-
/source-languages
- Supported input languages -
/target-languages
- Available output languages
-
Implementation Guide
Streaming Translation Workflow:
When to use synchronous vs asynchronous:
-
Use synchronous (
requests
) for:- Simple scripts
- Low-concurrency applications
- Quick prototyping
-
Use asynchronous (
aiohttp
) for:- High-performance applications
- Parallel translation streams
- Web servers with async frameworks
Response Handling
-
Stream Format: UTF-8 encoded text/event-stream with incremental translations.
-
Credit Tracking:
X-Credits-Required
header shows computational resources used. -
Error Handling: Failed streams immediately terminate with error message.
Use Case Examples
-
Live Caption Translation: Convert spoken language subtitles in real-time
-
Chat Localization: Instant message translation for multilingual support teams
-
Document Preview: Stream translated content while full processing continues
This streaming solution is ideal for applications requiring immediate partial results while maintaining full translation context awareness. The character-level streaming allows for dynamic UI updates and progressive content rendering.
Authorizations
The x-api-key
is a custom header required for authenticating requests to our API. Include this header in your request with the appropriate API key value to securely access our endpoints. You can find your API key(s) in the 'API' section of our studio website.
Body
Response
Text translation stream
The response is of type string
.