How can I integrate 'Web Search' and 'Structured Output' together in a single request within the OpenAI API?

Hi everyone

I’m new to using the ChatGPT API, and I want to build an app that gives me match results for football players.

My plan is for OpenAI to use the Web Search tool to get the results and then create a structured JSON response for my backend using the Structured Output feature.

However, I’m not sure if the API allows using these tools together in a single request. Thanks for the feedback!

Here’s the background you’ll need!

  • Internal hosted tools such as web search are available on the Responses API endpoint
  • OpenAI also has a special Chat Completions AI model that is for web results without tools
  • You can provide a schema with a response format to be fulfilled as an API parameter
  • The web search invocation gets its own system prompt injected by OpenAI, so results are like Google + AI, with links.

Here’s a look at the surface of using the Chat Completions model, which doesn’t accept any parameters to tune the sampling, nor any ‘reasoning’ parameters.

1 Like