Support imageConfig for Google Gemini 4K images in AI Gateway REST API

Summary

The AI Gateway REST API (ai-gateway.vercel.sh/v1/chat/completions) doesn’t support imageConfig parameters for Google Gemini image models.

AI SDK already supports this via providerOptions.google.imageConfig (PR #12059), but REST API users cannot access 4K image generation.

Current Behavior

curl -X POST "https://ai-gateway.vercel.sh/v1/chat/completions" \
  -H "Authorization: Bearer $API_KEY" \
  -d '{
    "model": "google/gemini-3-pro-image",
    "messages": [{"role": "user", "content": "A landscape"}],
    "modalities": ["text", "image"],
    "imageConfig": { "aspectRatio": "16:9", "imageSize": "4K" }
  }'

Result: imageConfig ignored, images generated at default 1K resolution.

Expected Behavior

Gateway should passthrough imageConfig to Google API:

  • imageSize: "1K" | "2K" | "4K"
  • aspectRatio: "1:1" | "16:9" | "9:16" etc.

Use Cases

  • 4K images for print/marketing materials
  • Platform-specific aspect ratios (Instagram, YouTube, TikTok)
  • Non-TypeScript environments (Python, Go, curl) need REST API access

Related

Thanks for reporting this feature gap! You’re correct - while the AI SDK supports imageConfig for Google Gemini models (via PR #12059), this isn’t currently available through the AI Gateway REST API.

You could try the following workarounds though:

  1. Use the AI SDK with TypeScript (already supports this)
  2. If using BYOK, make direct calls to Google’s API with imageConfig parameters
    Thanks again! Keep an eye out for updates :slight_smile:

Thanks for pointing to the PR, it helped me understand a bit more. However I’m not sure about the difference between

generateText({
  model: google("gemini-3-pro-image-preview"), // from the test in the PR
  /* … */
});

and

generateText({
  model: "google/gemini-3-pro-image", // what we're using
  /* … */
});

Is it basically the same and for both the structure of the providerOptions should be

providerOptions: {
  google: {
    responseModalities: ['TEXT', 'IMAGE'],
    imageConfig: {
      aspectRatio: '16:9',
      imageSize: '4K',
    },
  },
},

or does it differ, depending on whether I use @ai-sdk/google or not?