This page will help you get started with authenticating to our API.

Before you can start using our API, you need to generate an API Secret Key and obtain your User ID. These are essential to authenticate your requests and access the API's features.

Generating Your API Secret Key and Obtaining Your User ID

Follow these steps to generate your API Secret key and get your User ID:

  1. Visit the API Access page play.ht/studio/api-access
  2. If you haven't already, sign in to your existing account.
  3. Click the "Generate Secret Key" button. Your API Secret Key will be displayed. Make sure to copy and store it securely.
  4. Find your User ID on the same page under the "User ID" section. Copy it for future reference.

Important: Keep your API Secret Key confidential. Do not share it with anyone or include it in publicly accessible code repositories.

Authenticating Your API Requests

After obtaining your API Secret Key and User ID, include them in your API requests to authenticate yourself and access the API's features.

Here are examples of requests with these credentials in the headers:

curl --request POST \
     --url https://play.ht/api/v1/convert \
     --header 'AUTHORIZATION: YOUR_SECRET_KEY_HERE' \
     --header 'X-USER-ID: YOUR_USER_ID_HERE' \
     --header 'accept: application/json' \
     --header 'content-type: application/json' \
     --data '
{
  "content": [
    "Hey you!"
  ],
  "voice": "en-US-JennyNeural"
}
'
import * as PlayHT from 'playht';

PlayHT.init({
  apiKey: '<YOUR_SECRET_KEY_HERE>',
  userId: '<YOUR_USER_ID_HERE>',
});
from pyht import Client

client = Client(  
   user_id="<YOUR_USER_ID_HERE>",  
   api_key="<YOUR_SECRET_KEY_HERE>",  
)
POST /api/v1/convert HTTP/1.1  
Host: play.ht  
Authorization: YOUR_SECRET_KEY_HERE
X-User-Id: YOUR_USER_ID_HERE

Replace YOUR_SECRET_KEY_HERE and YOUR_USER_ID_HERE with your actual API Secret Key and User ID.