can1357/oh-my-pi · error

Aspect ratio ${aspectRatio} is only supported by xAI image g

Error message

Aspect ratio ${aspectRatio} is only supported by xAI image generation. Set providers.image to xai or use one of ${COMMON_IMAGE_ASPECT_RATIOS.join(", ")}.

What it means

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.

Source

Thrown at packages/coding-agent/src/tools/image-gen.ts:561

	};
}

/** Configured provider priority set via `providers.imageOrder` (default: none). */
let configuredImageProviderOrder: readonly ImageProvider[] = [];

export function isImageProviderPreference(value: unknown): value is ImageProviderPreference {
	return typeof value === "string" && IMAGE_PROVIDER_PREFERENCES.has(value);
}

/** Set the configured image-provider priority from settings; invalid IDs are dropped. */
export function setImageProviderOrder(providers: readonly string[]): void {
	configuredImageProviderOrder = providers.filter(isImageProviderId);
}
function assertImageAspectRatioSupported(provider: ImageProvider, aspectRatio: ImageGenParams["aspect_ratio"]): void {
	if (!aspectRatio || provider === "xai" || COMMON_IMAGE_ASPECT_RATIO_SET.has(aspectRatio)) {
		return;
	}
	throw new Error(
		`Aspect ratio ${aspectRatio} is only supported by xAI image generation. Set providers.image to xai or use one of ${COMMON_IMAGE_ASPECT_RATIOS.join(", ")}.`,
	);
}

interface ParsedAntigravityCredentials {
	accessToken: string;
	projectId: string;
}

function parseAntigravityCredentials(raw: string): ParsedAntigravityCredentials | null {
	try {
		const parsed = JSON.parse(raw) as { token?: string; projectId?: string };
		if (parsed.token && parsed.projectId) {
			return { accessToken: parsed.token, projectId: parsed.projectId };
		}
	} catch {
		// Invalid JSON
	}

View on GitHub (pinned to 9690622007)

Solutions

  1. Switch the image provider to xai (set providers.image to "xai") to use the custom aspect ratio
  2. Or change aspect_ratio to one of the listed common ratios (e.g. 1:1, 16:9, 9:16) accepted by all providers
  3. Drop the aspect_ratio parameter entirely to use the provider default

Example fix

// before
"providers": { "image": "openai" }, "aspect_ratio": "21:9"
// after
"providers": { "image": "xai" }, "aspect_ratio": "21:9"
Defensive patterns

Strategy: validation

Validate before calling

const COMMON_RATIOS = new Set(["1:1", "3:2", "2:3", "3:4", "4:3", "9:16", "16:9"]);
function checkRatio(ratio: string | undefined, provider: string): void {
	if (ratio && provider !== "xai" && !COMMON_RATIOS.has(ratio)) {
		throw new Error(`Ratio ${ratio} needs xai provider or a common ratio`);
	}
}

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/790c45129a2ad26e. Report an issue: GitHub.