> ## Documentation Index
> Fetch the complete documentation index at: https://docs.slng.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Python SDK

> Install voiceai-sdk on PyPI and call text-to-speech, speech-to-text, and streaming endpoints with sync or async clients.

`voiceai-sdk` is the official Python client for the SLNG API. It targets Python 3.9+ and ships both a synchronous `Slng` client and an `AsyncSlng` for asyncio code.

## Install

```bash theme={null}
pip install voiceai-sdk
```

Or with `uv`:

```bash theme={null}
uv add voiceai-sdk
```

## Initialize the client

Get an SLNG key from [app.slng.ai](https://app.slng.ai/api-keys), then construct the client:

```python theme={null}
from voiceai_sdk import Slng

client = Slng()                      # reads SLNG_API_KEY
client = Slng(api_key="zpka_...")    # or pass it explicitly
```

## Text-to-speech

```python theme={null}
from voiceai_sdk import Slng

client = Slng()

audio = client.text_to_speech.create(
    model_variant="slng/deepgram/aura:2-en",
    text="Hello from the SLNG Python SDK.",
    voice="aura-2-thalia-en",
)

audio.write_to_file("hello.wav")
```

## Speech-to-text

```python theme={null}
from pathlib import Path
from voiceai_sdk import Slng

client = Slng()

transcript = client.speech_to_text.create(
    model_variant="slng/deepgram/nova:3-en",
    audio=Path("meeting.wav"),
)

print(transcript.text)
```

## Async client

For asyncio applications, swap `Slng` for `AsyncSlng`:

```python theme={null}
import asyncio
from pathlib import Path
from voiceai_sdk import AsyncSlng

async def main():
    client = AsyncSlng()
    transcript = await client.speech_to_text.create(
        model_variant="slng/deepgram/nova:3-en",
        audio=Path("meeting.wav"),
    )
    print(transcript.text)

asyncio.run(main())
```

## Discover models

```python theme={null}
models = client.models.list()
voices = client.voices.list(model="slng/deepgram/aura:2-en")
```

## Links

* PyPI: [pypi.org/project/voiceai-sdk](https://pypi.org/project/voiceai-sdk/)
* Source: [github.com/slng-ai/sdks](https://github.com/slng-ai/sdks)
