> ## 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

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

`voiceai-sdk` is the official Python client for the SLNG API. It targets Python
3.9+ and ships 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

Create a key at [app.slng.ai](https://app.slng.ai/api-keys), or see
[Create your API key](/guides/get-started/quickstart#create-your-api-key),
then construct the client:

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

client = Slng()                      # reads SLNG_API_KEY
client = Slng(api_key="slng_cu_...")    # 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 sunny Barcelona!",
    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)
