
How to Generate Images Using LLM Gateway and the Vercel AI SDK
Image generation has become a core feature of modern AI applications. But integrating with multiple image providers — each with different APIs, pricing, and capabilities — can be a pain. LLM Gateway simplifies this by giving you a single, OpenAI-compatible API for image generation across providers like Google Gemini, Alibaba Qwen, ByteDance Seedream, and more. In this guide, we'll walk through generating images using both the OpenAI SDK and the Vercel AI SDK . Prerequisites Sign up at llmgateway.io and create a project Copy your API key Export it in your environment: export LLM_GATEWAY_API_KEY = "llmgtwy_XXXXXXXXXXXXXXXX" Option 1: The Images API ( /v1/images/generations ) This is the simplest approach — a drop-in replacement for OpenAI's image generation endpoint. Using curl curl -X POST "https://api.llmgateway.io/v1/images/generations" \ -H "Authorization: Bearer $LLM_GATEWAY_API_KEY " \ -H "Content-Type: application/json" \ -d '{ "model": "gemini-3-pro-image-preview", "prompt": "A c
Continue reading on Dev.to Tutorial
Opens in a new tab



