Skip to main content
Perplexity

Search documentation

Type to search this documentation.

Get Async Chat Completion

GET/v1/async/sonar/{api_request}Get Async Chat Completion

Retrieve the response for a given asynchronous chat completion request.

Parameters

api_requeststringpathrequired

Responses

200Successful Responseapplication/json
objectAsyncApiChatCompletionsResponse

AsyncApiChatCompletionsResponse

completed_atvalue

Unix timestamp when processing completed

Show child attributes
anyOf · 2 options
Option 1integer
Option 2nullnullable
created_atintegerrequired

Unix timestamp when the request was created

error_messagevalue

Error message if the request failed

Show child attributes
anyOf · 2 options
Option 1string
Option 2nullnullable
failed_atvalue

Unix timestamp when the request failed (if applicable)

Show child attributes
anyOf · 2 options
Option 1integer
Option 2nullnullable
idstringrequired

Unique identifier for the async request

modelstringrequired

Model used for the request

responsevalue
Show child attributes
anyOf · 2 options
Option 1objectCompletionResponse

CompletionResponse

choicesarray of objectrequired

Array of completion choices

Show child attributes
Show array items

A single completion choice

deltaobjectrequired
Show child attributes
contentvaluerequired
Show child attributes
anyOf · 3 options
Option 1string
Option 2array of value

Structured Content

Show array items
anyOf · 5 options
Option 1objectChatMessageContentTextChunk

ChatMessageContentTextChunk

textstringrequired
typestringrequired

const "text"

Option 2objectChatMessageContentImageChunk

ChatMessageContentImageChunk

image_urlvaluerequired
Show child attributes
anyOf · 2 options
Option 1objectURL

URL

urlstringrequired
Option 2string
typestringrequired

const "image_url"

Option 3objectChatMessageContentFileChunk

ChatMessageContentFileChunk

file_namevalue
Show child attributes
anyOf · 2 options
Option 1string
Option 2nullnullable
file_urlvaluerequired
Show child attributes
anyOf · 2 options

Option 1: URL ↑

Option 2string
typestringrequired

const "file_url"

Option 4objectChatMessageContentPDFChunk

ChatMessageContentPDFChunk

pdf_urlvaluerequired
Show child attributes
anyOf · 2 options

Option 1: URL ↑

Option 2string
typestringrequired

const "pdf_url"

Option 5objectChatMessageContentVideoChunk

ChatMessageContentVideoChunk

typestringrequired

const "video_url"

video_urlvaluerequired
Show child attributes
anyOf · 2 options
Option 1objectVideoURL

VideoURL

frame_intervalvalue

default 25

Show child attributes

default 25

anyOf · 2 options
Option 1string
Option 2integer
urlstringrequired
Option 2string
Option 3nullnullable
rolestringrequired

Chat roles enum

one of "system", "user", "assistant", "tool"

finish_reasonvalue

Reason generation stopped (stop or length)

Show child attributes
anyOf · 2 options
Option 1string

one of "stop", "length"

Option 2nullnullable
indexintegerrequired

Index of the choice in the array

messageobjectrequiredChatMessage-Output ↑
citationsvalue

URLs of sources used to generate the response

Show child attributes
anyOf · 2 options
Option 1array of string
Option 2nullnullable
createdintegerrequired

Unix timestamp when the completion was created

idstringrequired

Unique identifier for the completion

imagesvalue

Array of images returned when return_images is true

Show child attributes
anyOf · 2 options
Option 1array of object
Show array items
heightintegerrequired

Height of the image in pixels

image_urlstringrequired

URL of the image

origin_urlstringrequired

Original URL where the image was found

titlestringrequired

Title or description of the image

widthintegerrequired

Width of the image in pixels

Option 2nullnullable
modelstringrequired

Model used for generation

objectstring

Object type identifier

default "chat.completion"

related_questionsvalue

Array of related questions returned when return_related_questions is true

Show child attributes
anyOf · 2 options
Option 1array of string
Option 2nullnullable
search_resultsvalue

Search results used for context in the response

Show child attributes
anyOf · 2 options
Option 1array of object
Show array items

A single search result from the web

datevalue

Publication date of the result

Show child attributes
anyOf · 2 options
Option 1string
Option 2nullnullable
last_updatedvalue

Date the result was last updated

Show child attributes
anyOf · 2 options
Option 1string
Option 2nullnullable
snippetstring

