Skip to content

[Feature Request] Support Google Search Grounding with Structured Outputs - Gemini 3 #11599

@RobSchilderr

Description

@RobSchilderr

Description

Summary

The native Gemini API now supports combining Google Search grounding with structured outputs in a single call (Gemini 3+), but @ai-sdk/google doesn't expose this capability yet.

Native Gemini API Support

From the official Gemini documentation:

"Gemini 3 lets you combine Structured Outputs with built-in tools, including Grounding with Google Search, URL Context, Code Execution, and File Search."

This is available for gemini-3-pro-preview and gemini-3-flash-preview models. Ultimately they are now used with latest.

Current Limitation in @ai-sdk/google

When using @ai-sdk/google, you cannot use Google Search grounding (useSearchGrounding: true) together with structured outputs. This forces a workaround with two separate API calls:

  1. Phase 1: Call with grounding enabled to search and gather information (no structured output)
  2. Phase 2: Call without grounding to extract structured JSON from the Phase 1 results

This adds latency, doubles API costs, and introduces complexity in matching grounding sources between phases.

Desired Behavior

Allow combining grounding with structured outputs in a single call, matching what the native Gemini API supports:

const result = await generateObject({
  model: google("gemini-3-flash-preview", {
    useSearchGrounding: true,
  }),
  schema: mySchema,
  prompt: "Research this topic and return structured data",
});

// result.object contains structured data
// result.experimental_providerMetadata?.google?.groundingMetadata contains sources

References

AI SDK Version

  • ai: 6.0.6
  • @ai-sdk/google: 3.0.2

Code of Conduct

  • I agree to follow this project's Code of Conduct

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions