HeyPuter/puter · error · HttpError
insufficient_funds
insufficient_funds
Error message
Insufficient credits for image generation
What it means
Thrown by ReplicateImageGenerationProvider.generate() (ReplicateImageGenerationProvider.ts:159) when hasEnoughCredits returns false for the computed totalCostMicroCents. Same insufficient-funds semantics as the Gemini/OpenAI equivalents, specific to the Replicate provider. HTTP 402 insufficient_funds.
Source
Thrown at src/backend/drivers/ai-image/providers/replicate/ReplicateImageGenerationProvider.ts:159
selectedModel,
outputMp,
goFast,
inputMp,
generationMode,
);
if (totalCostMicroCents <= 0) {
throw new HttpError(
400,
`Error calculating cost for Replicate model ${selectedModel.id}`,
{ legacyCode: 'unknown_error' },
);
}
const usageAllowed = await this.#meteringService.hasEnoughCredits(
actor,
totalCostMicroCents,
);
if (!usageAllowed) {
throw new HttpError(
402,
'Insufficient credits for image generation',
{
legacyCode: 'insufficient_funds',
},
);
}
const input = this.#buildRequest(selectedModel, {
prompt,
ratio,
transformed,
inputImages,
singleImage,
});
const output = await this.#client.run(
selectedModel.replicateId as `${string}/${string}`,View on GitHub (pinned to 908ec23eda)
Solutions
- Top up or grant credits to the actor.
- Reduce output_megapixels (default is 1; lower tiers cost less).
- Use a cheaper model (e.g. flux-schnell) or disable go_fast.
- Reduce the number of input images to cut input-megapixel cost.
- Confirm the metering balance is current and retry.
Defensive patterns
Strategy: try-catch
Validate before calling
if (!(await meteringService.hasEnoughCredits(actor, totalCostMicroCents))) {
// prompt top-up, reduce output_megapixels, fewer input images, or cheaper model
} Try / catch
try {
await provider.generate(params);
} catch (e) {
if (e instanceof HttpError && e.status_code === 402) {
// surface insufficient credits; offer cheaper model/lower megapixels/top-up
}
throw e;
} Prevention
- Pre-check balance against the estimated cost before calling generate.
- Lower output_megapixels or input image count to reduce cost.
- Default to flux-schnell or disable go_fast when balance is low.
When it happens
Trigger: Low-balance actor calling a Replicate model; a high-megapixel output or image-input-heavy request inflating the cost estimate beyond remaining credits; go_fast or a premium generation_mode raising the cost.
Common situations: Trial credits exhausted; user selected a large output_megapixels value; multiple input images adding input-megapixel cost; balance not refreshed after payment.
Related errors
AI-assisted analysis of HeyPuter/puter@908ec23eda (2026-08-12).
Data as JSON: /api/errors/e10456193cb0ddd9.
Report an issue: GitHub.