You indeed would need to create the same user experience. ChatGPT and Assistants both have internal OpenAI tools.
The linked post which you can expand goes into a bit of a tool call demonstration. You would need to find a web search API that can service requests for you, like Bing (expensive) or some other search scraper libraries that are out there.
The challenge is actually exploring the web to get full-page results on modern dynamic sites beyond search descriptions.
Citations would just be talking to the AI about some footnotes to produce, or some special marker format within its answers it should make for references, where you can rewrite and attach the resulting web links when you parse and render the answer.
TL;DR: System instructions, functions, linked function returns.