# Quickstart

> Send your first prompt to ChatGPT from a chosen country and read the answer and its cited sources in two minutes, with curl, Python or Node.js.

Run one prompt on one engine and read the result: the same call works as a ChatGPT scraper API for the answer and citations a person sees in the app. You need an API key: create one in the dashboard under API keys. Keys start with `pk_live_`.

## 1. Save your key

```bash
export PROMPTGALE_API_KEY=pk_live_...
```

## 2. Ask and wait for the answer

`POST /v1/sync/task` runs the task and holds the request open until the answer is ready (up to 290 seconds).

**curl**

```bash
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"
    }
  }'
```

**Python**

```python
import os
import requests

res = requests.post(
    "https://promptgale.com/v1/sync/task",
    headers={"Authorization": f"Bearer {os.environ['PROMPTGALE_API_KEY']}"},
    json={
        "taskType": "CHATGPT",
        "payload": {"prompt": "best crm for a small agency", "country": "US", "brand": "Acme"},
    },
    timeout=300,
)
task = res.json()["data"]
print(task["status"], task["result"]["text"][:200])
```

**Node.js**

```js
const res = await fetch('https://promptgale.com/v1/sync/task', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.PROMPTGALE_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    taskType: 'CHATGPT',
    payload: { prompt: 'best crm for a small agency', country: 'US', brand: 'Acme' },
  }),
});
const { data: task } = await res.json();
console.log(task.status, task.result.text.slice(0, 200));
```

## 3. Read the result

A `200` response carries the finished task. The answer is in `data.result`:

```json
{
  "success": true,
  "data": {
    "id": "tsk_8Jx0c2...",
    "status": "COMPLETED",
    "credits": 1,
    "result": {
      "text": "For a small agency, the most recommended CRMs are ...",
      "sources": [
        { "position": 1, "url": "https://example.com/review", "domain": "example.com", "cited": true }
      ],
      "analysis": {
        "brands": [{ "name": "Acme", "mentioned": true, "rank": 1, "cited": true }]
      }
    }
  }
}
```

- `status` is `COMPLETED` or `FAILED`. A failed task is refunded and has an `error` object instead of a result.
- A `202` response means the engine is still writing: keep the `id` and read `GET /v1/tasks/{id}`.

## Next

- Many prompts, or work in a job queue: [Tasks](https://promptgale.com/docs/tasks.md) and [Batches](https://promptgale.com/docs/batches.md).
- Every field of the answer: [Results](https://promptgale.com/docs/results.md).
- Another country, a US state or a city: [Countries and locations](https://promptgale.com/docs/locations.md).
- Using an agent instead of code: [Connect an agent](https://promptgale.com/docs/mcp.md).
- More recipes (batches, countries, webhooks, CSV): [Examples](https://promptgale.com/docs/examples.md).

---

Docs index: https://promptgale.com/llms.txt · Full reference: https://promptgale.com/llms-full.txt · OpenAPI: https://promptgale.com/v1/openapi.json
