A Perplexity Sonar alternative that keeps your code working

Perplexity has moved Sonar to its new Agent API. MIAPI speaks the same OpenAI chat-completions format, so switching is two lines, with one flat price per answer and no token math.

Get 100 free queries Read the docs

What changed at Perplexity

Perplexity's own migration guide says Sonar Chat Completions support ended on 27 September 2026. Synchronous and streaming Sonar requests are being carried over to the new Agent API gradually, model by model; asynchronous requests are not. For new work, Perplexity asks developers to use the Agent API, which has a different request shape (input instead of messages, answers in output_text) and an effort setting.

If you would rather not rewrite your integration, MIAPI keeps the OpenAI chat-completions format your Sonar code already uses.

Perplexity Agent API, Perplexity Search API and MIAPI: the honest difference

Perplexity Agent API

You pick a model (Perplexity's Sonar or models from OpenAI, Anthropic, Google and others) and it searches the web as a tool. You pay per search, $1 per 1,000 with Fast Search or $2.50 per 1,000 standard, plus that model's token prices. Great if you want a particular model or deep research presets; the price per answer depends on how many tokens each answer uses.

Perplexity Search API

Returns ranked web results (titles, links and snippets), not a written answer. $5 per 1,000 requests, or $1 with Fast Search. You still need your own model to read the results and write an answer.

MIAPI

One call returns the written answer, inline citations, the source list and a confidence score. One flat price per answer, $2.50 to $3.60 per 1,000 depending on pack size, with no separate token bill. It works through an OpenAI-compatible endpoint or our own /v1/answer. Packs are one-time purchases and credits never expire.

Which should you pick? If you need a specific frontier model or Perplexity's deep research modes, the Agent API gives you more control. If you want a predictable price per answer and the smallest code change from Sonar, MIAPI is simpler.

Switching from Perplexity Sonar? Change 2 lines

MIAPI speaks the OpenAI chat-completions format, so code written for Sonar keeps working. Swap your API key and the base URL, and that is it. Any model name is accepted; we suggest miapi-grounded. Streaming works too.

Python (OpenAI client)
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_MIAPI_KEY",              # was: your Perplexity key
    base_url="https://api.miapi.uk/v1",    # was: https://api.perplexity.ai
)

resp = client.chat.completions.create(
    model="miapi-grounded",
    messages=[{"role": "user", "content": "What is the tallest building in the world?"}],
)
print(resp.choices[0].message.content)
Streaming
stream = client.chat.completions.create(
    model="miapi-grounded",
    messages=[{"role": "user", "content": "What is the tallest building in the world?"}],
    stream=True,
)
for chunk in stream:
    print(chunk.choices[0].delta.content or "", end="", flush=True)

Cost per 1,000 web-grounded answers (checked November 2026)

What it costs to get an AI-written answer with sources back from each API.

ProviderPer 1,000 answersHow it is priced
MIAPI$2.50–$3.60One flat price per answer, AI answer included. One-time packs from $9, credits never expire, 100 free queries a month.
Brave Answers$4 + tokens$4 per 1,000 requests plus $5 per million tokens.
You.com Answer API$5$5 per 1,000 calls.
Exa answer$5$5 per 1,000 requests to /answer.
Linkup sourced answer$6$0.006 per standard-depth call ($0.055 for deep).
Tavily≈ $8$0.008 per credit pay-as-you-go; a basic search is 1 credit. 1,000 free credits a month.
OpenAI web search tool$10 + tokens$10 per 1,000 calls plus search content tokens at model rates.
Google Gemini grounding$14 + tokens$14 per 1,000 grounded requests after 5,000 free a month (Gemini 3 and newer), plus model tokens.

2–5x cheaper than Tavily, OpenAI and Gemini, with one flat price per answer and no token math.

Published pay-as-you-go prices from each provider's own pricing page, checked 13 November 2026. ≈ marks an estimate: the real cost depends on tokens used, plan usage or settings. Some subscription plans can work out cheaper per answer if you use your whole monthly allowance. The “55–82% cheaper” figure compares MIAPI's $2.50–$3.60 with Tavily ($8), OpenAI web search ($10 + tokens) and Gemini grounding ($14 + tokens) per 1,000, before their token charges. Prices change, so follow the links for today's figures.

Try it free

100 free queries every month. No card needed. Paid packs from $9, and credits never expire.

Get 100 free queries