Text snippet from the search result

default ""

sourcestring

Source type of the result (web or attachment)

one of "web", "attachment" · default "web"

titlestringrequired

Title of the search result page

urlstringrequired

URL of the search result page

Option 2nullnullable
usagevalue
Show child attributes
anyOf · 2 options
Option 1objectUsageInfo

UsageInfo

Token usage and cost information for a request

citation_tokensvalue

Number of tokens used for citations

Show child attributes
anyOf · 2 options
Option 1integer
Option 2nullnullable
completion_tokensintegerrequired

Number of tokens in the completion/output

costobjectrequired

Cost breakdown for a chat completion request

Show child attributes
citation_tokens_costvalue

Cost for citation tokens in USD

Show child attributes
anyOf · 2 options
Option 1number
Option 2nullnullable
input_tokens_costnumberrequired

Cost for input tokens in USD

output_tokens_costnumberrequired

Cost for output tokens in USD

reasoning_tokens_costvalue

Cost for reasoning tokens in USD

Show child attributes
anyOf · 2 options
Option 1number
Option 2nullnullable
request_costvalue

Cost for web search requests in USD (includes pro search cost if applicable)

Show child attributes
anyOf · 2 options
Option 1number
Option 2nullnullable
search_queries_costvalue

Cost for search queries in USD

Show child attributes
anyOf · 2 options
Option 1number
Option 2nullnullable
total_costnumberrequired

Total cost for the request in USD

num_search_queriesvalue

Number of search queries executed

Show child attributes
anyOf · 2 options
Option 1integer
Option 2nullnullable
prompt_tokensintegerrequired

Number of tokens in the prompt/input

reasoning_tokensvalue

Number of tokens used for reasoning

Show child attributes
anyOf · 2 options
Option 1integer
Option 2nullnullable
search_context_sizevalue

Size of search context used

Show child attributes
anyOf · 2 options
Option 1string
Option 2nullnullable
total_tokensintegerrequired

Total tokens used (prompt + completion)

Option 2nullnullable
Option 2nullnullable
started_atvalue

Unix timestamp when processing started

Show child attributes
anyOf · 2 options
Option 1integer
Option 2nullnullable
statusstringrequired

Status enum for async processing.

one of "CREATED", "IN_PROGRESS", "COMPLETED", "FAILED"

Example response
{
  "completed_at": 0,
  "created_at": 0,
  "error_message": null,
  "failed_at": 0,
  "id": "string",
  "model": "string",
  "response": {
    "choices": [
      {
        "delta": {
          "content": [
            {
              "file_name": null,
              "file_url": {},
              "type": "file_url"
            }
          ],
          "role": "assistant"
        },
        "finish_reason": "length",
        "index": 0,
        "message": {
          "content": [
            {
              "file_name": null,
              "file_url": {},
              "type": "file_url"
            }
          ],
          "role": "assistant"
        }
      }
    ],
    "citations": [
      "string"
    ],
    "created": 0,
    "id": "string",
    "images": [
      {
        "height": 0,
        "image_url": "string",
        "origin_url": "string",
        "title": "string",
        "width": 0
      }
    ],
    "model": "string",
    "object": "chat.completion",
    "related_questions": [
      "string"
    ],
    "search_results": [
      {
        "date": null,
        "last_updated": null,
        "snippet": "",
        "source": "web",
        "title": "string",
        "url": "string"
      }
    ],
    "usage": {
      "citation_tokens": 0,
      "completion_tokens": 0,
      "cost": {
        "citation_tokens_cost": null,
        "input_tokens_cost": 0,
        "output_tokens_cost": 0,
        "reasoning_tokens_cost": null,
        "request_cost": null,
        "search_queries_cost": null,
        "total_cost": 0
      },
      "num_search_queries": 0,
      "prompt_tokens": 0,
      "reasoning_tokens": 0,
      "search_context_size": null,
      "total_tokens": 0
    }
  },
  "started_at": 0,
  "status": "COMPLETED"
}
422Validation Errorapplication/json
objectHTTPValidationError

HTTPValidationError

detailarray of object
Show child attributes
Show array items
locarray of valuerequired
Show child attributes
Show array items
anyOf · 2 options
Option 1string
Option 2integer
msgstringrequired
typestringrequired
Example response
{
  "detail": [
    {
      "loc": [
        0
      ],
      "msg": "string",
      "type": "string"
    }
  ]
}
Documentation menu