API Keys
An API Key authenticates every request to the Palabra API — REST calls, WebSocket streams, and WebRTC sessions alike. This page covers how to create one and how to use it once you have it.
Obtaining an API Key
Prerequisites
Get an API Key
To get your Palabra API Key, follow the steps below:
- Log in to the Palabra Platform
- Navigate to the API Keys page
- Create a new API Key
- Copy and save the API Key
Using API Keys
REST API Requests
Pass the API Key in the Authorization: Bearer <API_KEY> header in every request to the Palabra API endpoints listed in the API Reference.
WebSocket Streaming APIs
When connecting to the real-time WebSocket endpoints (Speech-to-Speech, Speech-to-Text, Text-to-Speech), pass the API Key in the Authorization header or in the token query parameter — the server validates the key and creates a streaming session for you automatically. See the docs of each streaming API for the endpoint URLs.
Code Sample
The example below shows how to send a request to the built-in voices API endpoint.
Built-in Voices Request Code Sample
curl -L 'https://api.palabra.ai/saas/voice/builtin' \
-H 'Accept: application/json' \
-H 'Authorization: Bearer <YourApiKey>'
import requests
url = 'https://api.palabra.ai/saas/voice/builtin'
headers = {
'Accept': 'application/json',
'Authorization': 'Bearer <YourApiKey>',
}
response = requests.get(url, headers=headers)
# Print the response status code and content
print(response.status_code)
print(response.json())
package main
import (
"fmt"
"net/http"
"io/ioutil"
)
func main() {
url := "https://api.palabra.ai/saas/voice/builtin"
req, err := http.NewRequest("GET", url, nil)
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Set headers
req.Header.Set("Accept", "application/json")
req.Header.Set("Authorization", "Bearer <YourApiKey>")
// Perform the request
client := &http.Client{}
resp, err := client.Do(req)
if err != nil {
fmt.Println("Error making request:", err)
return
}
defer resp.Body.Close()
// Read and print the response
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("Error reading response body:", err)
return
}
fmt.Println("Status Code:", resp.StatusCode)
fmt.Println("Response Body:", string(body))
}
const axios = require('axios');
const url = 'https://api.palabra.ai/saas/voice/builtin';
const headers = {
'Accept': 'application/json',
'Authorization': 'Bearer <YourApiKey>'
};
axios.get(url, { headers })
.then(response => {
console.log('Status Code:', response.status);
console.log('Response Data:', response.data);
})
.catch(error => {
console.error('Error making request:', error);
});