Skip to content

Go SDK (openai‑go): Add support for web_search tool in Responses API (docs now use web_search; SDK only exposes web_search_preview) #493

@ando-masaki

Description

@ando-masaki

Summary

OpenAI’s latest documentation and cookbook examples show the Responses API using the web_search tool (stable), but the official Go SDK currently exposes only preview types (web_search_preview, web_search_preview_2025_03_11).
This creates a mismatch and makes it harder to follow the docs from Go.

What happened

When trying to enable web search with the Responses API from Go, there is no typed constant for web_search.
The responses package defines WebSearchToolType with only preview values:

// From pkg.go.dev docs for github.com/openai/openai-go/responses
// WebSearchToolType: "web_search_preview" | "web_search_preview_2025_03_11"

There is no WebSearchToolTypeWebSearch (or equivalent) even though the docs demonstrate:

"tools": [{ "type": "web_search" }]

References

  • Cookbook example uses "type": "web_search".
  • SDK docs show only preview enum values for WebSearchToolType.

Expected behavior

The Go SDK should provide first-class typed support for the stable web_search tool in the Responses API, e.g., a WebSearchToolTypeWebSearch constant (or accepting "web_search" without resorting to raw strings), aligning with the official docs/cookbook.

Actual behavior

Only preview types are available in the Go SDK (web_search_preview, web_search_preview_2025_03_11).
Related streaming event types already use web_search_call naming, which further highlights the inconsistency.

Minimal example (illustrative)

// go.mod: github.com/openai/openai-go/v2 v2.1.1
// (code simplified to illustrate the missing constant)

import "github.com/openai/openai-go/responses"

_ = responses.WebSearchToolParam{
    // No typed constant available for "web_search" in the SDK today.
    Type: responses.WebSearchToolType("web_search"),
}

The docs suggest creating a Responses request with:

"tools": [{ "type": "web_search" }]

…but the Go SDK doesn’t expose a matching typed value.

Environment

  • openai-go: v2.1.1 (latest as of Aug 2025)
  • Go: (e.g.) 1.22.x
  • OS: (e.g.) macOS 14 / Linux

Workaround

Continue using web_search_preview types from the SDK until web_search is available, but this diverges from the current docs.

Proposed fix

  1. Add stable web_search support to the Responses tool types in responses:
    • Introduce a typed constant for web_search (e.g., WebSearchToolTypeWebSearch) alongside existing preview values.
    • Ensure WebSearchToolParam and any related option structs accept it.
  2. Update examples/tests to use web_search for Responses to match the docs/cookbook.
  3. (Optional) Keep preview values for backward compatibility.

I’m happy to help with a PR if this direction sounds good. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions