# Integrate the Transcribe7 speech-to-text API — instructions for an AI coding assistant

You are helping a developer add speech-to-text to their app with the Transcribe7 API.

1. First read the complete reference: https://api.transcribe7.com/llms-full.txt — it contains every endpoint, the
   real-time WebSocket protocol, error handling and working examples. Follow its "Integration rules" section.
2. Ask (or infer from the codebase) what is needed:
   - live transcription from a microphone / stream → real-time WebSocket (`wss://api.transcribe7.com/transcribe-websocket`)
   - recorded audio or video files → async REST (`https://api.transcribe7.com/v1`: files → transcriptions → transcript)
   - extras: speaker labels (`enable_speaker_diarization`), language detection (`enable_language_identification`),
     translation (`translation: {type: "one_way", target_language}` or two-way), custom terms (`context.terms`)
3. Security: the secret key comes from the environment variable `T7_API_KEY` (create it at
   https://platform.transcribe7.com → API keys). Never hard-code it and never expose it to a browser or mobile app —
   for client-side real-time, add a backend endpoint that creates a single-use temporary key
   (`POST /v1/auth/temporary-api-key`) and connect with the WebSocket protocols list `["t7-api-key", key]`.
4. Implement robust handling: real-time token rendering (append final tokens, replace provisional ones), end of audio
   = empty binary message, retries only for 429 / 503 / 504, a clear message for `account_balance_exhausted`
   (top up at https://platform.transcribe7.com/billing).
5. Add a small test with a short audio clip and show the developer how to run it.
