Setting Up Your Group

To get started with the Perplexity API:

  1. Navigate to your API Group section of your Account page.
  2. Fill out your group’s name, address, and tax details.

Setting up your billing

  • Register your credit card to get started

This step will not charge your credit card. It just stores payment information for later API usage.


Generating an API Key

Every API call requires a valid API key. To generate one:

  1. Go to the API Keys tab in the API Portal.
  2. Click + Create Key to generate a new API key.

The API key is a long-lived access token that can be used until it is manually refreshed or deleted.

API keys are sensitive credentials. Never expose them in client-side code or share them in public repositories.


Making Your First API Call

  • Once you have your API key, you can make your first API call.
  • Send the API key as a bearer token in the Authorization header with each request.

Example API Call

curl --location 'https://api.perplexity.ai/chat/completions' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Authorization: Bearer {API_KEY}' \
--data '{
  "model": "sonar-pro",
  "messages": [
    {
      "role": "system",
      "content": "Be precise and concise."
    },
    {
      "role": "user",
      "content": "How many stars are there in our galaxy?"
    }
  ]
}'

If you run out of credits, your API keys will be blocked until you add to your credit balance. You can avoid this by configuring “Automatic Top Up,” which refreshes your balance whenever it drops below a certain threshold.