Skip to main content
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

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.
If you already have an API Key, skip this step and move to the next section.
Remember that your API Key is confidential. Do not disclose it to others or expose it in any client-side code (browsers, apps).
  1. Go to ContextLM.ai and sign up or log in. 2. Go to API Keys and create a new API Key.

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
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-William-M-HD"}'
Python example
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-William-M-HD"},
)
Javascript example
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-William-M-HD",
  }),
});

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 page.