Skip to content

feat: add standard schema support for structured outputs and tools #1945

Description

@360ammar

Confirm this is a feature request for the Node library and not the underlying OpenAI API.

  • This is a feature request for the Node library

Describe the feature or improvement you're requesting

Summary

Add first-class Standard Schema support to the structured-output and tool helpers, so any conforming validation library — Zod, Valibot,
ArkType — works through a single integration, instead of a separate xResponseFormat / xFunction per library.

Why Standard Schema

One interface covers both jobs the helpers need:

Capability Spec member Notes
Parse model output ~standard.validate(value) Universal across conforming libraries; replaces the per-library parse callback.
Generate JSON Schema ~standard.jsonSchema The emerging Standard JSON Schema spec; used when a library exposes it.

Proposed shape

New helpers in src/helpers/standard-schema.ts, leaving the existing Zod helpers untouched:

  • standardResponseFormat
  • standardTextFormat
  • standardFunction
  • standardResponsesFunction

JSON Schema resolution — hybrid, in priority order:

  1. Caller-supplied schema, else
  2. ~standard.jsonSchema if the library exposes it, else
  3. a clear, actionable error.

The result is always passed through the existing toStrictJsonSchema transform, so output stays Structured-Outputs-compatible.

Key properties:

  • ✅ No new per-library dependencies — @standard-schema/spec is types-only.
  • ✅ Validation routes through ~standard.validate.
  • ✅ Full type inference via StandardSchemaV1.InferOutput.

Additional context

Follows the discussion in #1021

In that thread:

  • @RobertCraigie noted the SDK shouldn't vendor a JSON-Schema converter per library.
  • @fabian-hiller proposed Standard Schema to "reduce implementation effort and prevent vendor lock-in," later adding "it would be great if OpenAI could integrate it in the SDK."

A single Standard Schema integration addresses the converter-bloat concern directly.


I'm happy to put together a PR with the implementation and tests (Valibot + ArkType end-to-end, plus a Zod parity test). Opening this issue first to confirm direction and scope before writing the code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions