Sahif AI
No key

API Documentation

All endpoints accept the API key via Authorization: Bearer, X-API-Key header, or ?key= query.

Authentication

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")
POST/translate

Free Google Translate

Body
{ "text": "Hello", "target": "ur", "source": "auto" }
Response
{ "success": true, "translated": "ہیلو", "detected": "en", "target": "ur" }
POST/tts/docs

Neural TTS (returns audio/mpeg). 20 voices, 14 languages.

Body
{ "text": "Hello", "voice": "star12", "language": "en-US" }
Response
<binary MP3>
GET/tts/voices

List available voices and languages.

Body
Response
{ "voices": [...], "languages": [...], "default": "star12" }
POST/tts/translate

Basic Translate TTS (100+ languages, robotic quality).

Body
{ "text": "Bonjour", "language": "fr" }
Response
<binary MP3>
POST/stt/file

One-shot file STT. POST WebM/Opus body, or JSON { audioBase64 }.

Body
<binary WebM/Opus>  |  { "audioBase64": "...", "language": "en-US" }
Response
{ "success": true, "text": "hello world", "language": "en-US" }
WS/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}.

Body
control + binary audio
Response
streaming JSON
POST/lens/ocr

OCR with line and word bboxes. POST image bytes, or JSON { imageUrl }, or { imageBase64 }.

Body
<image bytes>  |  { "imageUrl": "https://…" }
Response
{ success, language, segments: [...], words: [...], fullText, processingMs }
POST/lens/translate

OCR + native Lens translation. Add targetLanguage.

Body
{ "imageUrl": "…", "targetLanguage": "en" }
Response
{ success, translatedText, matchedLines, segments, words, language }
POST/gemini/chat

Anonymous Gemini chat. Pass sessionId for multi-turn (omit for new session).

Body
{ "prompt": "hi", "sessionId": "optional-uuid" }
Response
{ success, response: "…", sessionId }
POST/gemini/reset

Clear a chat session.

Body
{ "sessionId": "..." }
Response
{ success: true }
GET/suggest?q=hello

Google autocomplete suggestions.

Body
Response
{ success: true, suggestions: ["..."] }