Real-time language translation apps combine two distinct AI capabilities: accurate speech recognition and context-aware language conversion. Building one today is simpler than it sounds. With modern inference platforms, you can chain a transcription model to a large language model and ship a working pipeline in under a hundred lines of code. Oxlo.ai provides the audio, LLM, and speech endpoints you need under a single API, with flat per-request pricing that keeps costs predictable even when users upload long audio files.
Architecture Overview
A minimal translation pipeline has three stages. First, an audio transcription model converts speech to text. Second, an LLM translates the text into the target language while preserving tone and context. Third, an optional text-to-speech model speaks the result. On Oxlo.ai, you can run all three stages using the same OpenAI-compatible client by switching the base URL to https://api.oxlo.ai/v1.
Why Request-Based Pricing Matters for Translation Workloads
Audio transcription is inherently variable. A user might submit a ten-second voice note or a forty-minute interview. Token-based billing means your costs scale with every second of audio, because longer inputs generate more tokens. Oxlo.ai charges one flat cost per API request regardless of prompt length or audio duration. For translation apps that handle long-form content, agentic loops, or multi-turn conversations, this can reduce costs significantly compared to token-based providers. See exact rates on the Oxlo.ai pricing page.
Step 1: Transcribing Audio with Whisper
Oxlo.ai hosts Whisper Large v3, Whisper Turbo, and Whisper Medium. These models accept common audio formats and return timestamped or plain transcripts. Because the endpoint is fully OpenAI SDK compatible, you can use the familiar transcription interface.
from openai import OpenAI
client = OpenAI(
base_url="https://api.oxlo.ai/v1",
api_key="YOUR_OXLO_API_KEY"
)
audio_file = open("input.mp3", "rb")
transcription = client.audio.transcriptions.create(
model="whisper-large-v3",
file=audio_file,
response_format="text"
)
source_text = transcription.text
print(source_text)
For real-time scenarios, chunk the audio stream and send segments to Whisper Turbo to minimize latency.
Step 2: Translating with an LLM
Once you have the transcript, pass it to an LLM with a strict system prompt. Oxlo.ai offers multilingual models such as Qwen 3 32B and Llama 3.3 70B that handle nuanced translation well. Use JSON mode to receive structured output that is easy to parse in your application logic.
import json
response = client.chat.completions.create(
model="qwen3-32b",
messages=[
{
"role": "system",
"content": (
"You are a professional translator. Translate the user's text into French. "
"Preserve idioms, tone, and formatting. Return JSON with keys: 'translation', 'detected_source_language'."
)
},
{
"role": "user",
"content": source_text
}
],
response_format={"type": "json_object"}
)
result = json.loads(response.choices[0].message.content)
translated_text = result["translation"]
print(translated_text)
If you need deep reasoning for technical or legal documents, swap in DeepSeek R1 671B or Kimi K2.6. Both support long context windows, so you can translate entire reports in a single request without chunking.
Step 3: Optional Voice Output with Kokoro
To complete the experience, convert the translated text back to speech. Oxlo.ai offers Kokoro 82M text-to-speech, which runs with no cold starts.
speech_response = client.audio.speech.create(
model="kokoro-82m",
voice="af_bella",
input=translated_text
)
with open("output.mp3", "wb") as f:
f.write(speech_response.content)
Putting It Together
A production app usually wraps these steps in an async handler. Below is a simplified FastAPI-style skeleton showing how the pieces connect.
from fastapi import FastAPI, UploadFile
from openai import AsyncOpenAI
import json
app = FastAPI()
client = AsyncOpenAI(base_url="https://api.oxlo.ai/v1", api_key="YOUR_OXLO_API_KEY")
@app.post("/translate")
async def translate(file: UploadFile, target_lang: str = "french"):
# 1. Transcribe
transcript = await client.audio.transcriptions.create(
model="whisper-large-v3",
file=file.file,
response_format="text"
)
# 2. Translate
chat = await client.chat.completions.create(
model="qwen3-32b",
messages=[
{
"role": "system",
"content": f"Translate to {target_lang}. Return JSON with key 'translation'."
},
{
"role": "user",
"content": transcript.text
}
],
response_format={"type": "json_object"}
)
payload = json.loads(chat.choices[0].message.content)
return {"translation": payload["translation"]}
Deploying at Scale on Oxlo.ai
Oxlo.ai supports streaming responses for low-latency chat, function calling for agentic workflows, and vision endpoints if you later want to translate text inside images. There are no cold starts on popular models, so the first user of the day does not pay a warmup penalty. Because the API is fully OpenAI SDK compatible, you can migrate existing translation prototypes by changing two lines: the base URL and the API key.
For teams shipping high-volume translation services, the flat per-request model removes the guesswork from budgeting. Long audio files, extended system prompts, and multi-step agentic corrections all count as single requests. That predictability is useful when you are pricing your own product. Review plans and request allowances on the Oxlo.ai pricing page.
Conclusion
Building a language translation app requires chaining speech recognition, language understanding, and optionally speech synthesis. With Oxlo.ai, you can implement the entire pipeline through one OpenAI-compatible endpoint, using Whisper for transcription, Qwen 3 or Llama 3.3 for translation, and Kokoro for voice output. The request-based pricing model keeps costs flat even when input audio or context grows, making Oxlo.ai a practical backbone for developer teams building translation products.
Top comments (0)