curl --request POST \
--url https://api.perplexity.ai/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"role": "system",
"content": "<string>"
}
]
}
'{
"id": "<string>",
"model": "<string>",
"created": 123,
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"reasoning_steps": [
{
"thought": "<string>",
"type": "<string>",
"web_search": {
"search_results": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
],
"search_keywords": [
"<string>"
]
},
"fetch_url_content": {
"contents": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
]
},
"execute_python": {
"code": "<string>",
"result": "<string>"
}
}
],
"tool_calls": [
{
"id": "<string>",
"type": "<string>",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>"
},
"delta": {
"role": "system",
"content": "<string>",
"reasoning_steps": [
{
"thought": "<string>",
"type": "<string>",
"web_search": {
"search_results": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
],
"search_keywords": [
"<string>"
]
},
"fetch_url_content": {
"contents": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
]
},
"execute_python": {
"code": "<string>",
"result": "<string>"
}
}
],
"tool_calls": [
{
"id": "<string>",
"type": "<string>",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"cost": {
"input_tokens_cost": 123,
"output_tokens_cost": 123,
"total_cost": 123,
"reasoning_tokens_cost": 123,
"request_cost": 123,
"citation_tokens_cost": 123,
"search_queries_cost": 123
},
"search_context_size": "<string>",
"citation_tokens": 123,
"num_search_queries": 123,
"reasoning_tokens": 123
},
"object": "chat.completion",
"citations": [
"<string>"
],
"search_results": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
],
"type": "message",
"status": "PENDING"
}Generate a chat completion response for the given conversation.
curl --request POST \
--url https://api.perplexity.ai/chat/completions \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"model": "<string>",
"messages": [
{
"role": "system",
"content": "<string>"
}
]
}
'{
"id": "<string>",
"model": "<string>",
"created": 123,
"choices": [
{
"index": 123,
"message": {
"role": "system",
"content": "<string>",
"reasoning_steps": [
{
"thought": "<string>",
"type": "<string>",
"web_search": {
"search_results": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
],
"search_keywords": [
"<string>"
]
},
"fetch_url_content": {
"contents": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
]
},
"execute_python": {
"code": "<string>",
"result": "<string>"
}
}
],
"tool_calls": [
{
"id": "<string>",
"type": "<string>",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>"
},
"delta": {
"role": "system",
"content": "<string>",
"reasoning_steps": [
{
"thought": "<string>",
"type": "<string>",
"web_search": {
"search_results": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
],
"search_keywords": [
"<string>"
]
},
"fetch_url_content": {
"contents": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
]
},
"execute_python": {
"code": "<string>",
"result": "<string>"
}
}
],
"tool_calls": [
{
"id": "<string>",
"type": "<string>",
"function": {
"name": "<string>",
"arguments": "<string>"
}
}
],
"tool_call_id": "<string>"
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 123,
"completion_tokens": 123,
"total_tokens": 123,
"cost": {
"input_tokens_cost": 123,
"output_tokens_cost": 123,
"total_cost": 123,
"reasoning_tokens_cost": 123,
"request_cost": 123,
"citation_tokens_cost": 123,
"search_queries_cost": 123
},
"search_context_size": "<string>",
"citation_tokens": 123,
"num_search_queries": 123,
"reasoning_tokens": 123
},
"object": "chat.completion",
"citations": [
"<string>"
],
"search_results": [
{
"title": "<string>",
"url": "<string>",
"date": "<string>",
"last_updated": "<string>",
"snippet": "",
"source": "web"
}
],
"type": "message",
"status": "PENDING"
}Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Show child attributes
0 < x <= 128000Optional. Controls the output format. Omit for default text output. Set type to json_schema for structured output.
Show child attributes
Show child attributes
web, academic, sec hour, day, week, month, year full, concise minimal, low, medium, high Successful Response
Show child attributes
Show child attributes
Show child attributes
message, info, end_of_stream PENDING, COMPLETED Was this page helpful?