How to create API Key Perplexity
Instructions on how to register, top up credits, and create API Key Perplexity to integrate AI search into your application.
- How to create and activate a Perplexity API Key
- What is the Perplexity API and what is it used for?
- How to call the Perplexity API in the test
- Security and management considerations regarding API Keys
- Frequently Asked Questions about the Perplexity API
- Step 1: Go to Account Perplexity Settings
- Step 2: Open the All Settings window.
- Step 3: Switch to the API Platform
- Step 4: Log in to the API Platform System
- Step 5: Add Payment Method
- Step 6: Enter International Payment Card Information
- Step 7: Navigate to the API Keys section and generate a key.
In the era of booming AI, integrating large language models (LLMs) like ChatGPT or Claude into applications is no longer uncommon. However, the inherent weakness of these traditional APIs is the limitation of training data, making them susceptible to "illusion" when faced with topical information.
If you're looking for an integrated AI solution capable of automatically searching and aggregating data from the internet in real time and returning results with credible source citations, then Perplexity API is the perfect answer.
No longer confined to a conventional web interface, the Perplexity API opens up a powerful "gateway" for developers and process optimization experts. You can easily embed this intelligent search engine into customer service chatbot systems, build internal market research tools, or even automate complex workflows via Docker and n8n .
This article will guide you step-by-step from how to register and securely activate your API Key, to how to call basic code to bring the power of Perplexity search into your own project.
How to create and activate a Perplexity API Key
Step 1: Go to Account Perplexity Settings
From the main Perplexity interface (Perplexity Computer interface), look at the bottom left corner. Click on your Account Name or Profile Picture (the location indicated by the red arrow).
Step 2: Open the All Settings window.
A small menu will pop up right above your account name. Hover your mouse over it and select the first item: All settings .
Step 3: Switch to the API Platform
The system settings window will appear. Look at the menu on the left, scroll down to the "Other" section at the bottom, and click on " API Platform" . This will open a dedicated admin page for developers.
Step 4: Log in to the API Platform System
The system will require re-authentication to ensure security. On the API Platform login interface, select your desired login method, for example: Continue with Google (or Apple/Email depending on your original account).
Step 5: Add Payment Method
After successfully logging into the API admin page, you will see a red warning message requesting you to top up your credits to use the service.
- Look at the top right corner of the interface and click the Add payment method button .
- Note: You can also access this section by selecting the Billing tab in the left-hand menu at any time.
Step 6: Enter International Payment Card Information
An "Enter payment details" form will appear in the middle of the screen. Enter your card information accurately, including:
- Card number: Card number (Visa, Mastercard, AMEX.)
- Expiration date: Month/Year of expiration (MM/YY)
- Security code: CVC security code (3 digits on the back of the card)
- Country: Select Vietnam. After filling in all the information, press the Done button to link your card and proceed to deposit a minimum amount of credit into your account (the system charges fees based on the actual amount of tokens you use).
Step 7: Navigate to the API Keys section and generate a key.
After you have finished topping up your credits, look at the management menu on the left and click on the API keys option . Then, on the main interface, click the + Generate API Key button in the upper right corner to generate the code.
Extremely important note: The system will display a long string of characters starting with pplx-. Please click Copy and save this string immediately to a secure file or your password manager. After you close this window, the API Key string will be permanently hidden and you will not be able to view it again; if lost, you will be forced to delete it and create a new key.
What is the Perplexity API and what is it used for?
The Perplexity API is a programming gateway that allows developers to directly integrate Perplexity's AI search and aggregation capabilities into their own applications, websites, or automation workflows —without requiring users to open a browser and go to perplexity.ai.
In other words: you can build a chatbot, internal research tool, or automated response system, running on Perplexity's AI search engine but entirely branded and designed by you.
Common application scenarios:
- Customer support chatbots can provide real-time information retrieval.
- Internal research tool for marketing, content, or consulting teams.
- Automate workflows via n8n, Make.com, or Zapier - call APIs when you need to summarize news or analyze the market.
- Mobile/web applications need to integrate intelligent search with source citation.
How to call the Perplexity API in the test
After obtaining the API key, here's the most basic way to check the connection using Python:
import requests url = "https://api.perplexity.ai/chat/completions" headers = { "Authorization": "Bearer pplx-xxxxxxxxxxxxxxxx", "Content-Type": "application/json" } payload = { "model": "sonar", "messages": [ {"role": "user", "content": "Xu hướng AI nổi bật nhất tháng 6 năm 2026 là gì?"} ] } response = requests.post(url, json=payload, headers=headers) print(response.json()["choices"][0]["message"]["content"])
Integration into n8n : Create an HTTP Request node → POST method → URL https://api.perplexity.ai/chat/completions→ add header Authorization: Bearer [API_KEY]→ import a JSON body with the query → the returned result is text that can be used further in the workflow.
Security and management considerations regarding API Keys
Your API key is extremely sensitive information. Anyone with your key can access the API and use up all the credit in your account. Several security principles must be followed:
- Never leave API keys in public source code: If your code is hosted on GitHub or GitLab, the key must be placed in an environment variable (
.envfile) and added.envto the.gitignore. - Create a separate key for each project: When a project ends or you suspect a key has been compromised, delete that key and create a new one – other projects will not be affected.
- Set a Spending Limit: In the API Settings section, you can set a maximum monthly spending limit – the system will automatically stop API calls when the limit is reached, preventing unexpected charges.
- Regularly check usage: The Usage section in Settings displays the API call history by day - if you see an unusual number, delete the key and recreate it immediately.
Frequently Asked Questions about the Perplexity API
How does Perplexity API differ from ChatGPT API or Claude API? The biggest difference is that Perplexity API has built-in real-time web search capabilities – the answers are always based on the most up-to-date information instead of being limited by training data. ChatGPT and Claude API are purely language models; they don't automatically search the web unless you integrate your own tools.
Is it free to use? No. The Perplexity API requires credit to be purchased before use. The perplexity.ai web interface has a free plan, but access via the API is a separate paid service.
Which model should you choose when calling an API? sonar The default model strikes a good balance between speed and quality. sonar-proIt provides more in-depth results but costs more tokens. For most practical applications, sonarit's a suitable starting choice.
- How to use Perplexity to create AI images on WhatsApp
- A comprehensive guide to academic knowledge on Perplexity AI.
- How to integrate Gemini with Perplexity AI
- How to Get the Most Out of Your New Perplexity Pro Subscription
- What is Perplexity Assistant?
- How to write effective Perplexity prompts
- 5 Often Overlooked Perplexity Features That Make It Smarter
- How to Use Perplexity in Telegram
- Is Perplexity Pro worth the money? A detailed comparison between Perplexity Pro and the free version.
- Is ChatGPT Plus or Perplexity the better AI chatbot?
- Stop using Perplexity! Your local LLM does everything better.
- How to manage storage in Perplexity AI
- Perplexity or Google better?
- Experience Perplexity AI virtual assistant on iPhone