vercel/ai · error

Fireworks poll response is Ready but missing result.sample

Error message

Fireworks poll response is Ready but missing result.sample

What it means

The Fireworks image model polls an image generation request until its status is 'Ready'. When status is Ready but `result.sample` (the generated image URL) is absent or not a string, it throws a plain Error indicating the response is inconsistent. This guards against a malformed Fireworks polling response.

Source

Thrown at packages/fireworks/src/fireworks-image-model.ts:367

        url: pollUrl,
        headers,
        body: { id: requestId },
        failedResponseHandler: createStatusCodeErrorResponseHandler(),
        successfulResponseHandler: createJsonResponseHandler(
          asyncPollResponseSchema,
        ),
        abortSignal,
        fetch: this.config.fetch,
      });

      const status = pollResponse.status;

      if (status === 'Ready') {
        const imageUrl = pollResponse.result?.sample;
        if (typeof imageUrl === 'string') {
          return imageUrl;
        }
        throw new Error(
          'Fireworks poll response is Ready but missing result.sample',
        );
      }

      if (status === 'Error' || status === 'Failed') {
        throw new Error(
          `Fireworks image generation failed with status: ${status}`,
        );
      }

      // Wait before next poll attempt
      await delay(pollIntervalMillis);
    }

    throw new Error(
      `Fireworks image generation timed out after ${pollTimeoutMillis}ms`,
    );
  }

View on GitHub (pinned to 69428b1f8b)

Solutions

  1. Upgrade @ai-sdk/fireworks to the latest version
  2. Retry the image generation request
  3. Inspect the raw poll response payload to confirm the `result` shape
  4. Check Fireworks status/announcements for API changes

Example fix

// before
pnpm add @ai-sdk/fireworks@1.0.0
// after
pnpm add @ai-sdk/fireworks@latest
Defensive patterns

Strategy: retry

Validate before calling

// guard raw poll responses when reading them directly
function pollHasSample(r: unknown): r is { status: string; result: { sample: string } } {
  return typeof r === 'object' && r !== null && typeof (r as any).result?.sample === 'string';
}

Type guard

function isMissingSampleError(e: unknown): boolean {
  return e instanceof Error && e.message.includes('missing result.sample');
}

Try / catch

try {
  return await generateImage({ model: fireworks.image(modelId), prompt });
} catch (e) {
  if (e instanceof Error && e.message.includes('missing result.sample')) {
    return retry(() => generateImage({ model: fireworks.image(modelId), prompt }));
  }
  throw e;
}

Prevention

When it happens

Trigger: Calling `fireworks.image(...).doGenerate` where a poll request returns `status: 'Ready'` but the body lacks `result.sample` — Fireworks API contract change, truncated response, or proxy interference.

Common situations: Outdated @ai-sdk/fireworks against an updated Fireworks REST API; corporate proxy or gateway rewriting JSON; rare Fireworks-side inconsistency between status and result payload.

Related errors


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