HeyPuter/puter · error · HttpError

upstream_bad_request

upstream_bad_request

Error message

Together AI response did not include image data

What it means

After a successful call to this.#client.images.generate(request), the Together AI SDK returned a response object, but its data array is missing or empty. This means Together accepted the request and returned an HTTP success, but the response body did not contain image data — typically indicating an upstream model error or an API contract change.

Source

Thrown at src/backend/drivers/ai-image/providers/together/TogetherImageProvider.ts:194

                selectedModel.resolution_map[ratioKey]?.[quality];
            if (resolutionEntry) {
                resolvedRatio = resolutionEntry;
            }
        }

        const request = this.#buildRequest(prompt, {
            ...options,
            ratio: resolvedRatio,
            model: selectedModel.id.replace('togetherai:', ''),
        }) as unknown as Together.Images.ImageGenerateParams;

        // Let SDK errors bubble — together-ai SDK errors carry `.status`
        // which the driver-boundary `translateProviderError` maps to
        // `upstream_*` HttpErrors. Re-wrapping in `new Error(...)` would
        // strip the status field and cause these to surface as 500s.
        const response = await this.#client.images.generate(request);
        if (!response?.data?.length) {
            throw new HttpError(
                400,
                'Together AI response did not include image data',
                {
                    legacyCode: 'upstream_bad_request',
                    fields: { provider: 'together' },
                },
            );
        }

        this.#meteringService.incrementUsage(
            actor,
            usageType,
            usageAmount,
            costInMicroCents,
        );

        const first = response.data[0] as {
            url?: string;

View on GitHub (pinned to 908ec23eda)

Solutions

  1. Retry the request after a brief delay — transient upstream issues often resolve.
  2. Check the Together AI status page for ongoing incidents.
  3. Log the full response object (including any error/message fields Together may include) for diagnosis.
  4. Verify the together-ai SDK version is compatible with the current API contract.

Example fix

// before — single call, no retry
const response = await this.#client.images.generate(request);

// after — retry with backoff for transient upstream issues
async function generateWithRetry(client, request, maxRetries = 2) {
  for (let i = 0; i <= maxRetries; i++) {
    const response = await client.images.generate(request);
    if (response?.data?.length) return response;
    if (i < maxRetries) await new Promise(r => setTimeout(r, 1000 * (i + 1)));
  }
  throw new Error('Together AI returned empty data after retries');
}
Defensive patterns

Strategy: retry

Try / catch

const MAX_RETRIES = 2;
let lastError;
for (let attempt = 0; attempt <= MAX_RETRIES; attempt++) {
  try {
    const response = await this.#client.images.generate(request);
    if (response?.data?.length) return response;
    lastError = new HttpError(400, 'Together AI returned empty data', { legacyCode: 'upstream_bad_request' });
  } catch (e) {
    lastError = e;
  }
  if (attempt < MAX_RETRIES) {
    await new Promise(r => setTimeout(r, 1000 * Math.pow(2, attempt)));
  }
}
throw lastError;

Prevention

When it happens

Trigger: Together AI returns a 200 with an empty data array; the response shape changed in a newer SDK version; the model is temporarily unavailable and returns an empty result instead of an error status; the response was truncated or malformed by a proxy.

Common situations: Transient Together AI platform issues where the model fails silently; a model deprecation where the endpoint returns success but no data; SDK version mismatch causing response parsing differences.

Related errors


AI-assisted analysis of HeyPuter/puter@908ec23eda (2026-08-12). Data as JSON: /api/errors/9ed58754a2e0b9da. Report an issue: GitHub.