How can I use the search api?

I’m building a side project with 4o-mini, however, the results are inconsistent where the results using the actual chatgpt app using the same exact query are accurate because it uses search. This seems to make the model closer to deterministic.

Is there a way to access the search api? If not, are there other ai apis that may provide more accurate and reliable results?

Thank you!

8 Likes

Hi @arshia !

Currently there is no support for web search via API.

If you would like to try search via API, the simplest is to use Perplexity AI’s “online” suite of models (see here).

The alternative is to implement some kind of a search + GPT-4o combo yourself from scratch, by e.g. combining either Bing API with GPT-4o (see here), or using Serpapi with GPT-4o.

5 Likes

Are there plans to offer API to the search function? (Similar to what Perplexity does?)

2 Likes

Got it. Thanks @platypus !

If I may follow up, what is the best way to make outputs deterministic at the moment?

One approach ai suggests is parse keywords out of an input, integrate a database, then search the database based on the parsed keywords to return the appropriate output.

3 Likes

That’s a super interesting idea!

I did some work with this and even dampening the sampling significantly (setting the temperature to 0), and setting the seed value still gives me some variation with outputs.

The best approach I found is using enums in structured outputs as much as possible, because the token mask guarantees that only one of the items in enums will be sampled. But this isn’t feasible all the time

1 Like

If you really want to make the AI “deterministic” to a fault, you could just hash and record the complete API input and parameters sent that affect generation and cache the response. No need to ever send identical inputs again.

Generate with max_response_tokens: 10 to see if the AI even wants to depart from the start of the previous if you are 90%+ getting the same beginning against the same fingerprints.

Run embeddings between the responses to see if the meaning drops below a threshold of being a different answer.

1 Like

It’s been 2 months since someone asked if search will ever be added to the API. An answer would be nice. Specially as most of us are paying for this, and I was paying for it for months before I realized there was a difference between the same model through the website as there is using the same model via API.

5 Likes

now, it is also possible to use search on the website for free, it would be nice to know if we can also use it from API.

3 Likes

I can’t speak for OpenAI, but think of it this way:

  • ChatGPT is an AI product;
  • The API is for building AI products.

You aren’t distinguishing yourself if you’d use the same search and model as ChatGPT or any other developer. Ask them to do even more of the work for you, you just being an “OpenAI wrapper”, and you might as well ask for “ChatGPT, but with our logo at the top and we get some of the money” (which never materialized with GPTs).

Building an in-house search is a big value add to the product, development sustained by a billion dollars of billables. Free is a constant enticement to click “purchase”.


API products do not have internet access, which I expect to continue.

You can make your own with an internet search API service, a web retriever, a screenshot visualizer, new ideas not yet demonstrated. You can implement this with functions the AI can call, automatic RAG, or agentic knowledge exploration.

1 Like

Thanks for your suggestion, I havn`t thought about it in depth. Just feel that the knowledge from API and website even under the same version, GPT 4o still quiet different.

1 Like

Any updates on this topic? @platypus

1 Like

The point of API is mainly to consume programmatically the same service I get in UI. I need the endpoint, not a lecture.

12 Likes

Per my tests, Perplexity “online” does not work well. Misses a ton of crucial info. IMHO, best approach is a search API + GPT combo.

2 Likes

Java fetch is interesting.

Java fetch is pretty useful for grabbing data fast without messing up the flow. You can pull search results in the background and have AI process them while still responding quick. It’s kinda like giving GPT an extra set of eyes. Makes API searches way smoother if you set it up

kinda like a web browser, but instead of showing pages, it just grabs data and hands it off. You can use it to pull info from APIs, stick links in responses, and even make AI cite sources in real-time. It’s like giving your code a way to go fetch the facts without needing a whole webpage

Fetch is like a meta search engine, but instead of just showing results, it pulls raw data and lets you work with it however you want. You can grab info, add links, make AI process it, whatever fits

2 Likes

Yes, I’m super surprised to find out that the API cannot get up-to-date information too. When is this coming?

1 Like

Dear OpenAI team, as can be seen CLEARLY in this thread, so many people (that PAY to use your API) want to know when it will be possible to use search with the API. I think it would be only fair to get an official response instead of ignoring us!

3 Likes

Meanwhile, we’re using Perplexity.ai API, which seems to be very straight forward, and recently also upgraded pretty significantly and produces great - high accuracy - results.

which model is the best for this? i want search api

A quick way to solve this is by using https://serpapi.com

It’s an API that returns Google results for your question.

If you know the information that needs to be retrieved, you can make the Serp API call and then pass the results in the context window of the Open Ai assistant or even use the Chat completion endpoint

If you need to let the AI assistant choose what needs to be searched, you can add it as a function calling in an Assistant.

If anybody is interested, I offer my services as a freelancer for setting up :slight_smile:

there’s an api (actor) at apify called gpt-search-private-api that does this