{"record":{"id":"790c45129a2ad26e","repo":"can1357/oh-my-pi","slug":"aspect-ratio-aspectratio-is-only-supported-by-x","errorCode":null,"errorMessage":"Aspect ratio ${aspectRatio} is only supported by xAI image generation. Set providers.image to xai or use one of ${COMMON_IMAGE_ASPECT_RATIOS.join(\", \")}.","messagePattern":"Aspect ratio (.+?) is only supported by xAI image generation\\. Set providers\\.image to xai or use one of (.+?)\\.","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/image-gen.ts","lineNumber":561,"sourceCode":"\t};\n}\n\n/** Configured provider priority set via `providers.imageOrder` (default: none). */\nlet configuredImageProviderOrder: readonly ImageProvider[] = [];\n\nexport function isImageProviderPreference(value: unknown): value is ImageProviderPreference {\n\treturn typeof value === \"string\" && IMAGE_PROVIDER_PREFERENCES.has(value);\n}\n\n/** Set the configured image-provider priority from settings; invalid IDs are dropped. */\nexport function setImageProviderOrder(providers: readonly string[]): void {\n\tconfiguredImageProviderOrder = providers.filter(isImageProviderId);\n}\nfunction assertImageAspectRatioSupported(provider: ImageProvider, aspectRatio: ImageGenParams[\"aspect_ratio\"]): void {\n\tif (!aspectRatio || provider === \"xai\" || COMMON_IMAGE_ASPECT_RATIO_SET.has(aspectRatio)) {\n\t\treturn;\n\t}\n\tthrow new Error(\n\t\t`Aspect ratio ${aspectRatio} is only supported by xAI image generation. Set providers.image to xai or use one of ${COMMON_IMAGE_ASPECT_RATIOS.join(\", \")}.`,\n\t);\n}\n\ninterface ParsedAntigravityCredentials {\n\taccessToken: string;\n\tprojectId: string;\n}\n\nfunction parseAntigravityCredentials(raw: string): ParsedAntigravityCredentials | null {\n\ttry {\n\t\tconst parsed = JSON.parse(raw) as { token?: string; projectId?: string };\n\t\tif (parsed.token && parsed.projectId) {\n\t\t\treturn { accessToken: parsed.token, projectId: parsed.projectId };\n\t\t}\n\t} catch {\n\t\t// Invalid JSON\n\t}","sourceCodeStart":543,"sourceCodeEnd":579,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/image-gen.ts#L543-L579","documentation":"Aspect ratios outside COMMON_IMAGE_ASPECT_RATIO_SET (the broadly supported ones like 1:1, 16:9, etc.) are implemented only by the xAI image provider. If the configured image provider is not xai and the caller requests an exotic aspect ratio, the tool fails fast with this message instead of sending a parameter the provider can't honor. The error text lists the accepted common ratios.","triggerScenarios":"Calling the image-gen tool with aspect_ratio set to a non-common value (e.g. 21:9, 9:16-custom, 4:5) while providers.image resolves to a non-xai provider (e.g. openai, google).","commonSituations":"Copying an aspect ratio from an xAI demo into a config defaulting to another provider; prompts that request unusual portrait ratios; shared configs where the provider changed after the ratio was set.","solutions":["Switch the image provider to xai (set providers.image to \"xai\") to use the custom aspect ratio","Or change aspect_ratio to one of the listed common ratios (e.g. 1:1, 16:9, 9:16) accepted by all providers","Drop the aspect_ratio parameter entirely to use the provider default"],"exampleFix":"// before\n\"providers\": { \"image\": \"openai\" }, \"aspect_ratio\": \"21:9\"\n// after\n\"providers\": { \"image\": \"xai\" }, \"aspect_ratio\": \"21:9\"","handlingStrategy":"validation","validationCode":"const COMMON_RATIOS = new Set([\"1:1\", \"3:2\", \"2:3\", \"3:4\", \"4:3\", \"9:16\", \"16:9\"]);\nfunction checkRatio(ratio: string | undefined, provider: string): void {\n\tif (ratio && provider !== \"xai\" && !COMMON_RATIOS.has(ratio)) {\n\t\tthrow new Error(`Ratio ${ratio} needs xai provider or a common ratio`);\n\t}\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Restrict aspect_ratio options in your UI/schema to the common set unless xai is configured","Keep providers.image and aspect_ratio settings in one validated config block","Drop aspect_ratio (use provider default) when provider support is unknown"],"tags":["validation","aspect-ratio","image-generation","provider-support"],"backgroundTag":"unsupported-aspect-ratio","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}