Generates a model’s response for the given chat conversation.
curl --request POST \
--url https://api.perplexity.ai/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "sonar",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
},
{
"role": "user",
"content": "How many stars are there in our galaxy?"
}
]
}'
{
"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"
}
]
}
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
OK
The response is of type object
.
curl --request POST \
--url https://api.perplexity.ai/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "sonar",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
},
{
"role": "user",
"content": "How many stars are there in our galaxy?"
}
]
}'
{
"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"
}
]
}
Generates a model’s response for the given chat conversation.
curl --request POST \
--url https://api.perplexity.ai/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "sonar",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
},
{
"role": "user",
"content": "How many stars are there in our galaxy?"
}
]
}'
{
"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"
}
]
}
Bearer authentication header of the form Bearer <token>
, where <token>
is your auth token.
OK
The response is of type object
.
curl --request POST \
--url https://api.perplexity.ai/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"model": "sonar",
"messages": [
{
"role": "system",
"content": "Be precise and concise."
},
{
"role": "user",
"content": "How many stars are there in our galaxy?"
}
]
}'
{
"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"
}
]
}