chatboxai/chatbox · error · ApiError
Provider doesnt support image generation
Error message
Provider doesnt support image generation
What it means
Thrown by AbstractAISDK.paint when this.getImageModel() returns a falsy value — the current provider configuration exposes no image-generation model to the AI SDK. The check happens before generateImage is called, so no provider request is attempted; this is a capability-mismatch error, not a network error.
Source
Thrown at src/shared/models/abstract-ai-sdk.ts:431
() => {}
)
await streamIterator.return?.().catch(() => {})
}
}
public async paint(
params: {
prompt: string
images?: { imageUrl: string }[]
num: number
aspectRatio?: string
},
signal?: AbortSignal,
callback?: (picBase64: string) => void | Promise<void>
): Promise<string[]> {
const imageModel = this.getImageModel()
if (!imageModel) {
throw new ApiError('Provider doesnt support image generation')
}
const result = await generateImage({
model: imageModel,
prompt: params.prompt,
// images 暂时不支持
n: params.num,
abortSignal: signal,
// Image generation is billable; network-error retries could double-charge.
maxRetries: 0,
})
const dataUrls = result.images.map((image) => `data:${image.mediaType};base64,${image.base64}`)
for (const dataUrl of dataUrls) {
await callback?.(dataUrl)
}
return dataUrls
}
/**View on GitHub (pinned to 81571269ad)
Solutions
- Switch to a provider+model that supports image generation (e.g. OpenAI gpt-image, a DALL·E model, Google Imagen) before invoking paint.
- If you control the provider config, populate the imageModel field / implement getImageModel() to return a valid SDK image model.
- In the UI, gate the 'generate image' control on whether the active provider exposes an image model (call getImageModel() to enable/disable the button).
- Catch this ApiError and show the user a targeted 'this model cannot generate images' message rather than a generic failure.
Example fix
// before
const imageModel = this.getImageModel()
if (!imageModel) {
throw new ApiError('Provider doesnt support image generation')
}
// after — include the provider/model id for actionable UX
const imageModel = this.getImageModel()
if (!imageModel) {
throw new ApiError(`Provider ${this.name} (${this.options.model.modelId}) does not support image generation`)
} Defensive patterns
Strategy: type-guard
Validate before calling
// Before calling paint(), confirm the provider exposes an image model.
function providerCanPaint(sdk: AbstractAISDK): boolean {
return Boolean(sdk.getImageModel())
}
if (!providerCanPaint(sdk)) {
showUser('This model cannot generate images. Pick an image-capable model.')
return
} Type guard
function supportsImageGeneration(sdk: { getImageModel(): unknown }): boolean {
return Boolean(sdk.getImageModel())
} Try / catch
try {
await sdk.paint({ prompt, num })
} catch (e) {
if (e instanceof ApiError && /doesn't support image generation/i.test(e.message)) {
promptUserToSelectImageModel()
return
}
throw e
} Prevention
- Gate the 'generate image' UI action on getImageModel() truthiness so users never trigger this error.
- When building a custom provider, populate imageModel or override getImageModel() if image gen is supported.
- Show model capability badges in the model picker so users can tell which models support images.
When it happens
Trigger: paint() is invoked (image generation requested) on a provider whose getImageModel() returns undefined — e.g. a chat-only provider, a provider whose config doesn't declare an image model, or a provider type for which image generation isn't implemented in this SDK subclass.
Common situations: User picked a text-only model (e.g. a generic OpenAI chat model) and clicked 'generate image'; provider config missing the imageModel field; model id resolves to a chat model but the UI offered the paint action; a custom provider that doesn't expose DALL·E/Imagen-style endpoints.
Related errors
- No readable text content found in EPUB file
- Embedding batch failed: expected ${batchTexts.length}, got $
- Custom provider "${providerId}" conflicts with a builtin pro
- Image generation requires an active chat session.
- Missing --prompt.
AI-assisted analysis of chatboxai/chatbox@81571269ad (2026-08-12).
Data as JSON: /api/errors/0bf617690263ec81.
Report an issue: GitHub.