POST
/
api
/
v1
/
agents
curl --request POST \
  --url https://api.play.ai/api/v1/agents \
  --header 'Authorization: Bearer <token>' \
  --header 'X-USER-ID: <api-key>' \
  --header 'content-type: <content-type>' \
  --data '{
  "voice": "s3://voice-cloning-zero-shot/baf1ef41-36b6-428c-9bdf-50ba54682bd8/original/manifest.json",
  "voiceSpeed": 1.2,
  "ttsModel": "PlayHT2.0-turbo",
  "displayName": "My Agent",
  "description": "My agent is the best agent",
  "greeting": "Hello! How can I help you today?",
  "prompt": "You are an agent for a company that sells widgets. A customer calls in and asks about the different types of widgets you sell. You should respond by telling the customer about the different types of widgets you sell and how they differ from each other.\n",
  "criticalKnowledge": "We have been in business for 20 years and have sold over 1 million widgets. Currently, we have 3 types of widgets: the standard widget, the deluxe widget, and the super widget. The standard widget is our most popular widget and is the most affordable. The deluxe widget is our mid-range widget and is popular with customers who want a little more than the standard widget. The super widget is our top of the line widget and is popular with customers who want the best of the best.",
  "answerOnlyFromCriticalKnowledge": false,
  "visibility": "public",
  "language": "english",
  "llm": null,
  "actions": [
    "f0gZrOKBKL7veJ6o1M"
  ]
}'
{
  "id": "f0gZrOKBKL7veJ6o1M",
  "voice": "s3://voice-cloning-zero-shot/baf1ef41-36b6-428c-9bdf-50ba54682bd8/original/manifest.json",
  "voiceSpeed": 1.2,
  "ttsModel": "PlayHT2.0-turbo",
  "displayName": "My Agent",
  "description": "My agent is the best agent",
  "greeting": "Hello! How can I help you today?",
  "prompt": "You are an agent for a company that sells widgets. A customer calls in and asks about the different types of widgets you sell. You should respond by telling the customer about the different types of widgets you sell and how they differ from each other.\n",
  "criticalKnowledge": "We have been in business for 20 years and have sold over 1 million widgets. Currently, we have 3 types of widgets: the standard widget, the deluxe widget, and the super widget. The standard widget is our most popular widget and is the most affordable. The deluxe widget is our mid-range widget and is popular with customers who want a little more than the standard widget. The super widget is our top of the line widget and is popular with customers who want the best of the best.",
  "answerOnlyFromCriticalKnowledge": false,
  "visibility": "public",
  "language": "english",
  "llm": null,
  "avatarPhotoUrl": "https://api.play.ai/api/v1/agents/as43.../avatar-photo",
  "criticalKnowledgeFiles": [
    {
      "id": "e0e92064e26257fed1477465...",
      "name": "whatever you want.pdf",
      "url": "https://api.play.ai/api/v1/agents/as43.../critical-knowledge-files/e0e92...",
      "size": 108439,
      "type": "pdf"
    }
  ],
  "phoneNumbers": [
    {
      "phoneNumber": 13659874563,
      "country": "US",
      "locality": "Malibu"
    }
  ],
  "actions": [
    "f0gZrOKBKL7veJ6o1M"
  ]
}

Use this endpoint to create new agents. Required parameters include the agent’s name and the agent’s prompt.

After you create your agent, you can proceed to start a conversation using our Websocket API, or you can try it out through our web interface at https://play.ai/agent/<your-agent-id>.

To update the agents see the Update Agent endpoint.

Authorizations

Authorization
string
header
required

Your secret API key from PlayAI, formatted as Bearer YOUR_SECRET_API_KEY.

X-USER-ID
string
header
required

Your unique user ID from PlayAI.

Headers

content-type
enum<string>
required
Available options:
application/json
accept
enum<string>
Available options:
application/json

Body

application/json
voice
string
required

The unique ID for a PlayAI Voice.

Example:

"s3://voice-cloning-zero-shot/baf1ef41-36b6-428c-9bdf-50ba54682bd8/original/manifest.json"

displayName
string
required

The agent's name

Maximum length: 250
Example:

"My Agent"

description
string
required

The agent's description

Maximum length: 500
Example:

"My agent is the best agent"

voiceSpeed
number | null

The voice speed, i.e. how fast is the agent's speech.

