API Documentation
All endpoints accept the API key via Authorization: Bearer, X-API-Key header, or ?key= query.
All endpoints (except /, /health, /test) require an API key.
# Header (recommended)
curl https://testing-api.sahifai.com/translate \
-H "Authorization: Bearer YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"text":"hi","target":"ur"}'
# WebSocket (use query param — browsers can't set headers)
new WebSocket("wss://testing-api.sahifai.com/stt/live?key=YOUR_KEY")/translateFree Google Translate
{ "text": "Hello", "target": "ur", "source": "auto" }{ "success": true, "translated": "ہیلو", "detected": "en", "target": "ur" }/tts/docsNeural TTS (returns audio/mpeg). 20 voices, 14 languages.
{ "text": "Hello", "voice": "star12", "language": "en-US" }<binary MP3>
/tts/voicesList available voices and languages.
—
{ "voices": [...], "languages": [...], "default": "star12" }/tts/translateBasic Translate TTS (100+ languages, robotic quality).
{ "text": "Bonjour", "language": "fr" }<binary MP3>
/stt/fileOne-shot file STT. POST WebM/Opus body, or JSON { audioBase64 }.
<binary WebM/Opus> | { "audioBase64": "...", "language": "en-US" }{ "success": true, "text": "hello world", "language": "en-US" }/stt/live?key=…Live streaming STT. Send {type:'start',language:'en-US'} → binary Opus frames → {type:'stop'}. Receives {type:'partial'|'final'|'ready'|'stopped'|'error', text}.
control + binary audio
streaming JSON
/lens/ocrOCR with line and word bboxes. POST image bytes, or JSON { imageUrl }, or { imageBase64 }.
<image bytes> | { "imageUrl": "https://…" }{ success, language, segments: [...], words: [...], fullText, processingMs }/lens/translateOCR + native Lens translation. Add targetLanguage.
{ "imageUrl": "…", "targetLanguage": "en" }{ success, translatedText, matchedLines, segments, words, language }/gemini/chatAnonymous Gemini chat. Pass sessionId for multi-turn (omit for new session).
{ "prompt": "hi", "sessionId": "optional-uuid" }{ success, response: "…", sessionId }/gemini/resetClear a chat session.
{ "sessionId": "..." }{ success: true }/suggest?q=helloGoogle autocomplete suggestions.
—
{ success: true, suggestions: ["..."] }