Home › OpenAI API lesson 2: Web search, JSON

OpenAI API lesson 2: Web search, JSON

Last checked

Two built-in features make answers usable inside an app: the web_search tool for current information with citations, and Structured Outputs so the reply always matches your JSON schema.

Step by step

  1. Add tools: [{ type: "web_search" }] to a Responses API call.
  2. Read the url_citation annotations (URL, title, location) and show the sources to your users.
  3. For JSON, define a schema with Pydantic (Python) or Zod (JavaScript).
  4. Pass it as text_format (Python parse helper) or with zodTextFormat (JavaScript).
  5. Use the parsed object in your code instead of parsing free text.

Try it: examples

Good to know

Sources (official pages, read Nov 8, 2026)

Written from OpenAI's official documentation and product pages; we don't run hands-on tests. Features and limits vary by plan and country.

Report an error on this page