Skip to main content

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

Composio is a universal tool gateway for AI agents. The Composio Perplexity toolkit exposes the full Perplexity API — Chat Completions, Agent, Search, Embeddings, and async variants — as tools that any agent framework can call through a single MCP URL or direct API integration.
Composio handles authentication, secure credential storage, OAuth flows, and tool routing for 1000+ apps. Learn more at composio.dev.
The toolkit ships these Perplexity actions:
  • Execute AgentPOST /v1/agent (Agent API responses)
  • Create Chat CompletionPOST /v1/sonar (Sonar chat completions)
  • Create Async Chat CompletionPOST /v1/async/sonar
  • Get / List Async Chat CompletionsGET /v1/async/sonar/{id}, GET /v1/async/sonar
  • Perplexity Search (Raw Results)POST /search
  • Create EmbeddingsPOST /v1/embeddings
  • Create Contextualized EmbeddingsPOST /v1/contextualizedembeddings
  • List ModelsGET /v1/models

Prerequisites

Get API Key

Generate your Perplexity API key from the API portal.

Installation

pip install composio
For agent-framework integrations, install your framework SDK alongside Composio (Composio supports Claude Agent SDK, OpenAI Agents SDK, LangChain, LlamaIndex, Mastra, Pydantic AI, AutoGen, CrewAI, Google ADK, and more).

Quick Start: Tool Router (MCP)

The Tool Router exposes Perplexity as an MCP server your agent can connect to. This works with any MCP-compatible client (Claude Code, Cursor, OpenCode, etc.).
from composio import Composio

composio = Composio(api_key="your-composio-api-key")
session = composio.create(user_id="your-user-id")
url = session.mcp.url

print(f"MCP URL: {url}")
Wire that URL into your agent’s MCP configuration:
import asyncio
from claude_agent_sdk import ClaudeSDKClient, ClaudeAgentOptions

options = ClaudeAgentOptions(
    permission_mode="bypassPermissions",
    mcp_servers={
        "tool_router": {
            "type": "http",
            "url": url,
            "headers": {"x-api-key": "your-composio-api-key"},
        }
    },
    system_prompt="You are a helpful assistant with access to Perplexity tools.",
    max_turns=10,
)

async def main():
    async with ClaudeSDKClient(options=options) as client:
        await client.query("Summarize the latest AI research papers")
        async for message in client.receive_response():
            if hasattr(message, "content"):
                for block in message.content:
                    if hasattr(block, "text"):
                        print(block.text)

asyncio.run(main())

Quick Start: Direct API Actions

You can also execute Perplexity actions directly from Composio without an MCP layer:
from composio import Composio

composio = Composio(api_key="your-composio-api-key")

# Connect the user's Perplexity account once
composio.toolkits.authorize(
    user_id="your-user-id",
    toolkit="perplexityai",
)

# Run a Sonar chat completion
result = composio.actions.execute(
    user_id="your-user-id",
    action="PERPLEXITYAI_CREATE_CHAT_COMPLETION",
    params={
        "model": "sonar-pro",
        "messages": [
            {"role": "user", "content": "What are the latest fusion-energy headlines?"}
        ],
    },
)

print(result["data"]["choices"][0]["message"]["content"])

Supported Agent Frameworks

Composio’s Perplexity toolkit works with every agent framework Composio supports, including:
  • ChatGPT, OpenAI Agents SDK, Codex
  • Claude Agents SDK, Claude Code
  • Cursor, VS Code, OpenCode
  • Google ADK, LangChain, AI SDK, Mastra AI
  • LlamaIndex, CrewAI, Pydantic AI, AutoGen
Each framework has a dedicated setup guide in the Composio Perplexity toolkit page.

Authentication

Composio stores your Perplexity API key securely and injects it into every request. You provide your key once during the toolkit authorization flow — either through the Composio dashboard or programmatically via composio.toolkits.authorize(...). Composio handles token refresh, scope management, and request signing on every call.

Composio Perplexity Toolkit

Full toolkit documentation with framework-specific guides.

Composio Docs

Composio platform documentation.

Perplexity API Reference

Full Perplexity API reference.

Perplexity Models

Available Perplexity models.

Support

Need help with the integration?