Skip to main content

Overview

gnani-vachana is the official Python client for the Gnani Speech APIs. It wraps STT and TTS across all three transports — REST, SSE, and WebSocket — so you never hand-roll multipart uploads, SSE frame parsing, WAV headers, or WebSocket lifecycles.
The package is dependency-light — requests and websockets only — ships type hints (py.typed), and is maintained by Gnani.ai.
The PyPI package is gnani-vachana, but the Python import package is gnani. Install gnani-vachana, then from gnani.stt import ....

Installation

Or with uv:
Requirements: Python 3.9+

Authentication

You need a Gnani API key — generate one on the Gnani API platform. A single API key authenticates both STT and TTS; no organization_id or user_id is required. The recommended approach is the GNANI_API_KEY environment variable, which every client reads automatically:
Or pass it explicitly:
If neither is present, the constructor raises AuthenticationError immediately — before any network call.
If you are upgrading from an SDK version older than 0.7.x, remove the organization_id and user_id constructor arguments. They are no longer accepted.

Choosing a client

Each API has one class per transport. Pick by latency requirement, not by preference — they return the same audio and the same transcripts.

Speech-to-Text

Text-to-Speech

The two streaming STT/TTS clients are async; the REST and SSE clients are ordinary synchronous Python. You can mix them freely in the same program.

Your first request

Continue to Speech-to-Text →
Always pass model="timbre-v2.5" on TTS calls. The SDK still defaults to timbre-v2.0, which the API no longer serves — omitting model returns 400 with The supported models are "timbre-v2.5".

Error handling

Each sub-package defines its own exception hierarchy, rooted at GnaniSTTError and GnaniTTSError. Catching the root class catches everything the SDK raises.
ValueError is raised — before any request leaves your process — for invalid parameter combinations such as an unknown voice, an unsupported sample rate, or speed outside 0.851.15.

Request IDs

Every method accepts an optional request_id. When omitted, the SDK generates one and sends it as X-API-Request-ID. It is echoed back in STT REST responses and in TTS WebSocket events.
Log it. It is the fastest way for Gnani support to trace a single call end to end.

Pointing at a different environment

All clients take base_url, defaulting to https://api.vachana.ai. The streaming clients derive their WebSocket URL from it automatically (httpswss).

Further Reading

Speech-to-Text

REST transcription and realtime streaming with the Python SDK.

Text-to-Speech

REST, SSE, and WebSocket synthesis with the Python SDK.