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

# TTS - Quickstart

> Start building with ContextLM in under 5 minutes

The ContextLM API delivers a streamlined interface to advanced context-aware speech generation technology. Follow this guide to master implementing natural-sounding speech within your application.

### 1. Create an API Key

<AccordionGroup>
  <Accordion icon="key" title="Create an API Key">
    Follow the link below to create your API Key if you haven't done so already.
    You will need it to interact with ContextLM API.

    <Note>
      If you already have an API Key, skip this step and move to the next
      section.
    </Note>

    <Warning>
      Remember that your API Key is confidential. Do not disclose it to others
      or expose it in any client-side code (browsers, apps).
    </Warning>

    1. Go to [ContextLM.ai](https://contextlm.ai/auth) and sign up or log in. 2.
       Go to [API Keys](https://contextlm.ai/profile) and create a new API Key.
  </Accordion>
</AccordionGroup>

### 2. Make your first request

Make a POST request to this endpoint: `https://api.contextlm.ai/v1/generate_speech` to convert text to speech.

Remember to replace ContextLM\_API\_KEY with your actual API key.

Terminal example

```bash theme={null}
curl -X POST 'https://api.contextlm.ai/v1/generate_speech' \
-H 'x-api-key: $ContextLM_API_KEY' \
-H 'Content-Type: application/json' \
-d '{"text": "Hello World!", "voice_id": "en-US-West-M-HD", "model_id": "vivid", "format": "MP3", "pitch": 0, "speaking_rate": 1.0, "custom_prompt": "Read in a warm and friendly tone."}'
```

Python example

```python theme={null}
import requests

response = requests.post(
    "https://api.contextlm.ai/v1/generate_speech",
    headers={"x-api-key": "$ContextLM_API_KEY"},
    json={"text": "Hello World!", "voice_id": "en-US-West-M-HD", "model_id": "vivid", "format": "MP3", "pitch": 0, "speaking_rate": 1.0, "custom_prompt": "Read in a warm and friendly tone."},
)
```

Javascript example

```javascript theme={null}
const response = await fetch("https://api.contextlm.ai/v1/generate_speech", {
  method: "POST",
  headers: {
    "x-api-key": "$ContextLM_API_KEY",
    "Content-Type": "application/json",
  },
  body: JSON.stringify({
    text: "Hello World!",
    voice_id: "en-US-West-M-HD",
    model_id: "vivid",
    format: "MP3",
    pitch: 0,
    speaking_rate: 1.0,
    custom_prompt: "Read in a warm and friendly tone.",
  }),
});
```

## 3. Configuration

ContextLM supports speech synthesis with a variety of voices and configurations. Checkout the API reference for more details. To try out all the available voices, visit the [Voice Library](https://contextlm.ai/voices) page.

<CardGroup>
  <Card title="API reference" icon="file" href="/api-reference/introduction">
    View the API reference documentation.
  </Card>

  <Card title="Voice library" icon="speaker" href="https://contextlm.ai/voices">
    View the voice library documentation.
  </Card>
</CardGroup>
