> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/web-scraper-api/targets/llms-and-ai/chatgpt.md).

# ChatGPT

Extract ChatGPT responses by submitting prompts, with parsed data including response text, Markdown output, citations, external links, and shopping product details.

The `chatgpt` source lets you submit a prompt to [**ChatGPT**](/api-reference/dedicated-scrapers/llm-and-ai-scrapers.md#chatgpt) and receive a fully parsed, structured response, including the plain-text and Markdown answer, source citations, and shopping products and ads.

## Request samples

The following code examples demonstrate how to submit a prompt to ChatGPT using [**Push-Pull**](/products/web-scraper-api/integration-methods/push-pull.md).

{% tabs %}
{% tab title="cURL" %}

```bash
curl 'https://data.oxylabs.io/v1/queries' \
--user 'USERNAME:PASSWORD' \
-H 'Content-Type: application/json' \
-d '{
        "source": "chatgpt",
        "prompt": "best supplements for better sleep",
        "parse": true,
        "geo_location": "United States",
        "callback_url": "https://your-server.com/oxylabs-callback"
    }'
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
from pprint import pprint

# Structure payload.
payload = {
    'source': 'chatgpt',
    'prompt': 'best supplements for better sleep',
    'parse': True,
    'geo_location': "United States",
    'callback_url': "https://your-server.com/oxylabs-callback"
}

# Get response.
response = requests.request(
    'POST',
    'https://data.oxylabs.io/v1/queries',
    auth=('USERNAME', 'PASSWORD'),
    json=payload,
)

# Print prettified response to stdout.
pprint(response.json())
```

{% endtab %}

{% tab title="Node.js" %}

```javascript
const https = require("https");

const username = "USERNAME";
const password = "PASSWORD";
const body = {
    source: "chatgpt",
    prompt: "best supplements for better sleep",
    parse: true,
    geo_location: "United States",
    callback_url: "https://your-server.com/oxylabs-callback"
};

const options = {
    hostname: "data.oxylabs.io",
    path: "/v1/queries",
    method: "POST",
    headers: {
        "Content-Type": "application/json",
        Authorization:
            "Basic " + Buffer.from(`${username}:${password}`).toString("base64"),
    },
};

const request = https.request(options, (response) => {
    let data = "";

    response.on("data", (chunk) => {
        data += chunk;
    });

    response.on("end", () => {
        const responseData = JSON.parse(data);
        console.log(JSON.stringify(responseData, null, 2));
    });
});

request.on("error", (error) => {
    console.error("Error:", error);
});

request.write(JSON.stringify(body));
request.end();
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php

$params = array(
    'source' => 'chatgpt',
    'prompt' => 'best supplements for better sleep',
    'parse' => true,
    'geo_location' => "United States",
    'callback_url' => "https://your-server.com/oxylabs-callback"
);

$ch = curl_init();

curl_setopt($ch, CURLOPT_URL, "https://data.oxylabs.io/v1/queries");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($params));
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_USERPWD, "USERNAME" . ":" . "PASSWORD");


$headers = array();
$headers[] = "Content-Type: application/json";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

$result = curl_exec($ch);
echo $result;

if (curl_errno($ch)) {
    echo 'Error:' . curl_error($ch);
}
curl_close($ch);
```

{% endtab %}

{% tab title="Golang" %}

```go
package main

import (
"bytes"
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)

func main() {
const Username = "USERNAME"
const Password = "PASSWORD"

  payload := map[string]interface{}{
        "source": "chatgpt",
        "prompt": "best supplements for better sleep",
        "parse":  true,
        "geo_location": "United States",
        "callback_url": "https://your-server.com/oxylabs-callback",
    }

jsonValue, _ := json.Marshal(payload)

client := &http.Client{}
request, _ := http.NewRequest("POST",
"https://data.oxylabs.io/v1/queries",
bytes.NewBuffer(jsonValue),
)

request.SetBasicAuth(Username, Password)
response, _ := client.Do(request)

responseText, _ := ioutil.ReadAll(response.Body)
fmt.Println(string(responseText))
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Net.Http.Json;
using System.Threading.Tasks;

namespace OxyApi
{
    class Program
    {
        static async Task Main()
        {
            const string Username = "USERNAME";
            const string Password = "PASSWORD";

            var parameters = new
            {
                source = "chatgpt",
                prompt = "best supplements for better sleep",
                parse = true,
                geo_location = "United States",
                callback_url = "https://your-server.com/oxylabs-callback"
            };

            var client = new HttpClient();

            Uri baseUri = new Uri("https://data.oxylabs.io");
            client.BaseAddress = baseUri;

            var requestMessage = new HttpRequestMessage(HttpMethod.Post, "/v1/queries");
            requestMessage.Content = JsonContent.Create(parameters);

            var authenticationString = $"{Username}:{Password}";
            var base64EncodedAuthenticationString = Convert.ToBase64String(System.Text.ASCIIEncoding.UTF8.GetBytes(authenticationString));
            requestMessage.Headers.Add("Authorization", "Basic " + base64EncodedAuthenticationString);

            var response = await client.SendAsync(requestMessage);
            var contents = await response.Content.ReadAsStringAsync();

            Console.WriteLine(contents);
        }
    }
}
```

{% endtab %}

{% tab title="Java" %}

```java
package org.example;

import okhttp3.*;
import org.json.JSONArray;
import org.json.JSONObject;

public class Main implements Runnable {
    private static final String AUTHORIZATION_HEADER = "Authorization";
    public static final String USERNAME = "USERNAME";
    public static final String PASSWORD = "PASSWORD";

    public void run() {
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("source", "chatgpt");
        jsonObject.put("prompt", "best supplements for better sleep");
        jsonObject.put("parse", true);
        jsonObject.put("geo_location", "United States");
        jsonObject.put("callback_url", "https://your-server.com/oxylabs-callback");

        Authenticator authenticator = (route, response) -> {
            String credential = Credentials.basic(USERNAME, PASSWORD);
            return response
                    .request()
                    .newBuilder()
                    .header(AUTHORIZATION_HEADER, credential)
                    .build();
        };

        var client = new OkHttpClient.Builder()
                .authenticator(authenticator)
                .build();

        var mediaType = MediaType.parse("application/json; charset=utf-8");
        var body = RequestBody.create(jsonObject.toString(), mediaType);
        var request = new Request.Builder()
                .url("https://data.oxylabs.io/v1/queries")
                .post(body)
                .build();

        try (var response = client.newCall(request).execute()) {
            if (response.body() != null) {
                try (var responseBody = response.body()) {
                    System.out.println(responseBody.string());
                }
            }
        } catch (Exception exception) {
            System.out.println("Error: " + exception.getMessage());
        }

        System.exit(0);
    }

    public static void main(String[] args) {
        new Thread(new Main()).start();
    }
}
```

{% endtab %}

{% tab title="JSON" %}

```json
{
        "source": "chatgpt",
        "prompt": "best supplements for better sleep",
        "parse": true,
        "geo_location": "United States",
        "callback_url": "https://your-server.com/oxylabs-callback"
}
```

{% endtab %}
{% endtabs %}

{% hint style="info" %}
**Note:** JavaScript rendering is enabled by default for all LLM sources. You do not need to include rendering parameters in your request payload.
{% endhint %}

Submitting a job with [**Push-Pull**](/products/web-scraper-api/integration-methods/push-pull.md) integration method (including [batch queries](/products/web-scraper-api/integration-methods/push-pull.md#batch-query)) method returns the job ID immediately – not the result. Once the job status is `done`, retrieve the parsed response. See [**Integration method**](/products/web-scraper-api/integration-methods/push-pull.md) on the LLMs and AI page for the full submit-and-retrieve flow.

### Request parameters

Basic setup and customization options for scraping ChatGPT.

<table><thead><tr><th width="222">Parameter</th><th width="350.3333333333333">Description</th><th>Default Value</th></tr></thead><tbody><tr><td><mark style="background-color:green;"><strong><code>source</code></strong></mark></td><td>Sets the scraper target. Use <code>chatgpt</code>.</td><td>–</td></tr><tr><td><mark style="background-color:green;"><strong><code>prompt</code></strong></mark></td><td>The prompt or question to submit to ChatGPT. Up to 4,000 characters.</td><td>–</td></tr><tr><td><code>callback_url</code></td><td><strong>Recommended.</strong> URL where we deliver a notification once the job completes. <a href="https://developers.oxylabs.io/products/web-scraper-api/integration-methods/push-pull"><strong>More info</strong></a></td><td>–</td></tr><tr><td><code>search</code></td><td>Set to <code>true</code> for web search.</td><td><code>false</code></td></tr><tr><td><code>parse</code></td><td>Set to <code>true</code> for structured JSON results.</td><td><code>false</code></td></tr><tr><td><code>geo_location</code></td><td>Specify a country to route the request from. <a href="/products/web-scraper-api/features/localization.md"><strong>More info</strong></a>. </td><td>–</td></tr><tr><td><code>browser_instructions</code></td><td>Optional custom browser instructions when rendering JavaScript. <a href="/products/web-scraper-api/features/js-rendering-and-browser-control.md#browser-instructions"><strong>More info</strong></a>.</td><td>–</td></tr></tbody></table>

&#x20;   \- mandatory parameter

## Structured data

Once the job is retrieved via the Push-Pull results endpoint, Web Scraper API returns either an HTML or JSON object that contains ChatGPT output, with structured data on various elements of the results page.

In the examples below, long text values are shortened (`...`) and arrays are trimmed to the first few items.

<details>

<summary><code>chatgpt</code> structured output</summary>

```json
{
    "results": [
        {
            "job_id": "7513507166020492289",
            "status_code": 200,
            "url": "https://chatgpt.com/uc/6ac5fb18-4da4-83ea-a621-c610d8c36283",
            "content": {
                "prompt": "best supplements for better sleep",
                "response_text": "If your goal is better sleep , I’d keep the supplement stack simple. The evidence for most “sleep supplements” is surprisingly weak. Best options Melatonin — best for timing, jet lag, or trouble falli ...",
                "markdown_text": "If your goal is **better sleep**, I’d keep the supplement stack simple. The evidence for most “sleep supplements” is surprisingly weak.\n\n### Best options\n\n1. **Melatonin — best for timing, jet lag, or ...",
                "markdown_json": [
                    {
                        "children": [
                            {
                                "raw": "If your goal is ",
                                "type": "text"
                            },
                            {
                                "children": [
                                    {
                                        "raw": "better sleep",
                                        "type": "text"
                                    }
                                ],
                                "type": "strong"
                            },
                            {
                                "raw": ", I’d keep the supplement stack simple. The evidence for most “sleep supplements” is surprisingly weak.",
                                "type": "text"
                            }
                        ],
                        "type": "paragraph"
                    },
                    {
                        "type": "blank_line"
                    }
                ],
                "citations": [
                    {
                        "text": "NCCIH",
                        "title": "Melatonin: What You Need To Know | NCCIH",
                        "url": "https://www.nccih.nih.gov/health/melatonin-what-you-need-to-know?a70bf911_page=2&aa69e157_page=1&c159a325_page=2&utm_source=chatgpt.com"
                    },
                    {
                        "text": "NCCIH",
                        "title": "Sleep Disorders and Complementary Health Approaches: Usefulness and Safety | NCCIH",
                        "url": "https://www.nccih.nih.gov/health/sleep-disorders-and-complementary-health-approaches?utm_source=chatgpt.com"
                    },
                    {
                        "text": "PubMed",
                        "title": "Oral magnesium supplementation for insomnia in older adults: a Systematic Review & Meta-Analysis - PubMed",
                        "url": "https://pubmed.ncbi.nlm.nih.gov/33865376/?utm_source=chatgpt.com"
                    }
                ],
                "parse_status_code": 12000
            }
        }
    ]
}
```

</details>

When ChatGPT recommends products, the response also contains `shopping_products` with the details from each product's details sheet. The following example is from the prompt `best running shoes for flat feet`:

<details>

<summary><code>shopping_products</code> example</summary>

```json
{
    "shopping_products": [
        {
            "currency": "USD",
            "description": "The ASICS Men's GEL-KAYANO 31 is a strong choice for runners who want dependable stability paired with plush comfort for daily training and longer miles. Reviewers consistently highlight its durable c ...",
            "images": [
                "https://images.openai.com/static-rsc-1/yMpUQ70QnMPOLpTOHvY6R7AOszGDOM6GsNW9ViMloL4ZfIg5XxQ5odSQ14oNA32_vUZVjr2pjj2q6pOReSUTSjZ_KZ83jFSx2GJAyVp6S18FcdFJnqoyQkBvOer8K25j9MOgaSXyhuLa-Kti-4DuY02WzY1Q7gTx-e0KyaBnHjpEwX-Y9mY5Lnr1RCWbBwkDNC6od99Dz4dffL63GLYGlpblclv0v1YKizmvk9nEZus"
            ],
            "offers": [
                {
                    "currency": "USD",
                    "details": "In stock",
                    "merchant": "DICK’S Sporting Goods",
                    "price": 164.99,
                    "price_str": "$164.99",
                    "url": "https://www.dickssportinggoods.com/p/asics-mens-gel-kayano-31-running-shoes-24asimglkyn31smggmns/24asimglkyn31smggmns?sku=25422829&color=White+Sage&utm_source=chatgpt.com&oppcref=4aa33dbf-5e5c-4575-a677-485318d5b72f"
                },
                {
                    "currency": "USD",
                    "details": "In stock online, Delivery between Oct 9 - 19 $14",
                    "merchant": "VS Athletics",
                    "price": 165,
                    "price_str": "$165.00",
                    "url": "https://www.vsathletics.com/store/asics-gel-kayano-31-mens-1011b867-401.html?utm_source=chatgpt.com&oppcref=9d033abe-5e97-4ca5-9148-1e182cd63b2d"
                }
            ],
            "price": 164.99,
            "price_str": "$164.99",
            "rating": 4.6,
            "reviews": [
                {
                    "link_text": "Cut in half: ASICS Gel Kayano 31 Review",
                    "source": "RunRepeat",
                    "text": "Lab testing found the cushioning highly comfortable for impact protection, though the softer ride comes with a slight reduction in energy return, favoring comfort over a lively feel.",
                    "title": "Comfort vs. Energy Return",
                    "url": "https://runrepeat.com/asics-gel-kayano-31"
                }
            ],
            "reviews_count": 3941,
            "reviews_summary": "Across expert reviews, the GEL-KAYANO 31 is widely regarded as a comfortable, premium stability trainer with excellent durability and support. Most reviewers praise its plush cushioning and smooth rid ...",
            "thumbnail": "https://images.openai.com/static-rsc-1/yMpUQ70QnMPOLpTOHvY6R7AOszGDOM6GsNW9ViMloL4ZfIg5XxQ5odSQ14oNA32_vUZVjr2pjj2q6pOReSUTSjZ_KZ83jFSx2GJAyVp6S18FcdFJnqoyQkBvOer8K25j9MOgaSXyhuLa-Kti-4DuY02WzY1Q7gTx-e0KyaBnHjpEwX-Y9mY5Lnr1RCWbBwkDNC6od99Dz4dffL63GLYGlpblclv0v1YKizmvk9nEZus",
            "title": "ASICS GEL-KAYANO 31 Running Shoes"
        }
    ]
}
```

</details>

{% hint style="warning" %}
The composition of the response may vary depending on whether the query was made from a **desktop** or **mobile** device.
{% endhint %}

### Output data dictionary

#### HTML example

<figure><img src="https://3826932121-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FBQ7Zf9paoN3FTeGcyfY1%2Fuploads%2Fgit-blob-cb12a6dab81c0843699e150f596d72e0b5041eda%2FScreenshot%202025-07-21%20at%2012.54.42.png?alt=media" alt=""><figcaption></figcaption></figure>

#### JSON structure

All LLM targets return the same top-level `job` and `results[]` envelope. See [LLMs and AI](/api-reference/dedicated-scrapers/llm-and-ai-scrapers.md) for the full metadata reference.

The following table shows ChatGPT-specific `results[].content` fields:

{% hint style="info" %}
The number of items and fields for a specific result type may vary depending on the submitted prompt.
{% endhint %}

<table><thead><tr><th width="173">Field</th><th width="476">Description</th><th width="90">Type</th></tr></thead><tbody><tr><td><code>prompt</code></td><td>Submitted prompt to generate result.</td><td>string</td></tr><tr><td><code>response_text</code></td><td>Plain-text response from ChatGPT.</td><td>string</td></tr><tr><td><code>markdown_text</code></td><td>ChatGPT response as Markdown.</td><td>string</td></tr><tr><td><code>markdown_json</code></td><td>Structured JSON representation of the Markdown response. Each item contains <code>type</code> and <code>children</code>.</td><td>array</td></tr><tr><td><mark style="background-color:yellow;"><code>citations</code></mark></td><td>List of response source citations. Objects contain <code>title</code>, <code>url</code>, <code>text</code>, <code>description</code>, and <code>section</code>.</td><td>array</td></tr><tr><td><mark style="background-color:yellow;"><code>links</code></mark></td><td>List of objects for inline source link details: <code>url</code> and <code>text</code>.</td><td>array</td></tr><tr><td><mark style="background-color:yellow;"><code>shopping_products</code></mark></td><td>List of products ChatGPT recommends, with details from each product's details sheet. Objects contain <code>title</code>, <code>price</code>, <code>price_str</code>, <code>currency</code>, <code>rating</code>, <code>reviews_count</code>, <code>thumbnail</code>, <code>images</code> (image URLs from the product gallery), <code>description</code> (ChatGPT's summary of the product), <code>offers</code>, <code>reviews</code>, and <code>reviews_summary</code> (ChatGPT's summary of what reviewers say). Fields that ChatGPT does not show for a product are not returned.</td><td>array</td></tr><tr><td><code>shopping_products.offers</code></td><td>Merchant offers listed in the product details. Objects contain <code>merchant</code>, <code>price</code>, <code>price_str</code>, <code>currency</code>, <code>url</code>, and <code>details</code> (availability and delivery details, as displayed).</td><td>array</td></tr><tr><td><code>shopping_products.reviews</code></td><td>Review excerpts listed in the product details. Objects contain <code>source</code> (the reviewer or publication), <code>title</code> (the heading of the review), <code>text</code> (the review excerpt), <code>link_text</code> (the reviewed article's title), and <code>url</code> (the reviewed article's URL).</td><td>array</td></tr><tr><td><mark style="background-color:yellow;"><code>ads</code></mark></td><td>Ad details containing <code>url</code>, <code>title</code>, <code>image_url</code>, <code>description</code>, and an <code>advertiser_info</code> object.</td><td>array</td></tr><tr><td><mark style="background-color:yellow;"><code>ads.advertiser_info</code></mark></td><td>Object with advertiser <code>url</code>, <code>name</code>, and <code>image_data</code>.</td><td>object</td></tr><tr><td><code>raw_response</code></td><td>Raw streamed response from ChatGPT, one line per item.</td><td>array of strings</td></tr><tr><td><code>parse_status_code</code></td><td><code>12000</code> – successful. Otherwise, parser failed to extract some or all structured fields.</td><td>integer</td></tr></tbody></table>

&#x20;    – conditional, returned only when content is in the LLM's response.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://developers.oxylabs.io/products/web-scraper-api/targets/llms-and-ai/chatgpt.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
