vercel/ai · error · Error

google.interactions: background POST response did not includ

Error message

google.interactions: background POST response did not include an interaction id; cannot stream the result.

What it means

When streaming a background Google interactions request, the initial POST must return an interaction `id` so the model can poll/stream the result. If the POST response has no id, doStreamBackground throws because the result cannot be streamed.

Source

Thrown at packages/google/src/interactions/google-interactions-language-model.ts:721

    pollingTimeoutMs: number | undefined;
  }): Promise<LanguageModelV4StreamResult> {
    const postResult = await postJsonToApi({
      url,
      headers: mergedHeaders,
      body: args,
      failedResponseHandler: googleFailedResponseHandler,
      successfulResponseHandler: createJsonResponseHandler(
        googleInteractionsResponseSchema,
      ),
      abortSignal: options.abortSignal,
      fetch: this.config.fetch,
    });

    const { responseHeaders: postHeaders, value: postResponse } = postResult;
    const interactionId = postResponse.id;

    if (interactionId == null || interactionId.length === 0) {
      throw new Error(
        'google.interactions: background POST response did not include an interaction id; cannot stream the result.',
      );
    }

    const headerServiceTier = postHeaders?.['x-gemini-service-tier'];

    /*
     * If the POST already returned a terminal status (e.g. cached, immediate
     * failure, or `incomplete`), there is nothing to stream from the GET --
     * synthesize directly from the response so the caller still gets a
     * complete stream.
     */
    if (isTerminalStatus(postResponse.status)) {
      const synthesized = synthesizeGoogleInteractionsAgentStream({
        response: postResponse,
        warnings,
        generateId: this.config.generateId ?? defaultGenerateId,
        includeRawChunks: options.includeRawChunks,

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Log the POST response body to check for embedded error details (message, status)
  2. Verify API key, quota, and that background mode is enabled/supported for the model and endpoint
  3. Update @ai-sdk/google so the interactions response schema matches the current API
  4. Retry the request; if the API consistently omits id, report with the sanitized response
Defensive patterns

Strategy: try-catch

Validate before calling

const post = /* background POST response */;
if (post?.id == null || post.id.length === 0) {
  // don't attempt streaming; log body and surface API error details
}

Type guard

function hasInteractionId(res: unknown): res is { id: string } {
  return typeof (res as any)?.id === 'string' && (res as any).id.length > 0;
}

Try / catch

try {
  const result = streamText({ model: google.interactions('gemini-...'), prompt, /* background */ });
} catch (error) {
  if (error instanceof Error && error.message.includes('did not include an interaction id')) {
    // inspect POST body for API error; check auth/quota/background support
  }
  throw error;
}

Prevention

When it happens

Trigger: Calling streamText/doStream with background mode against google.interactions where the POST response body's `id` field is null or empty — e.g. an error response parsed without an id, or schema drift.

Common situations: Gemini API returning an error payload in the POST body; authentication/quota issues surfacing as incomplete responses; outdated package not matching the current interactions API shape.

Related errors


AI-assisted analysis of vercel/ai@69428b1f8b (2026-08-30). Data as JSON: /api/errors/599cda06353f50be. Report an issue: GitHub.