ChatGPT is different from the API. The former has integrated browsing capabilities while the latter hasn’t. To enable web search via the API you need to implement a function call and in your back-end then run a web search API (e.g. the Bing API). The results from this search can be integrated as context into the model prompt to generate the actual response.
To get started, you might want to take a look at the functional calling documentation here.
In the following post, I included an example function description for web search: