Translation
Interact with AI models in Ethiopian languages (Amharic, Somali, Tigrinya, Oromo, Afar) with automatic translation between your language and English.
Overview
Selam API provides seamless translation support for Ethiopian languages. Send requests in your native language and receive responses in the same language, with translation happening automatically behind the scenes. All translation features work with existing endpoints and are fully backward compatible.
Auto-Detection
Automatically detect your language and translate both input and output seamlessly.
6 Languages
Support for English, Amharic, Somali, Tigrinya, Oromo, and Afar languages.
Streaming Support
Translation works with both standard and streaming responses for real-time applications.
Information
Translation Modes
Selam API supports two translation modes to fit different use cases:
Auto-Detection Mode
Automatically detects your input language and translates both your message to English (for the AI) and the AI's response back to your detected language.
When to use:
- •You want to write in your native Ethiopian language
- •You want responses in the same language you used
- •You don't want to specify language codes manually
How it works:
- You send a message in any supported language
- System detects your language automatically
- Translates your message to English for the AI model
- Translates the AI response back to your detected language
Target Language Mode
Specify the exact language you want responses in, regardless of your input language. This gives you precise control over the output language.
When to use:
- •You want to specify exactly which language to receive responses in
- •You might write in English but want responses in an Ethiopian language
- •You want to practice a specific language
How it works:
- You send a message in any language
- System translates your message to English for the AI model
- Translates the AI response to your specified target language
Supported Languages
Selam API supports 6 languages for translation:
enEnglishEnglish
amAmharicአማርኛ
soSomaliSoomaali
tiTigrinyaትግርኛ
omOromoAfaan Oromoo
aaAfarQafar
Tip
/v1/languages endpoint. See the Languages API Reference for details.Auto-Detection Mode
Use auto-detection mode by setting translation_mode: "auto" in your request. The system will automatically detect your language and respond in the same language.
1from openai import OpenAI
2
3client = OpenAI(
4 api_key="your-api-key",
5 base_url="https://api.selamgpt.com/v1"
6)
7
8# Send message in Amharic with auto-detection
9response = client.chat.completions.create(
10 model="selam-turbo",
11 messages=[
12 {"role": "user", "content": "ሰላም! እንዴት ነህ?"}
13 ],
14 extra_body={
15 "translation_mode": "auto"
16 }
17)
18
19# Response will be in Amharic
20print(response.choices[0].message.content)
21
22# Check translation metadata
23if hasattr(response, 'translation_metadata'):
24 metadata = response.translation_metadata
25 print(f"Detected language: {metadata.get('detected_language')}")
26 print(f"Translation time: {metadata.get('translation_time_ms')}ms")Information
translation_metadata with the detected language, target language, and translation time in milliseconds.Target Language Mode
Use target language mode by setting target_language to your desired language code. The system will translate responses to your specified language regardless of your input language.
1from openai import OpenAI
2
3client = OpenAI(
4 api_key="your-api-key",
5 base_url="https://api.selamgpt.com/v1"
6)
7
8# Send message in English, get response in Amharic
9response = client.chat.completions.create(
10 model="selam-turbo",
11 messages=[
12 {"role": "user", "content": "Tell me about Ethiopia"}
13 ],
14 extra_body={
15 "target_language": "am"
16 }
17)
18
19# Response will be in Amharic
20print(response.choices[0].message.content)
21
22# Try different target languages
23for lang_code in ["ti", "so", "om"]:
24 response = client.chat.completions.create(
25 model="selam-turbo",
26 messages=[
27 {"role": "user", "content": "Hello, how are you?"}
28 ],
29 extra_body={
30 "target_language": lang_code
31 }
32 )
33 print(f"{lang_code}: {response.choices[0].message.content}")Translation in Chat Completions
Translation works seamlessly with the chat completions endpoint, supporting multi-turn conversations and streaming responses.
Multi-Turn Conversations
Maintain conversation context across multiple turns with translation:
1from openai import OpenAI
2
3client = OpenAI(
4 api_key="your-api-key",
5 base_url="https://api.selamgpt.com/v1"
6)
7
8# Start conversation in Amharic
9messages = [
10 {"role": "user", "content": "ሰላም! ስለ ኢትዮጵያ ንገረኝ"}
11]
12
13response = client.chat.completions.create(
14 model="selam-turbo",
15 messages=messages,
16 extra_body={"translation_mode": "auto"}
17)
18
19# Add assistant response to conversation
20messages.append({
21 "role": "assistant",
22 "content": response.choices[0].message.content
23})
24
25# Continue conversation
26messages.append({
27 "role": "user",
28 "content": "ስለ አዲስ አበባ ተጨማሪ ንገረኝ"
29})
30
31response = client.chat.completions.create(
32 model="selam-turbo",
33 messages=messages,
34 extra_body={"translation_mode": "auto"}
35)
36
37print(response.choices[0].message.content)Streaming with Translation
Translation works with streaming responses for real-time applications:
1from openai import OpenAI
2
3client = OpenAI(
4 api_key="your-api-key",
5 base_url="https://api.selamgpt.com/v1"
6)
7
8# Stream response with translation
9stream = client.chat.completions.create(
10 model="selam-turbo",
11 messages=[
12 {"role": "user", "content": "ስለ ኢትዮጵያ ታሪክ ንገረኝ"}
13 ],
14 extra_body={"translation_mode": "auto"},
15 stream=True
16)
17
18for chunk in stream:
19 if chunk.choices[0].delta.content:
20 print(chunk.choices[0].delta.content, end="", flush=True)
21
22# Translation metadata appears in the final chunk
23print("\n\nTranslation complete!")Information
[DONE].Translation in Voice Agents
Voice Agent supports real-time translation for voice conversations. Speak in any supported language and get responses in your preferred language.
Auto-Detection in Voice Agent
Voice Agent automatically detects your spoken language and responds in the same language:
1import { io } from 'socket.io-client';
2
3// Connect to Voice Agent
4const socket = io('wss://api.selamgpt.com/v1/audio/agent', {
5 query: {
6 token: 'your-jwt-token',
7 api_key: 'your-api-key',
8 voice: 'mekdes' // Amharic voice
9 },
10 transports: ['websocket']
11});
12
13socket.on('connected', () => {
14 // Start session without specifying language
15 // Voice Agent will auto-detect from speech
16 socket.emit('start_session', {
17 voice: 'mekdes',
18 instructions: 'You are a helpful assistant.'
19 // No language parameter - auto-detect mode
20 });
21});
22
23// Speak in Amharic, get responses in Amharic
24// Speak in English, get responses in EnglishTarget Language in Voice Agent
Specify a target language to always receive responses in that language:
1import { io } from 'socket.io-client';
2import PageFeedback from '@/components/docs/PageFeedback';
3
4const socket = io('wss://api.selamgpt.com/v1/audio/agent', {
5 query: {
6 token: 'your-jwt-token',
7 api_key: 'your-api-key',
8 voice: 'ubax' // Somali voice
9 },
10 transports: ['websocket']
11});
12
13socket.on('connected', () => {
14 // Start session with target language
15 socket.emit('start_session', {
16 voice: 'ubax',
17 language: 'so', // Always respond in Somali
18 instructions: 'You are a helpful assistant.'
19 });
20});
21
22// Speak in any language, get responses in SomaliTip
mekdes for Amharic, ubax for Somali, sami for Tigrinya. See the Voice Agent Guide for more details.Best Practices
Choose the Right Mode
- •Use auto mode when you want the simplest experience and will consistently use one language
- •Use target mode when you need precise control over output language
- •Use default mode (no translation) when working in English to avoid translation overhead
Handle Errors Gracefully
- •Always check for translation errors and provide fallback behavior
- •Implement retry logic for translation service unavailability (503 errors)
- •Handle language detection failures by falling back to target mode
Monitor Performance
- •Use
translation_metadatato track translation performance - •Translation adds ~200-500ms overhead - factor this into your application design
- •Use streaming for long responses to improve perceived latency
Ensure Proper Encoding
- •Always use UTF-8 encoding for proper Unicode support
- •Set
Content-Type: application/json; charset=utf-8header - •Verify your terminal/console supports UTF-8 for Ethiopian scripts
Test with Multiple Languages
- •Test your integration with all supported Ethiopian languages
- •Verify proper Unicode handling for each language's script
- •Test edge cases like mixed-language input and special characters
Optimize Input Length
- •Language detection works best with messages of at least 10-20 characters
- •For very short messages, consider using target mode instead of auto mode
- •Provide context in longer messages for better translation quality
Related Resources
Was this page helpful?