Documentation Index
Fetch the complete documentation index at: https://docs.perplexity.ai/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Cursor is an AI-first code editor that can call any HTTP API from your project code and supports the Model Context Protocol (MCP) for in-editor tools. This guide covers three integration paths for Perplexity:Official TypeScript SDK
Call the Perplexity API directly from your project code while you build in Cursor. Recommended.
OpenAI-Compatible SDK
Reuse an existing OpenAI client by pointing
baseURL at https://api.perplexity.ai/v1.Cursor MCP
Configure the hosted Perplexity Docs MCP in
.cursor/mcp.json so Cursor can look up Perplexity docs while you code.Recommended path: Use the official SDK (or the OpenAI-compatible SDK) from your application code, and add the Perplexity Docs MCP to Cursor for in-editor documentation lookup. Cursor’s “custom OpenAI-compatible model” override pointed at Perplexity is experimental and tends to be less reliable than code-level integration or MCP — see Custom Model Override (Experimental).
Prerequisites
- Cursor installed (cursor.com/download)
- Node.js 18+ for the TypeScript examples
- A Perplexity API key
Get API Key
Generate a key from the Perplexity API Portal.
API Key Handling
Never hardcode your API key in source files or commit it to a repository. Store it in an environment variable and read it at runtime:- macOS/Linux
- Windows
- .env (project-local)
Path 1: Official TypeScript SDK (Recommended)
Build your application in Cursor and call the Perplexity API from your code using the official SDK. This is the most reliable path and gives you full type safety, preset support, and access to every API feature.Install
Agent API with pro-search
The Agent API is the recommended surface for most applications. Use the pro-search preset for web-grounded responses with sensible defaults:
Python equivalent
Python equivalent
Add Web Search
Enable theweb_search tool for explicit control over when search is used:
Path 2: OpenAI-Compatible SDK
If you already have an OpenAI client in your project, you can reuse it by pointing thebaseURL at https://api.perplexity.ai/v1. Perplexity accepts POST /v1/responses as an alias for the Agent API.
Install
Use It
Python equivalent
Python equivalent
Use
baseURL (TypeScript) or base_url (Python) — both must include the /v1 suffix. See the OpenAI Compatibility guide for the full list of supported parameters and which Perplexity features are available through this path.Path 3: Cursor MCP for Docs Lookup
Cursor supports the Model Context Protocol (MCP). The hosted Perplexity Docs MCP athttps://docs.perplexity.ai/mcp lets Cursor search and read Perplexity’s documentation directly from chat — useful for grounding code suggestions in canonical docs without context-switching to a browser.
Project-Scoped Configuration
Add a.cursor/mcp.json file at the root of your project. This makes the server available only for that project:
Global Configuration
To make the server available across all projects, add the same entry to~/.cursor/mcp.json:
Add the Configuration
Save the JSON above to
.cursor/mcp.json (project) or ~/.cursor/mcp.json (global).Reload Cursor
Open Cursor → Settings → MCP and confirm
perplexity-docs appears with a green/ready status. Restart Cursor if needed.Custom Model Override (Experimental)
Cursor lets you point its built-in model picker at an OpenAI-compatible base URL. While it is possible to set this tohttps://api.perplexity.ai/v1 and use a Perplexity model name, this path has limitations:
- The Agent API surface (presets, structured tool calls, finance/people search) is not fully exercised by Cursor’s internal prompting.
- Cursor’s autocomplete and edit features are tuned to specific model behaviors and may not work well with substituted models.
- Streaming, tool use, and error handling can behave differently than in a code-level integration.
Next Steps
Agent API Quickstart
Presets, tools, and the full Agent API surface used by the examples above.
Perplexity SDK Overview
Install, configure, and use the official Python and TypeScript SDKs.
OpenAI Compatibility
Drop-in compatibility details, supported parameters, and migration tips.
Perplexity MCP Server
Add Perplexity search, ask, research, and reason tools to Cursor and other MCP clients.
Need help? Join the Perplexity developer community for support and discussion.