Skip to main content
Perplexity

Search documentation

Type to search this documentation.

Create Async Chat Completion

POST/v1/async/sonarCreate Async Chat Completion

Submit an asynchronous chat completion request.

Request body

required
application/json
objectAsyncApiChatCompletionsRequest

AsyncApiChatCompletionsRequest

Request body for creating an asynchronous chat completion

idempotency_keyvalue

Unique key to prevent duplicate requests

Show child attributes
anyOf · 2 options
Option 1string
Option 2nullnullable
requestobjectrequired
Show child attributes
disable_searchvalue

When true, disables all web search capabilities. The model responds based solely on its training data

Show child attributes
anyOf · 2 options
Option 1boolean
Option 2nullnullable
enable_search_classifiervalue

When true, uses a classifier to determine if web search is needed for the query

Show child attributes
anyOf · 2 options
Option 1boolean
Option 2nullnullable
image_domain_filtervalue

Limit image results to specific domains

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

Filter image results by format (e.g. png, jpg)

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

ISO 639-1 language code for preferred response language

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

Return results last updated after this date (MM/DD/YYYY)

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

Return results last updated before this date (MM/DD/YYYY)

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

Maximum number of completion tokens to generate

Show child attributes
anyOf · 2 options
Option 1integer

exclusiveMinimum 0 · maximum 128000

Option 2nullnullable
messagesarray of objectrequired

Array of messages forming the conversation history

Show child attributes
Show array items
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"

modelstringrequired

Model to use, for example, sonar-pro

one of "sonar", "sonar-pro", "sonar-deep-research", "sonar-reasoning-pro"

reasoning_effortvalue

Controls how much effort the model spends on reasoning

Show child attributes
anyOf · 2 options
Option 1string

one of "minimal", "low", "medium", "high"

Option 2nullnullable
response_formatvalue

Optional. Controls the output format. Omit for default text output. Set `type` to `json_schema` for structured output.

Show child attributes
anyOf · 3 options
Option 1objectResponseFormatText

ResponseFormatText

typestringrequired

Must be `text`.

const "text"

Option 2objectResponseFormatJSONSchema

ResponseFormatJSONSchema

Constrains the model output to match the provided JSON schema.

json_schemaobjectrequired
Show child attributes
descriptionvalue
Show child attributes
anyOf · 2 options
Option 1string
Option 2nullnullable
namevalue

default "schema"

Show child attributes

default "schema"

anyOf · 2 options
Option 1string
Option 2nullnullable
schemaobjectrequired
strictvalue

default true

Show child attributes

default true

anyOf · 2 options
Option 1boolean
Option 2nullnullable
typestringrequired

Must be `json_schema`.

const "json_schema"

Option 3nullnullable
return_imagesvalue

When true, include image results in the response

Show child attributes
anyOf · 2 options
Option 1boolean
Option 2nullnullable
return_related_questionsvalue

When true, generates suggested follow-up queries based on the search results

Show child attributes
anyOf · 2 options
Option 1boolean
Option 2nullnullable
search_after_date_filtervalue

Return results published after this date (MM/DD/YYYY)

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

Return results published before this date (MM/DD/YYYY)

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

Limit search results to specific domains (e.g. github.com, wikipedia.org)

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

Filter results by language using ISO 639-1 codes (e.g. en, fr, de)

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

Source of search results (web, academic, or sec)

Show child attributes
anyOf · 2 options
Option 1string

one of "web", "academic", "sec"

Option 2nullnullable
search_recency_filtervalue

Filter by publication recency (hour, day, week, month, or year)

Show child attributes
anyOf · 2 options
Option 1string

one of "hour", "day", "week", "month", "year"

Option 2nullnullable
stopvalue

Stop sequences. Generation stops when one of these strings is produced

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

If true, returns streaming SSE response

default false

Show child attributes

default false

anyOf · 2 options
Option 1boolean
Option 2nullnullable
stream_modestring

Controls the format of streaming events. 'full' suppresses reasoning events and includes metadata inline; 'concise' emits reasoning events separately

one of "full", "concise" · default "full"

temperaturevalue

Controls randomness in the response. Higher values make output more random. Range: 0-2

Show child attributes
anyOf · 2 options
Option 1number

maximum 2 · minimum 0

Option 2nullnullable
top_pvalue

Nucleus sampling parameter. Controls diversity via nucleus sampling

Show child attributes
anyOf · 2 options
Option 1number

maximum 1 · minimum 0

Option 2nullnullable
web_search_optionsobject

Configuration options for web search behavior

Show child attributes
image_results_enhanced_relevanceboolean

When true, applies enhanced relevance filtering to image results

default false

search_context_sizestring

Amount of search context to include (low, medium, or high)

one of "low", "medium", "high" · default "low"

search_typevalue

Search type (fast for speed, pro for quality, auto to let the model decide)

Show child attributes
anyOf · 2 options
Option 1string

one of "fast", "pro", "auto"

Option 2nullnullable
user_locationvalue
Show child attributes
anyOf · 2 options
Option 1objectUserLocation

UserLocation

User's geographic location for search personalization

cityvalue

City name

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

ISO 3166-1 alpha-2 country code

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

Latitude coordinate

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

Longitude coordinate

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

State or region name

Show child attributes
anyOf · 2 options
Option 1string
Option 2nullnullable
Option 2nullnullable
Example request
{
  "request": {
    "messages": [
      {
        "content": "<string>",
        "role": "<string>"
      }
    ],
    "model": "sonar-deep-research"
  }
}

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
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