--- title: Sema Translation API emoji: 🌍 colorFrom: blue colorTo: green sdk: docker pinned: false license: mit short_description: Translation API using consolidated sema-utils models --- # Sema Translation API 🌍 A powerful translation API that supports multiple African languages using the consolidated `sematech/sema-utils` model repository. ## Features - **Automatic Language Detection**: Detects source language automatically if not provided - **Multi-language Support**: Supports 200+ languages via FLORES-200 codes - **Fast Translation**: Uses CTranslate2 for optimized inference - **RESTful API**: Clean FastAPI interface with automatic documentation - **Consolidated Models**: Uses models from the unified `sematech/sema-utils` repository ## API Endpoints ### `GET /` Health check endpoint that returns API status and version information. ### `POST /translate` Main translation endpoint that accepts: **Request Body:** ```json { "text": "Habari ya asubuhi", "target_language": "eng_Latn", "source_language": "swh_Latn" } ``` **Response:** ```json { "translated_text": "Good morning", "source_language": "swh_Latn", "target_language": "eng_Latn", "inference_time": 0.234, "timestamp": "Monday | 2024-06-21 | 14:30:25" } ``` ## Language Codes This API uses FLORES-200 language codes. Some common examples: - `eng_Latn` - English - `swh_Latn` - Swahili - `kik_Latn` - Kikuyu - `luo_Latn` - Luo - `fra_Latn` - French - `spa_Latn` - Spanish ## Usage Examples ### Python ```python import requests response = requests.post("https://your-space-url/translate", json={ "text": "Habari ya asubuhi", "target_language": "eng_Latn" }) print(response.json()) ``` ### cURL ```bash curl -X POST "https://your-space-url/translate" \ -H "Content-Type: application/json" \ -d '{ "text": "Wĩ mwega?", "source_language": "kik_Latn", "target_language": "eng_Latn" }' ``` ## Model Information This API uses models from the consolidated `sematech/sema-utils` repository: - **Translation Model**: `sematrans-3.3B` (CTranslate2 optimized) - **Language Detection**: `lid218e.bin` (FastText) - **Tokenization**: `spm.model` (SentencePiece) ## API Documentation Once the Space is running, visit `/docs` for interactive API documentation. --- Created by Lewis Kamau Kimaru | Sema AI