Required range: 0.5 <= x <= 1.5
Example:

1.2

ttsModel
enum<string> | null
default:PlayDialog

The voice model to use for the agent's speech.

Available options:
PlayHT2.0-turbo,
Play3.0-mini,
PlayDialog
Example:

"PlayHT2.0-turbo"

greeting
string | null

The greeting message for the agent

Maximum length: 250
Example:

"Hello! How can I help you today?"

prompt
string | null

Instructions for the agent

Maximum length: 10000
Example:

"You are an agent for a company that sells widgets. A customer calls in and asks about the different types of widgets you sell. You should respond by telling the customer about the different types of widgets you sell and how they differ from each other.\n"

criticalKnowledge
string | null

The agent's critical knowledge

Maximum length: 20000
Example:

"We have been in business for 20 years and have sold over 1 million widgets. Currently, we have 3 types of widgets: the standard widget, the deluxe widget, and the super widget. The standard widget is our most popular widget and is the most affordable. The deluxe widget is our mid-range widget and is popular with customers who want a little more than the standard widget. The super widget is our top of the line widget and is popular with customers who want the best of the best."

answerOnlyFromCriticalKnowledge
boolean
default:false

If true, the agent will only respond with information from the critical knowledge field.

visibility
enum<string>
default:public

The visibility of the agent

Available options:
public,
private
language
enum<string> | null

The language of the agent

Available options:
arabic,
english,
french,
german,
greek,
hindi,
italian,
japanese,
korean,
malay,
mandarin,
polish,
portuguese,
russian,
spanish,
thai,
turkish
Example:

"english"

llm
object | null

Leave this field out or null if you don't want the agent to use your custom LLM API.

actions
string[]

The unique ID for each action.

Response

201 - application/json
Agent resource response.
id
string
required

The unique ID for each agent.

Example:

"f0gZrOKBKL7veJ6o1M"

voice
string
required

The unique ID for a PlayAI Voice.

Example:

"s3://voice-cloning-zero-shot/baf1ef41-36b6-428c-9bdf-50ba54682bd8/original/manifest.json"

displayName
string
required

The agent's name

Maximum length: 250
Example:

"My Agent"

description
string
required

The agent's description

Maximum length: 500
Example:

"My agent is the best agent"

answerOnlyFromCriticalKnowledge
boolean
default:false
required

If true, the agent will only respond with information from the critical knowledge field.

visibility
enum<string>
default:public
required

The visibility of the agent

Available options:
public,
private
voiceSpeed
number | null

The voice speed, i.e. how fast is the agent's speech.

Required range: 0.5 <= x <= 1.5
Example:

1.2

ttsModel
enum<string> | null
default:PlayDialog

The voice model to use for the agent's speech.

Available options:
PlayHT2.0-turbo,
Play3.0-mini,
PlayDialog
Example:

"PlayHT2.0-turbo"

greeting
string | null

The greeting message for the agent

Maximum length: 250
Example:

"Hello! How can I help you today?"

prompt
string | null

Instructions for the agent

Maximum length: 10000
Example:

"You are an agent for a company that sells widgets. A customer calls in and asks about the different types of widgets you sell. You should respond by telling the customer about the different types of widgets you sell and how they differ from each other.\n"

criticalKnowledge
string | null

The agent's critical knowledge

Maximum length: 20000
Example:

"We have been in business for 20 years and have sold over 1 million widgets. Currently, we have 3 types of widgets: the standard widget, the deluxe widget, and the super widget. The standard widget is our most popular widget and is the most affordable. The deluxe widget is our mid-range widget and is popular with customers who want a little more than the standard widget. The super widget is our top of the line widget and is popular with customers who want the best of the best."

language
enum<string> | null

The language of the agent

Available options:
arabic,
english,
french,
german,
greek,
hindi,
italian,
japanese,
korean,
malay,
mandarin,
polish,
portuguese,
russian,
spanish,
thai,
turkish
Example:

"english"

llm
object | null

Leave this field out or null if you don't want the agent to use your custom LLM API.

avatarPhotoUrl
string | null

The URL of the agent's avatar photo

Example:

"https://api.play.ai/api/v1/agents/as43.../avatar-photo"

criticalKnowledgeFiles
object[]
phoneNumbers
object[]
actions
string[]

The unique ID for each action.

Was this page helpful?