# Upscrape ChatGPT Answers LLM Integration Prompt

Give this to an LLM or coding agent. It must fetch the OpenAPI spec first and use this brief only for orientation.

## First Step

Fetch and read this OpenAPI spec before writing code:

https://data.upscrape.com/catalog/platforms/chatgpt/openapi.json?token=SFMyNTY.g2gDdAAAAAFtAAAAC3BsYXRmb3JtX2lkbQAAAAdjaGF0Z3B0bgYAs5q0yJ8BYgABUYA.UJfbU2ASreQEM57thqJop7x_kTo9NCCkoHkXpeFXa5I
This signed OpenAPI URL is valid for approximately 7 days.

## Hard Rules

- Use the OpenAPI spec as the source of truth for endpoints, request bodies, response envelopes, errors, and input JSON schemas.
- Raw capability output is intentionally open-ended. Treat any included output example as illustrative, not as a fixed schema.
- Authenticate every request with `Authorization: Bearer YOUR_API_KEY`.
- Start runs with `POST /execute`; do not invent platform-specific execute endpoints.
- Poll `GET /jobs/{id}` or `GET /jobs/{id}/result` until `state` is `completed` or `failed`.
- Optionally send `Prefer: wait=N` on `POST /execute` to wait up to N seconds for inline results.
- If the response is `200`, the job completed — read `results[0].data`. If `202`, poll `GET /jobs/{id}`.

## API Base

- Base URL: `https://data.upscrape.com`
- OpenAPI spec: `https://data.upscrape.com/catalog/platforms/chatgpt/openapi.json?token=SFMyNTY.g2gDdAAAAAFtAAAAC3BsYXRmb3JtX2lkbQAAAAdjaGF0Z3B0bgYAs5q0yJ8BYgABUYA.UJfbU2ASreQEM57thqJop7x_kTo9NCCkoHkXpeFXa5I`
- Execute endpoint: `POST /execute`
- Job poll endpoint: `GET /jobs/{id}`
- Result alias: `GET /jobs/{id}/result`
- Content-Type: `application/json`
- Optional header: `Idempotency-Key`
- Optional header: `Prefer: wait=N` (hold connection up to N seconds for synchronous result)

## Execution Flow

1. Send `POST /execute` with a platform capability ID and its `input` object.
2. The API responds with a queued `job_id`.
3. Poll the job endpoint until `state` becomes `completed` or `failed`.
4. If completed, read `results[0].data`; its raw JSON shape may evolve with the upstream source.

## Example Execute Request

```json
{
  "capability": "chatgpt.answer.generate",
  "input": {
    "country": "United States",
    "country_mode": "best_effort",
    "include_sources": true,
    "locale": "en-US",
    "max_sources": 6,
    "mode": "search",
    "model": "auto",
    "prompt": "As of 2026-08-03, explain how the official MCP Streamable HTTP transport handles session creation, subsequent protocol headers, and expired sessions. Separate protocol requirements from client design choices.",
    "source_policy": {
      "official_sources_only": true,
      "preferred_domains": [
        "modelcontextprotocol.io"
      ],
      "published_after": "2025-01-01"
    },
    "timezone": "America/New_York"
  }
}
```

## Optional Request Fields

- `network.session_id`: explicit reusable session identifier
- `network.session_key`: stable key used to derive a reusable session
- `network.sticky`: reuse the resolved session when `true`
- `timeout_ms`: per-capability timeout override up to the capability maximum listed below

## Supported Capabilities

- `chatgpt.answer.generate` - Generate answer. Submit a prompt with locale, country, search, and source-policy controls in a fresh ChatGPT context; return a complete answer, citations, and execution evidence. Max `timeout_ms`: 120000.