Perplexity API
Create Async Chat Completion
Creates an asynchronous chat completion job.
POST
/
async
/
chat
/
completions
curl --request POST \
--url https://api.perplexity.ai/async/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"request": {
"model": "sonar",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
},
{
"role": "user",
"content": "How many stars are there in our galaxy?"
}
],
"max_tokens": 123,
"temperature": 0.2,
"top_p": 0.9,
"search_domain_filter": [
"<any>"
],
"return_images": false,
"return_related_questions": false,
"search_recency_filter": "<string>",
"search_after_date_filter": "<string>",
"search_before_date_filter": "<string>",
"top_k": 0,
"stream": false,
"presence_penalty": 0,
"frequency_penalty": 1,
"response_format": {},
"web_search_options": {
"search_context_size": "high"
}
}
}'
{
"id": "<string>",
"model": "<string>",
"created_at": 123,
"started_at": 123,
"completed_at": 123,
"response": {
"id": "<string>",
"model": "<string>",
"created": 123,
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"search_context_size": "<string>",
"citation_tokens": 123,
"num_search_queries": 123,
"reasoning_tokens": 123
},
"object": "chat.completion",
"choices": [
{
"index": 123,
"finish_reason": "stop",
"message": {
"content": "<string>",
"role": "system"
}
}
],
"citations": [
"<string>"
],
"search_results": [
{
"title": "<string>",
"url": "<string>",
"date": "2023-12-25"
}
]
},
"failed_at": 123,
"error_message": "<string>",
"status": "CREATED"
}
Authorizations
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
Body
application/json
Response
200 - application/json
Successfully created async chat completion job.
The response is of type object
.
curl --request POST \
--url https://api.perplexity.ai/async/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"request": {
"model": "sonar",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
},
{
"role": "user",
"content": "How many stars are there in our galaxy?"
}
],
"max_tokens": 123,
"temperature": 0.2,
"top_p": 0.9,
"search_domain_filter": [
"<any>"
],
"return_images": false,
"return_related_questions": false,
"search_recency_filter": "<string>",
"search_after_date_filter": "<string>",
"search_before_date_filter": "<string>",
"top_k": 0,
"stream": false,
"presence_penalty": 0,
"frequency_penalty": 1,
"response_format": {},
"web_search_options": {
"search_context_size": "high"
}
}
}'
{
"id": "<string>",
"model": "<string>",
"created_at": 123,
"started_at": 123,
"completed_at": 123,
"response": {
"id": "<string>",
"model": "<string>",
"created": 123,
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"search_context_size": "<string>",
"citation_tokens": 123,
"num_search_queries": 123,
"reasoning_tokens": 123
},
"object": "chat.completion",
"choices": [
{
"index": 123,
"finish_reason": "stop",
"message": {
"content": "<string>",
"role": "system"
}
}
],
"citations": [
"<string>"
],
"search_results": [
{
"title": "<string>",
"url": "<string>",
"date": "2023-12-25"
}
]
},
"failed_at": 123,
"error_message": "<string>",
"status": "CREATED"
}
Assistant
Responses are generated using AI and may contain mistakes.