Skip to content

AI Gateway: Vertex rejects thought signatures from Google AI Studio on mid-conversation failover #14196

@shtefcs

Description

@shtefcs

Description

When using the AI Gateway with order: ['google', 'vertex'], mid-conversation provider failover causes Vertex to reject the request with 400: "Unable to submit request because Thought signature is not valid."

Steps to reproduce

  1. Use google/gemini-3-flash with order: ['google', 'vertex'] in providerOptions
  2. Run a multi-step agent session (10+ tool call steps using streamText with tools)
  3. Wait for Google AI Studio to return 503 (intermittent capacity issue on preview models)
  4. Gateway automatically fails over to Vertex for the next step
  5. Vertex rejects with 400: "Thought signature is not valid"

What happens

Steps 1-10 run fine on Google AI Studio. Each step generates tool calls with thought signatures. On step 11, Google returns 503. The Gateway tries Vertex as the next provider in the order. Vertex receives the full conversation history including thought signatures generated by Google AI Studio, and rejects them as invalid.

Error from Gateway routing metadata

```json
{
"modelAttemptCount": 1,
"providerAttempts": [
{ "provider": "google", "statusCode": 503, "error": "Service temporarily unavailable" },
{ "provider": "vertex", "statusCode": 400, "error": "Unable to submit request because Thought signature is not valid." }
]
}
```

The full URL Vertex tried to hit: `https://aiplatform.googleapis.com/v1beta1/projects/141030677902/locations/global/publishers/google/models/gemini-3-flash-preview:streamGenerateContent?alt=sse\`

Workaround

Using `only: ['google']` prevents the failover and avoids the error. But this means we lose Vertex as a fallback when Google has capacity issues (503s), which happen regularly with preview models.

We also added `models: ['moonshotai/kimi-k2.5']` as a model-level fallback so when Google 503s, it falls back to a completely different model instead of trying Vertex with incompatible signatures.

Environment

  • ai: 6.0.141
  • @ai-sdk/gateway: 3.0.83
  • @ai-sdk/google: 3.0.53 (transitive)
  • Model: google/gemini-3-flash (resolves to gemini-3-flash-preview)
  • Using Vercel AI Gateway with OIDC auth on Vercel deployment

Related issues

Metadata

Metadata

Assignees

No one assigned

    Labels

    ai/providerrelated to a provider package. Must be assigned together with at least one `provider/*` labelbugSomething isn't working as documentedprovider/gatewayIssues related to the @ai-sdk/gateway providerprovider/googleIssues related to the @ai-sdk/google providerprovider/google-vertexIssues related to the @ai-sdk/google-vertex providerreproduction provided

    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