How to authenticate your Talk API requests
All Talk API endpoints require authentication using a unified do.dev API key.
talk service enableddo_live_* keyPass your API key as a Bearer token in the Authorization header:
curl -X POST "https://api.do.dev/v1/talk/speech" \
-H "Authorization: Bearer do_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{"text": "Hello world", "voice": "aria"}'Pass your API key in the X-API-Key header:
curl -X POST "https://api.do.dev/v1/talk/speech" \
-H "X-API-Key: do_live_your_key_here" \
-H "Content-Type: application/json" \
-d '{"text": "Hello world", "voice": "aria"}'Which method should I use?
We recommend using Bearer token or X-API-Key header as they keep your API key out of server logs and browser history.
Talk API endpoints require specific scopes on your API key:
| Endpoint | Required Scope |
|---|---|
POST /v1/talk/speech | talk:speech |
GET /v1/talk/voices | talk:voices |
GET /v1/talk/formats | talk:formats |
Use talk:* to grant access to all Talk endpoints.
If no API key is provided, you'll receive a 401 Unauthorized response:
{
"error": "API key required. Use Authorization: Bearer <key> or X-API-Key header."
}If the API key is invalid or inactive:
{
"error": "Invalid API key"
}If the API key lacks the required scope:
{
"error": "Insufficient scope. Required: talk:speech"
}If the API key doesn't have the talk service enabled:
{
"error": "API key does not have access to the talk service"
}const apiKey = process.env.DO_API_KEY;
const response = await fetch("https://api.do.dev/v1/talk/speech", {
method: "POST",
headers: {
"Authorization": `Bearer ${apiKey}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
text: "Hello world",
voice: "aria"
})
});import os
import requests
api_key = os.environ.get("DO_API_KEY")
response = requests.post(
"https://api.do.dev/v1/talk/speech",
headers={
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
},
json={"text": "Hello world", "voice": "aria"}
)