Approaches
There are two ways to use the Vercel AI SDK with Lumenfall:
The
@lumenfall/ai-sdk community provider is currently in development and will be published to npm soon. In the meantime, use the OpenAI provider - Lumenfall’s API is fully OpenAI-compatible.
Installation
Configuration
Lumenfall’s API is OpenAI-compatible, so you can use the@ai-sdk/openai provider and point it at Lumenfall - no extra dependencies needed.
Use createOpenAI to create a provider that points to Lumenfall:
Generate images
Use thegenerateImage function with your Lumenfall provider:
Generate multiple images
Request multiple images with then parameter:
Edit images
AI SDK 6 supports image editing by passing reference images in a structuredprompt object:
The
@ai-sdk/openai provider does not include response_format in edit requests because OpenAI’s gpt-image models return base64 by default. Lumenfall defaults to URLs (as this makes most sense for users and is the earlier default of the OpenAI API), so you must pass response_format: "b64_json" via providerOptions.openai for the SDK to parse the response correctly. The upcoming @lumenfall/ai-sdk provider will handle this automatically.Passing additional parameters
UseproviderOptions to pass provider-specific parameters that aren’t part of the standard interface:
providerOptions.openai are passed directly to the upstream provider.
Supported provider options depend on the model. Check the model’s documentation for details.
Complete example: Next.js API route
Here’s how to securely use Lumenfall in a Next.js app. The API key stays on the server, and the client calls through a server route.API route
Client component
Next steps
OpenAI SDK
Use the OpenAI SDK directly for more control.
Available Models
See all available image generation models.