Translation Tool
ChimerAI's Translation Tool provides AI-powered text translation across 50+ languages using your configured LLM — no third-party translation API key needed.
What you get
- 50+ languages — All major world languages
- LLM-powered — Uses your existing AI model (GPT-4o, Claude, etc.)
- Tone control — Formal, casual, technical, business styles
- Batch translation — Translate multiple texts in one call
- Glossary support — Custom term mappings per workspace
- HTML-aware — Preserves HTML tags while translating content
Quick setup
npx chimerai add ai-tools --only translate
Scaffolds:
app/api/tools/translate/route.ts ← Translation endpoint
services/ai/tools/translate_tools.py ← Python LLM translation
Usage
const res = await fetch('/api/tools/translate', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
text: 'Hello, how are you?',
targetLanguage: 'German',
sourceLanguage: 'auto', // auto-detect
tone: 'formal', // 'formal' | 'casual' | 'technical'
}),
});
const { translation, detectedLanguage, confidence } = await res.json();
Batch translation
const res = await fetch('/api/tools/translate/batch', {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify({
texts: ['Hello', 'Goodbye', 'Thank you'],
targetLanguage: 'Japanese',
}),
});
const { translations } = await res.json();
// translations: string[]
Python implementation
from openai import AsyncOpenAI
client = AsyncOpenAI()
async def translate_text(
text: str,
target_language: str,
source_language: str = "auto",
tone: str = "neutral"
) -> dict:
system = f"""You are a professional translator.
Translate text to {target_language}.
Tone: {tone}.
Return ONLY the translation, no explanations."""
if source_language != "auto":
system += f"\nSource language: {source_language}."
response = await client.chat.completions.create(
model="gpt-4o-mini",
messages=[
{"role": "system", "content": system},
{"role": "user", "content": text},
],
temperature=0.2,
)
return {"translation": response.choices[0].message.content.strip()}
Integrating in your app
// Translate user content before storing:
const { translation } = await translateText({
text: userMessage,
targetLanguage: workspace.language ?? 'English',
});
// Translate AI responses on the fly:
const aiResponse = await callAI(prompt);
const localised = await translateText({ text: aiResponse, targetLanguage: user.locale });