Do chatGPT 4o Plus API has web browsing access

Hi Community,

Can anybody confirm me if I buy chat GPT4o Plus subscription then via its API can it be possible I can get web browsing results in my API output?

Does it need any setting turned on ?any parameter?property etc.

Please help ASAP =/=.

Welcome to the Community!

You might find this thread useful to get an answer to your question:

In general, you should bear in mind that ChatGPT and the API are different products. ChatGPT inherently comes with browsing capabilities (if enabled), while the API does not. However, you can use search APIs to create the same outcome using the API. The thread above will share a few more details in this regard.

2 Likes

Hi

This is not possible with the API.

I am using it combined with web scraping which actually works better than using gpts interface and telling it to go online.

1 Like

Hi,

I am interested and was looking into exactly what you described @tomarmstrong1.
Would you mind sharing with me the way that you are web scraping and how that is working sofar for you.

Hi,

I basically have a php script that uses a simple scraping API like scraping ant (not affiliated) which grabs the page.

I then pass that to GPT 4 and perform the query on that data in the open AI API.

I use this function to scrape

// ScrapingAnt Function
function scrapeURL($url, $type) {
    // Set your ScrapingAnt API key
    $apiKey = 'API KEY';

    $ch = curl_init();

    // ScrapingAnt API endpoint
    $scrapingAntUrl = 'https://api.scrapingant.com/v2/general?url=' . urlencode($url);

    // If a simple scrape is requested, add browser=false
    if ($type == 'simple') {
        //$scrapingAntUrl .= "&browser=false";
    }

    // Set up the cURL options
    curl_setopt($ch, CURLOPT_URL, $scrapingAntUrl);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
        "x-api-key: $apiKey"  // Corrected API key concatenation
    ));

    $retryCount = 0;
    $maxRetries = 5;
    $responseSize = 0;

    // Loop to retry while the response size is less than 1000 bytes
    while ($retryCount < $maxRetries) {
        // Execute the request and capture the response
        $response = curl_exec($ch);

        // If there is a cURL error, print it
        if (curl_errno($ch)) {
            echo 'cURL error: ' . curl_error($ch);
        }

        // Check if the response is valid and calculate the size
        if ($response) {
            $responseSize = strlen($response);
            echo "<br>Response size: " . $responseSize . " bytes<br>";

            // If the response size is 1000 bytes or more, break the loop
            if ($responseSize >= 1000) {
                break;
            }
        }

        // If the response size is less than 1000, sleep for 1 second and retry
        $retryCount++;
        echo "<br>Retrying... attempt $retryCount<br>";
        sleep(1);
    }

    // Close the cURL session
    curl_close($ch);

    // Return the response if valid, otherwise return an error message
    if ($responseSize >= 1000) {
        return $response;
    } else {
        return "Couldn't get a valid response after $maxRetries attempts.";
    }
}

I then use this function to query the API


// Open AI call - generative

function makeQuery($query, $model) {
	
	print("<p>model: <strong>$model</strong></p>");	
	
	ini_set('display_errors', 1);
	ini_set('display_startup_errors', 1);
	error_reporting(E_ALL);

	$ch = curl_init();

	$url = 'https://api.openai.com/v1/chat/completions';

	$api_key = 'APIKEY';

	// Define the structured conversation with OpenAI's schema
	$messages = [
	[
		"role" => "system",
		"content" => "You are ChatGPT, a large language model trained by OpenAI. Answer as helpfully, accurately, and comprehensively as possible. Follow user instructions carefully. If unsure about an answer, explain your reasoning clearly."

	],
	[
		"role" => "user",
		"content" => $query
	]
	];

	$post_fields = array(
	"model" => $model,
	"messages" => $messages,
	"temperature" => 0.9
	);

	$header  = [
	'Content-Type: application/json',
	'Authorization: Bearer ' . $api_key
	];

	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($post_fields));
	curl_setopt($ch, CURLOPT_HTTPHEADER, $header);

	$result = curl_exec($ch);

	if (curl_errno($ch)) {
		echo 'Error: ' . curl_error($ch);
		exit; // Exit the script if there's an error
	}

	curl_close($ch);

	$response = json_decode($result);

	if (isset($response->error)) {
	echo 'API Error: ' . $response->error->message;
	exit; // Exit the script if there's an API error
	}

	$message_content = $response->choices[0]->message->content;
	
	//print_r($message_content);

	// Display the number of tokens used
	$usage = $response->usage;
	echo "Tokens used: " . $usage->total_tokens . PHP_EOL;

	return $message_content;

}

The query is something like:

Take a deep breath and read through all these instructions carefully.

Then write a fact-filled 190-200 word description of the holiday property in the reference text.
Make it look like a real person did it.

Writing style rules

Include all of the facts from the reference text.
strictly 190 - 200 words total for the whole description.
Pack the text with facts from the reference.
Cut out fluff and flowery language and use facts instead.
Don’t be corny or cringe.
Vary sentence length.
Use simple words.
Use as few commas as possible.
Vary sentence length dramatically.
Write naturally and focus on facts.
Vary sentence length fom 4 - 15 words.
Ask and answer questions.
Use natural human language.
Use Less commas and never use a comma just before and like this ‘, and’
Provide helpful content.
No headings.
Highlight ~3-4 cool benefits in tags.
Break the text into the paragraphs outlined and follow the instructions carefully.
Put paragraphs in

tags.
Add some adult humour.

Talk to them like a human and use a high degree of burstiness and non-ai language because the text should pass any ai detectors easily.

[reference Text start]
$context (the scraped page)
[reference Text end]

REMEMBER: 200 words max for all the text.";

Let me know if there’s anything else I can show.