Get ChatGPT, Perplexity and Gemini answers programmatically
Get the answers ChatGPT, Perplexity and Gemini show people as JSON, with cited sources and per country, and why the OpenAI API returns something else.
- api
- chatgpt
- perplexity
- gemini
Key takeaways
- A model API such as OpenAI's returns what a model generates with your settings; the ChatGPT, Perplexity and Gemini apps pick their own model, instructions and searches, so their answers and sources can differ.
- PromptGale asks the app itself in a real browser from the country you choose and returns the answer, its sources (cited or only listed), the searches it ran and a brand analysis as JSON.
- One request shape covers every engine: change taskType to CHATGPT, PERPLEXITY or GEMINI. POST /v1/sync/task waits up to 290 seconds for the answer.
- You pay per answer in credits on a monthly plan: ChatGPT, Gemini and Perplexity cost 1.5 credits, $0.0143 on the Starter plan. Failed tasks are refunded.
On this page
To get the answers that ChatGPT, Perplexity and Gemini show people, you have to ask the apps themselves, not a model API. A model API (such as OpenAI's) returns what a model generates for your request, with your settings. The app a person uses picks its own model, instructions and searches, so its answer and its sources can differ. PromptGale opens the app in a real browser from the country you choose, asks your prompt, and returns the answer, its cited sources, the searches it ran and a brand analysis as JSON, from one REST call or an MCP tool.
This post covers the two ways to do it (model APIs and app answers), when each one is right, and how to call PromptGale for ChatGPT, Perplexity and Gemini.
Model API or app answer: which one do you need?
Both are legitimate. They answer different questions.
| You want to... | Use |
|---|---|
| Build a feature that generates text for your own users | A model API (such as OpenAI's or Google's) |
| Know what ChatGPT, Perplexity or Gemini tell people about a topic or a brand | The app answer |
| Measure which sources and brands an engine cites, by country | The app answer |
| Control the model, the system prompt and the tools | A model API |
If your question is "what does ChatGPT tell my customers?", a model API is measuring something else.
Why doesn't the OpenAI API return the same answer as chatgpt.com?
OpenAI's API can search the web. Per OpenAI's web search guide, you add a tool of type web_search to a Responses API call, and the answer carries url_citation annotations. You can pass an approximate user_location to localize the search.
But in the API you choose the model, the instructions and the tool settings. In the ChatGPT app, ChatGPT chooses them. Per OpenAI's ChatGPT search help article, the app may search the web on its own when a question would benefit from current information, may send additional, more specific queries to search providers, and collects general location information based on your IP address. OpenAI also bills them separately: API usage is billed separately from a ChatGPT subscription.
OpenAI does not say the two return the same answer, and with different settings you should not expect them to. Our guide ChatGPT API vs ChatGPT app goes through the differences field by field.
The same logic applies to Gemini and Perplexity: a developer API gives you a model; the consumer app gives you the answer people read.
How do I get the app's answer as JSON?
With PromptGale you send three things: the engine (taskType), the prompt and a country. A real browser opens the engine's app from that country, asks the prompt and returns what the page showed.
POST /v1/sync/task runs one task and holds the request open until the answer is ready (up to 290 seconds). This is the request from the Quickstart:
curl -X POST https://promptgale.com/v1/sync/task \
-H "Authorization: Bearer $PROMPTGALE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"taskType": "CHATGPT",
"payload": {
"prompt": "best crm for a small agency",
"country": "US",
"brand": "Acme"
}
}'A 200 carries the finished task with status COMPLETED or FAILED. A 202 means the engine is still writing: keep the task id and read it later with GET /v1/tasks/{id}.
To ask Perplexity or Gemini, change taskType to PERPLEXITY or GEMINI. Everything else stays the same.
The same call in Python, adapted from the Quickstart and the Examples, here for Perplexity:
import os
import requests
res = requests.post(
"https://promptgale.com/v1/sync/task",
headers={"Authorization": f"Bearer {os.environ['PROMPTGALE_API_KEY']}"},
json={
"taskType": "PERPLEXITY",
"payload": {"prompt": "best crm for a small agency", "country": "US", "brand": "Acme"},
},
timeout=300,
)
task = res.json()["data"]
if task["status"] == "COMPLETED":
print(task["result"]["text"][:300])
else:
# FAILED (refunded), or still running after the wait (HTTP 202): read GET /v1/tasks/{id} later.
print(task["id"], task["status"], task.get("error"))What does the JSON contain?
data.result has the same shape for every engine; fields an engine does not show are left out (Results docs):
textandmarkdown: the answer as the app showed it.sources: each source withposition,url,domain,title(when there is one) andcited(falsemeans it was only in the source list, not cited in the answer).searchQueries: the searches the engine ran for your prompt (its query fan-out), when the engine shows them.relatedQuestions: follow-up questions the engine suggests, when it shows them.model: the model name, when the engine exposes it.analysis.brands: when you send abrand(and optionallycompetitors), whether each one was mentioned, its rank among the brands named, whether one of its pages was cited, and its share of voice. No extra credits.location: where the task ran (country, locale, timezone, and the state or point when you sent one).
Which engines and countries are available?
The engines listed today are ChatGPT, Gemini, Perplexity, Google AI Overviews, Google AI Mode, Bing Copilot Search and Meta AI. Engines and countries depend on availability, so read the current lists from GET /v1/capabilities and GET /v1/countries instead of hard-coding them (the Engines docs page keeps the list). Each engine has its own page: ChatGPT, Perplexity, Gemini.
Every task takes a country, and each engine is served from its own list of countries (GET /v1/countries?taskType=CHATGPT). Every engine listed today also accepts a US state, which adds 1 credit; some also take a city or a map point. GET /v1/capabilities has the location options per engine, and Countries and locations explains them.
What if I need hundreds of prompts?
Pick the interface that matches the job:
| Interface | Best for |
|---|---|
POST /v1/sync/task | One prompt at a time, in a script or an interactive tool |
POST /v1/tasks | A job queue: queue a task, then poll it or get a webhook |
POST /v1/batches | Many prompts across engines and countries in one call (up to 10,000 tasks) |
| Remote MCP server | An AI agent such as Claude Code or Cursor asking the engines for you |
Batches depend on the plan: Starter allows up to 100 items per batch, Growth and above up to 10,000. Webhooks are signed with HMAC-SHA256 (Webhooks docs).
What does it cost?
You pick a monthly plan and pay per answer in credits. ChatGPT, Gemini and Perplexity cost 1.5 credits per answer; Google AI Overviews, Google AI Mode and Bing Copilot Search cost 1; Meta AI costs 2. The Starter plan is $19 a month for 2,000 credits, so a ChatGPT answer costs $0.0143 on it (1.5 × $19 / 2,000 = $0.01425). Credits are held when a task is accepted, charged when it completes and refunded when it fails. Reading results, credits and countries is free. The current prices are on the pricing page.
Can I do this from an AI agent instead of code?
Yes. PromptGale is also a remote MCP server at https://promptgale.com/mcp, with OAuth sign-in (or an API key). An agent can call run_prompt and read the answer and sources directly. Setup per client is on the MCP server page.
How do I start?
Create an account and verify your email. There is no free plan: start the trial or pick a plan (the current offer is on the pricing page), create an API key in the dashboard, then run the Quickstart request above. The docs have the rest.
Frequently asked questions
- Is the OpenAI API with web search the same as ChatGPT?
- No. The API can search the web with its web_search tool, but you choose the model, the instructions and the tool settings, while the ChatGPT app chooses its own. OpenAI does not say the answers match. To measure what people read in ChatGPT, ask the app.
- Do I get the citations, or only the text?
- Both. Each answer comes with its sources, and each source says whether the answer cites it or whether it was only in the source list.
- Can I choose the country the answer comes from?
- Yes. Every task takes a country as a two-letter code (US by default). Each engine is served from its own list of countries, returned by GET /v1/countries. Every engine listed today also accepts a US state, which adds 1 credit.
- What happens if a task fails?
- It ends with status FAILED and an error code, and the credits held for it are refunded in full.
- Is there a free plan or a trial?
- There is no free plan: a new account starts with no credits and needs the trial or a paid plan before it can create API keys and run tasks. The trial is currently the Starter plan for 1 day with 25 trial credits; a card is required and is charged at the end of the trial unless you cancel, and there is one trial per customer. The current offer is on the pricing page.