Skip to main content
POST
/
chat
/
completions
Chat Completions
curl --request POST \
  --url https://api.perplexity.ai/chat/completions \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "sonar-deep-research",
  "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"
      }
    }
  ],
  "search_results": [
    {
      "title": "<string>",
      "url": "<string>",
      "date": "2023-12-25"
    }
  ],
  "videos": [
    {
      "url": "<string>",
      "thumbnail_url": "<string>",
      "thumbnail_width": 123,
      "thumbnail_height": 123,
      "duration": 123
    }
  ]
}

Authorizations

Authorization
string
header
required

Body

application/json
model
enum<string>
required
Available options:
sonar,
sonar-pro,
sonar-deep-research,
sonar-reasoning,
sonar-reasoning-pro
Example:
messages
Message · object[]
required
Example:
search_mode
enum<string>
default:web
Available options:
academic,
sec,
web
reasoning_effort
enum<string>
Available options:
low,
medium,
high
max_tokens
integer
temperature
number
default:0.2
Required range: 0 <= x < 2
top_p
number
default:0.9
language_preference
string
search_domain_filter
any[]
return_images
boolean
default:false
search_recency_filter
string
search_after_date_filter
string
search_before_date_filter
string
last_updated_after_filter
string
last_updated_before_filter
string
top_k
number
default:0
stream
boolean
default:false
presence_penalty
number
default:0
frequency_penalty
number
default:0
response_format
object
enable_search_classifier
boolean
default:false
web_search_options
object
Example:
media_response
object
Example:

Response

id
string
required
model
string
required
created
integer
required
usage
object
required
object
string
default:chat.completion
required
choices
ChatCompletionsChoice · object[]
required
search_results
ApiPublicSearchResult · object[] | null
videos
VideoResult · object[] | null