Skip to main content
Perplexity

Search documentation

Type to search this documentation.

On this pageOverview

Perplexity on Stripe Projects

Stripe Projects provisions third-party services from your terminal or coding agent. One command creates a Perplexity API project in your own account, mints a key, and writes it to your Stripe project's .env:

Bash
stripe projects add perplexity/api

perplexity/api is the service. Once added, update, rotate, and remove refer to it by the resource name perplexity-api, and account-level commands like open, spend, and link take the provider name perplexity.

A Perplexity API project is the billing and key boundary in the API Console. The one Stripe Projects creates is a normal project in your account. Open it in the API Console any time to see balance, usage, keys, and billing settings. On this page, "Stripe project" means the directory the CLI manages and "Perplexity API project" means the API project it provisions.

macOS/Linux
brew install stripe/stripe-cli/stripe
stripe plugin install projects
npm
npm install -g @stripe/cli
stripe plugin install projects

You don't need an existing Perplexity account. The add flow creates one from your Stripe-verified email if needed. You do need a payment method on your Stripe account: Stripe asks for one before provisioning any paid service.

  1. Initialize a Stripe project

    Bash
    stripe projects init my-app

    The first run signs you in to Stripe and creates a Stripe project in the current directory. If your Stripe account has no payment method yet, add one now so the next step doesn't stop at a Checkout page:

    Bash
    stripe projects billing add
  2. Add Perplexity

    Bash
    stripe projects add perplexity/api

    This creates a Perplexity API project, mints a key, and writes it to .env as PERPLEXITY_API_KEY:

    stripe projects add perplexity/api creating the Perplexity API project and writing PERPLEXITY_API_KEY to .env

    Creating a new Perplexity API project prompts for a $10 minimum credit purchase, charged to your Stripe account's payment method. See Billing and credits for the full rules.

  3. Make your first request

    The official SDKs read PERPLEXITY_API_KEY from the environment. The examples use the low preset, which sets a default model and web search configuration:

    Python
    from perplexity import Perplexity
    
    client = Perplexity()  # reads PERPLEXITY_API_KEY from the environment
    
    response = client.responses.create(
        preset="low",
        input="Summarize the top AI infrastructure news from this week.",
    )
    
    print(response.output_text)
    Typescript
    import Perplexity from "@perplexity-ai/perplexity_ai";
    
    const client = new Perplexity(); // reads PERPLEXITY_API_KEY from the environment
    
    const response = await client.responses.create({
      preset: "low",
      input: "Summarize the top AI infrastructure news from this week.",
    });
    
    console.log(response.output_text);
    cURL
    curl https://api.perplexity.ai/v1/agent \
      -H "Authorization: Bearer $PERPLEXITY_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{
        "preset": "low",
        "input": "Summarize the top AI infrastructure news from this week."
      }' | jq

    To open the Perplexity API project in the API Console and see usage, balance, and keys:

    Bash
    stripe projects open perplexity

Perplexity API usage is prepaid: you buy credits, usage draws the balance down. For a Perplexity API project created by Stripe Projects, credit purchases charge your Stripe account's payment method, so you never enter a card on the Perplexity side.

On provision

  • Creating a new dedicated Perplexity API project prompts for a $10 minimum initial credit purchase.
  • If you already administer a Perplexity API project, the CLI offers to connect it instead of creating a new one. Connected projects keep their existing Perplexity billing, so credit purchases for them stay in the API Console (see Connect an existing Perplexity API project).

Top up after provisioning

Bash
# resource name, then service
stripe projects update perplexity-api perplexity/api \
  --config '{"buy_credits_usd": 25}'
Setting When What it does
initial_credit_usd at add One-time credit purchase at provision (min $10)
buy_credits_usd at update One-time top-up (min $10)
auto_recharge anytime Automatically buy credits when the balance runs low. Requires recharge_amount_usd when turned on
recharge_amount_usd with auto_recharge Amount purchased by each automatic recharge (min $10)

The CLI prompts for these when needed, and agents pass them with --config. The same settings are editable in the API Console, and changes from either place apply to the same Perplexity API project.

Check spend

Bash
stripe projects spend perplexity

stripe projects spend perplexity showing the provider spend limit and monthly charges

Stripe applies a monthly spending limit per provider. Adjust it with stripe projects billing update --limit 50 --provider perplexity. A purchase that would exceed the limit is declined; raise the limit and retry.

If you run out of credits, the key is blocked until you add more. Enable auto_recharge ahead of time so credits are added automatically when the balance runs low.

Your Stripe account connects to exactly one Perplexity API project. The first time you run add, if your Stripe-verified email already administers Perplexity API projects, the CLI asks whether to create a new one or connect an existing one:

  • Create a new dedicated Perplexity API project (recommended)
  • One of your existing Perplexity API projects, listed by name

Each additional Stripe project you run add in gets its own API key, all minted inside that one Perplexity API project. Other users on the same Stripe account can run add too, but only if they are an Admin of that Perplexity API project.

You can also make this choice up front, before adding Perplexity to a Stripe project:

Bash
stripe projects link perplexity

If you connect an existing Perplexity API project, it keeps its existing Perplexity billing. Credit purchases through Stripe Projects open that project's billing page in the API Console instead of charging your Stripe payment method. Only keys minted through Stripe Projects are visible to Stripe; your other keys are not.

Bash
stripe projects rotate perplexity-api   # mint a new key, update .env
stripe projects remove perplexity-api   # deprovision and revoke
  • Rotate mints a fresh key and updates .env. The old key keeps working for 24 hours so running deployments don't break mid-rotation.
  • Remove deprovisions this Stripe project's key. Your Perplexity API project, credits, and any other keys are untouched, and it stays visible in the API Console.

A Stripe account connects to one Perplexity API project. stripe projects unlink perplexity only forgets that connection in the current Stripe project directory; the Perplexity API project and its keys are untouched, and link reconnects to the same one.

To connect the Stripe account to a different Perplexity API project, delete the current one in the API Console, then run stripe projects unlink perplexity and stripe projects link perplexity. The link step asks you to create or connect a Perplexity API project again.

Claude Code, Cursor, Codex, and other agents can run the full add flow non-interactively.

  1. Install the agent skill

    stripe projects init writes a skill into the Stripe project (Claude Code, Cursor, and AGENTS.md variants):

    stripe projects init creating the Stripe project and writing the stripe-projects-cli agent skill files

    To install the skill globally instead:

    Bash
    npx skills add https://docs.stripe.com --skill stripe-projects -g -y
  2. Authorize once

    Attach a payment method before the agent session so it never hits a browser prompt:

    Bash
    stripe login                # if you haven't yet
    stripe projects billing add
  3. Let the agent provision

    Agents use the non-interactive form. --confirm-paid-service is required when a purchase is involved:

    Bash
    stripe projects add perplexity/api \
      --config '{"initial_credit_usd": 10}' \
      --json --yes --confirm-paid-service --accept-tos

    Then try a prompt like:

    Add Perplexity to this app with Stripe Projects, then build a /research endpoint that calls the Agent API with the low preset.

Suggest an edit

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

Export
Documentation menu