Home › SpaceXSI API lesson 2: Web search, JSON

SpaceXSI API lesson 2: Web search, JSON

Last checked

Two features turn a chat model into something an app can rely on: the web_search tool lets Grok look things up now, and Structured Outputs make it reply in a JSON shape your code can read.

Step by step

  1. Add tools=[{"type": "web_search"}] to a responses.create request so Grok can search and browse the web.
  2. Read the citations returned with the answer and show them to your users.
  3. For X posts instead of web pages, use the separate x_search tool.
  4. To get JSON back, set response_format to type "json_schema" and pass your schema (you can write it with Pydantic or Zod).
  5. Mark which fields are required; fields not listed are optional, and additionalProperties defaults to false.
  6. Parse the reply in your code and handle the case where a value is null.

Try it: examples

Good to know

Sources (official pages, read Nov 8, 2026)

Written from SpaceXSI'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