# Chatgpt Prompt Actor - GEO Analyse with Citation Data (`automation_nerd/chatgpt-prompt-actor`) Actor

This Actor automates interactions with ChatGPT by sending prompts and extracting responses.
it opens the web interface, dismisses pop-ups, sends prompts, waits for responses (up to 2 minutes), and extracts generated results including citations for further use.

- **URL**: https://apify.com/automation_nerd/chatgpt-prompt-actor.md
- **Developed by:** [Egon Maier](https://apify.com/automation_nerd) (community)
- **Categories:** Automation, SEO tools, AI
- **Stats:** 96 total users, 0 monthly users, 100.0% runs succeeded, 6 bookmarks
- **User rating**: 5.00 out of 5 stars

## Pricing

Pay per usage

This Actor is paid per platform usage. The Actor is free to use, and you only pay for the Apify platform usage, which gets cheaper the higher subscription plan you have.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-usage

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

### ChatGPT Prompt Actor

This Actor automates interactions with ChatGPT by sending prompts and extracting responses. It uses [PlaywrightCrawler](https://crawlee.dev/docs/examples/playwright-crawler) with [Camoufox](https://github.com/daijro/camoufox) - a stealthy fork of Firefox - to navigate ChatGPT's web interface and perform automated conversations.

#### What this Actor does:

1. **Navigates to ChatGPT**: Opens the ChatGPT web interface at https://chatgpt.com/
2. **Handles UI Elements**: Automatically closes any modal dialogs that might appear
3. **Processes Multiple Prompts**: Sequentially sends all prompts from your input array
4. **Sends Prompts**: Enters each prompt into ChatGPT's text input field
5. **Waits for Response**: Monitors the page until ChatGPT completes its response (up to 2 minutes)
6. **Extracts Results**: Captures the AI-generated response text and also *citations*, and *news items*
7. **Saves Data**: Stores all prompts, responses, and metadata in a structured dataset

#### Input Parameters:

- `prompts` (array): Messages/questions to send to ChatGPT — each runs in its own fresh conversation
- `maxConcurrency` (integer, default 1): How many browser sessions to run in parallel (see "Parallel processing" below)
- `maxRequestRetries` (integer, default 3): Retries **per session** on failure — each retry uses a fresh browser and IP; already-answered prompts in the session are skipped
- `promptsPerSession` (integer, default 10): How many prompts to answer in one browser before starting a fresh browser/IP. Higher = faster (a running ChatGPT answers follow-ups in ~5s vs ~25s to start a new browser); those prompts share one IP
- `blockResources` (boolean, default true): Block images/fonts/media to cut residential proxy traffic (the biggest cost driver). JS/CSS/XHR are kept, so response extraction is unaffected
- `proxyCountry` (string): Select which country the proxy should be located in (optional, auto-selects if empty)

#### Parallel processing (chunking)

Prompts are grouped into **sessions** (chunks) of `promptsPerSession`. One session = one browser on one IP that answers its prompts one after another (reusing the browser via "new chat" — much faster than starting a new browser per prompt). `maxConcurrency` controls how many sessions run **in parallel**.

- **Number of sessions** = ⌈ number of prompts ÷ `promptsPerSession` ⌉
- **Run in parallel** = up to `maxConcurrency` sessions at a time

Each parallel session needs its own browser (~1 GB RAM), so raise the Actor's memory when you increase `maxConcurrency`. Parallelism makes the result arrive **faster** (less wall-clock time) for only a slight increase in usage cost — the total compute is roughly the same.

**Examples (25 prompts):**

| Config                                       | Sessions                  | Behaviour                                       | Memory                              |
| -------------------------------------------- | ------------------------- | ----------------------------------------------- | ----------------------------------- |
| `promptsPerSession: 10`, `maxConcurrency: 1` | 3 sessions of 10 / 10 / 5 | run **one after another** (1 browser at a time) | 2 GB (default)                      |
| `promptsPerSession: 10`, `maxConcurrency: 3` | 3 sessions of 10 / 10 / 5 | run **all 3 at once** — fastest                 | ~4 GB (≈ 1 GB per parallel session) |

> Note: the chunk size is set purely by `promptsPerSession`. With `promptsPerSession: 10` and 10 prompts you always get **one** session of 10 — `maxConcurrency` only matters once there is more than one session. For two parallel sessions of 5, set `promptsPerSession: 5`.

#### Output:

The Actor saves one dataset item per prompt:

- **prompt**: Original input prompt
- **success**: `true` if a response was extracted, `false` otherwise
- **error**: `null` on success, otherwise an error message (e.g. `EMPTY_RESPONSE`, `REQUEST_FAILED_AFTER_RETRIES`)
- **attempts**: Number of tries it took (including the final one)
- **responseText**: ChatGPT's response as plain text
- **responseMarkdown**: ChatGPT's response with formatting preserved (headings, lists, tables, code blocks) — ideal for further processing
- **sources**: Web sources as `{ position, text, url, domain, type }`, deduplicated by URL. The actor opens ChatGPT's full "Sources" sidebar, so bundled/hidden citations are included — not just the 2–3 inline pills. The `type` field tells you where each link came from:
  - `citation` — cited inline in the answer text
  - `source` — listed in the sources sidebar
  - `more` — additionally searched by ChatGPT but not directly cited
- **sourceDomains**: Unique host names of **cited** sources (`citation`/`source` only, e.g. `["www.nike.com", "bbc.com"]`) — the aggregated GEO metric. Host names are kept as-is (no `www`/subdomain stripping), so `www.nike.com` and `nike.com` count separately
- **newsListing**: Array of news items if present in responses
- **responseTimeMs**: How long the response generation took
- **promptIndex**: Index of current prompt (0-based)
- **totalPrompts**: Total number of prompts in batch
- **timestamp**: ISO timestamp of when the interaction occurred

> **Breaking change (v0.1):** `response` was replaced by `responseText`/`responseMarkdown`, `citations` was renamed to `sources` (now with `domain` and `position`, and now includes bundled/hidden citations — not just inline pills), `sourceDomains` was added, the `url` field was removed, and `success`/`error` are now present on every item.

#### Features:

- **Stealth Browsing**: Uses Camoufox to avoid detection and blocking
- **Proxy Support**: Automatically uses Apify proxy configuration when running on the platform
- **Country Selection**: Choose proxy location from 35+ countries for geo-specific responses
- **Error Handling**: Gracefully handles timeouts and extraction failures
- **Modal Handling**: Automatically closes ChatGPT's welcome dialogs and popups

# Actor input Schema

## `prompts` (type: `array`):

Array of messages/questions to send to ChatGPT. Each prompt runs in its own fresh conversation.

## `maxConcurrency` (type: `integer`):

How many browser sessions to run in parallel. Default 1 (fits in 2 GB RAM). Raise for speed, but each parallel session needs ~1 GB more memory — increase the Actor's memory accordingly (e.g. 4 GB for 3 parallel sessions). Usage cost rises slightly; the result just arrives faster.

## `maxRequestRetries` (type: `integer`):

How often to retry a browser session (a chunk of 'promptsPerSession' prompts) that hits a failure such as a block. Each retry uses a fresh browser and a new residential IP; prompts already answered in the session are skipped, so effectively the failing prompt(s) get retried on a new IP. The attempts made are reported per item as 'attempts'.

## `promptsPerSession` (type: `integer`):

How many prompts to handle in one browser session before starting a fresh browser/IP. Higher = faster (a running ChatGPT session answers follow-up prompts in ~5s vs. ~25s to start a new browser), but those prompts share one IP — if it gets blocked mid-session the rest retry on a new IP. Default 10.

## `blockResources` (type: `boolean`):

Block images, fonts and media to reduce residential proxy traffic (the biggest cost driver). JavaScript, CSS and XHR are always kept, so response extraction is unaffected. Disable only if you suspect it affects results.

## `proxyCountry` (type: `string`):

Select which country the proxy should be located in. Leave empty for automatic selection.

## Actor input object example

```json
{
  "prompts": [
    "What are most popular products from nike?",
    "What is the best chocolate?"
  ],
  "maxConcurrency": 1,
  "maxRequestRetries": 3,
  "promptsPerSession": 10,
  "blockResources": true,
  "proxyCountry": ""
}
```

# Actor output Schema

## `results` (type: `string`):

All results as JSON (one item per prompt: responseText, responseMarkdown, sources, sourceDomains, …)

## `run` (type: `string`):

API endpoint of this run (status, stats, storages)

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "prompts": [
        "What are most popular products from nike?",
        "What is the best chocolate?"
    ]
};

// Run the Actor and wait for it to finish
const run = await client.actor("automation_nerd/chatgpt-prompt-actor").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = { "prompts": [
        "What are most popular products from nike?",
        "What is the best chocolate?",
    ] }

# Run the Actor and wait for it to finish
run = client.actor("automation_nerd/chatgpt-prompt-actor").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "prompts": [
    "What are most popular products from nike?",
    "What is the best chocolate?"
  ]
}' |
apify call automation_nerd/chatgpt-prompt-actor --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,automation_nerd/chatgpt-prompt-actor"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/yzASbDEG7w2agWgw6/builds/coBfKeV6UtI32Rqro/openapi.json
