Skip to main content
Perplexity

Search documentation

Type to search this documentation.

On this pageOverview

Perplexity with Composio

Composio is a universal tool gateway for AI agents. The Composio Perplexity toolkit exposes Perplexity's Agent, Search, and Embeddings APIs as tools that any agent framework can call through a single MCP URL or direct API integration.

The toolkit ships these Perplexity actions:

  • Execute Agent — POST /v1/agent (Agent API responses)
  • Perplexity Search (Raw Results) — POST /search
  • Create Embeddings — POST /v1/embeddings
  • Create Contextualized Embeddings — POST /v1/contextualizedembeddings
  • List Models — GET /v1/models

Get API Key

Generate your Perplexity API key from the API portal.

Bash
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).

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.).

Python
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:

Python
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())

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

Python
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 an Agent API request
result = composio.tools.execute(
    slug="PERPLEXITYAI_EXECUTE_AGENT",
    user_id="your-user-id",
    arguments={
        "model": "openai/gpt-5.6-sol",
        "tools": [{"type": "web_search"}],
        "input": "What are the latest fusion-energy headlines?",
    },
)

print(result["data"])

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.

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.

Need help with the integration?

Suggest an edit

Propose a replacement for this page. The site team reviews it before applying any changes.

Export
Documentation menu