An image generation API for developers: Nano Banana and GPT Image on one key
Generate and edit images using Nano Banana and GPT Image on one OpenAI-compatible key with built-in asset storage and exact per-call pricing.
On this page 7 sections
The best image generation API for developers combines multiple leading models behind one OpenAI-compatible endpoint, saves every generated asset to permanent storage, and reports exact per-image costs. thelastapi gives you access to Google's Nano Banana models and OpenAI's GPT Image on a single API key, without separate contracts or fragmented SDKs. You can switch models by id in your existing OpenAI SDK client, inspect costs down to the micro-dollar in every response, and store assets automatically.
Choosing an image generation API in 2026 often forces a compromise. One provider gives you strong prompt comprehension, another offers fast visual generation, and a third handles multi-image edits. Coordinating keys, separate billing balances, and file storage for all of them creates unnecessary engineering overhead. Here is how you can run Nano Banana and GPT Image under one API, how the models compare, and how to implement them in production.
Why route multiple image models through one key?
Different visual tasks demand different architectures. A model optimized for photorealistic rendering may fail when asked to put crisp, legible text on a signboard. Similarly, an expensive generalist model is wasteful if you only need rapid background variations for an e-commerce catalog.
Routing your image generations through a unified gateway solves three practical challenges:
- One client integration. You interact with
POST /v1/ai/images/generationsusing standard OpenAI SDK shapes. Shifting a workflow from Nano Banana to GPT Image requires changing only themodelstring. - Predictable budgeting. Instead of tracking balances across separate dashboards, spend is metered against an account-wide daily limit and per-project caps. Every JSON answer returns
cost_micro_usdso your application can log the exact cost of each picture. - Automatic persistence. Standalone lab APIs return temporary links that expire within hours. Through thelastapi, every image generated inside a project is automatically archived in Files with a permanent link.
If you are evaluating architectures across providers, see how to choose a multi-model API in 2026: a checklist and our guide to one API for image, video and voice AI models.
Comparing the models: Nano Banana vs GPT Image
thelastapi provides stable model aliases mapped to specific lab versions. When you specify a model, exactly that model runs. If the upstream provider experiences downtime, the system returns provider_unavailable or model_unavailable rather than silently rerouting your prompt to an unintended tier.
| thelastapi model | Upstream lab model | Primary strengths | Approximate price (USD) |
|---|---|---|---|
vibiz/image-pro | Nano Banana 2.1 (Google) | Google's newest image model; fast rendering and style consistency | ~$0.034 per image |
vibiz/image-text | GPT-5.4 Image 2 (OpenAI) | Complex reasoning, long prompts, rendering clear text inside images | ~$0.04 per image |
vibiz/image | Nano Banana 2 (Google) | Fast image creation, edits, consistent characters across variations | ~$0.067 per image |
Use vibiz/image-text when your graphic requires written words, diagrams, packaging mockups, or intricate prompt logic. Use vibiz/image-pro or vibiz/image when speed, character consistency, or cost efficiency are the primary goals. For a deeper breakdown of cost trade-offs, read GPT Image vs Nano Banana: cost per image and when to use which.
Beyond the standard aliases, you can also run specialized models by id, including black-forest-labs/flux-schnell and black-forest-labs/flux-dev. You can inspect available media models at any time using the CLI:
vibiz media-modelsHow to generate images with the OpenAI SDK and CLI
You can generate images through terminal commands, direct HTTP calls, or the official OpenAI client library pointed at our base URL.
Generate via the CLI
For local scripting or quick testing, use the vibiz image command:
# Generate using the default image model
vibiz image "a croissant on a marble table" -o hero.png
# Generate using GPT Image
vibiz image "a retro coffee shop sign that reads Morning Roast" --model vibiz/image-text -o sign.pngGenerate via the OpenAI Node.js SDK
To call the AI gateway programmatically, initialize the client using the environment variables provisioned by vibiz dev (VIBIZ_AI_BASE_URL and VIBIZ_AI_API_KEY):
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: process.env.VIBIZ_AI_BASE_URL,
apiKey: process.env.VIBIZ_AI_API_KEY,
});
async function generateCover(prompt: string) {
const response = await openai.images.generate({
model: 'vibiz/image-text',
prompt,
n: 1,
size: '1024x1024',
response_format: 'url',
});
// The returned URL is permanent when called within a project
const image = response.data[0];
console.log('Image URL:', image.url);
console.log('File ID in project storage:', (image as Record<string, unknown>).file_id);
}
generateCover('Studio product photo of a blue ceramic mug on raw slate');The gateway accepts standard dimensions from 256 to 2,048 pixels per side and supports generating up to 4 images per request.
How to edit existing photos and combine inputs
Both Nano Banana and GPT Image support image-to-image editing. Rather than passing base64 strings across services, you supply public URLs in image_url or image_urls.
You can modify an existing image using the CLI:
vibiz image "make the background a sunny beach" -o out.png --from-image https://thelastapi.dev/f/Qm9x.../portrait.pngUsing the API, you can pass up to 8 source images in image_urls. This allows you to combine disparate visual assets, such as matching a specific person's face with a new outfit or placing a product photo inside a newly described environment:
import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: process.env.VIBIZ_AI_BASE_URL,
apiKey: process.env.VIBIZ_AI_API_KEY,
});
async function editProductImage() {
const response = await openai.images.generate({
model: 'vibiz/image',
prompt: 'Place the product from image 1 onto the wooden coffee table from image 2',
response_format: 'url',
image_urls: [
'https://thelastapi.dev/f/Qm9x.../product.png',
'https://thelastapi.dev/f/Qm9x.../table.png',
],
} as never);
console.log('Generated result:', response.data[0].url);
}If you send image_url or image_urls to a model that only supports generation from scratch, the API returns HTTP 400 with details.reason: "model_takes_no_photo" rather than silently ignoring your input. To learn more about configuring authentication for Google's models, review how to use Nano Banana with an API key.
Automatic permanent asset hosting in Files
When using standalone lab APIs, image responses provide temporary download links that expire within 60 to 120 minutes. Production applications must download the binary payload, transfer it to an object store, and set public permissions.
thelastapi automates this pipeline. Every image generated within a project is written directly to the project's Files storage.
Key attributes of generated assets:
- Permanent URLs. The
urlfield returned inPOST /v1/ai/images/generationspoints tohttps://thelastapi.dev/f/<key>/<name>, where<key>is a secure 32-character random string. These links do not expire. - Traceable metadata. Each file record captures its width, height, mime type, generating model, prompt text, and
cost_usd. - Environment separation. Calls using development keys save assets to development storage; production keys write to production storage.
- Searchable archive. You can locate previously generated images using the CLI without maintaining an auxiliary database table:
# Retrieve the link of the most recent image
vibiz files latest --type image
# Search generated files by words in their prompt
vibiz files search "marble table"Calls authenticated with an account key that lack a project context return links valid for 24 hours without writing to project Files.
Setting budgets and bringing your own key
Uncontrolled image generation can quickly consume resources. thelastapi provides governance mechanisms directly at the gateway layer:
- Daily spend limits. Accounts default to a $5 daily ceiling across AI calls and actions. Owners can adjust this limit in billing settings.
- Project-level budgets. Projects default to a $1 daily AI budget. When reached, subsequent calls fail immediately with HTTP 429 and
details.reason: "project_budget"instead of accumulating unexpected debt. - Automated threshold alerts. Project owners receive email notifications and console alerts when consumption hits 80% and 100% of defined daily limits.
If you have existing Google AI Studio credits, you can connect your Gemini key to run Google models at zero platform markup:
GEMINI_API_KEY=your_key_here vibiz ai keys set googleWhen configured, requests for vibiz/image, vibiz/image-pro, and any google/... model run against your Google account and cost $0 on thelastapi. The response payload confirms this with "paid_by": "your_key". Requests for OpenAI models like vibiz/image-text continue running on thelastapi's metered rails as usual.
To start generating images with Nano Banana and GPT Image on a single key, create your account at thelastapi.dev/start or explore our setup guides in the AI docs.
Frequently asked questions
Can I use the official OpenAI client SDK with Nano Banana?
Yes. Set the client's baseURL to your project's VIBIZ_AI_BASE_URL and pass your VIBIZ_AI_API_KEY as the apiKey, then specify model as vibiz/image or vibiz/image-pro.
Do image URLs returned by the API expire?
If the generation runs within a project, the image is automatically saved to Files and the returned URL is permanent. Calls made under an account key without a project return URLs that expire after 24 hours.
How does the API bill when I use my own Google API key?
When you configure your own Gemini key, calls to Google models like vibiz/image and vibiz/image-pro are billed directly to your Google account and cost 0 on thelastapi. Calls to non-Google models like vibiz/image-text continue to be billed through your thelastapi balance.
What happens if an image model is down?
The gateway returns HTTP 503 with model_unavailable or provider_unavailable along with retry guidance. It never secretly substitutes a different model for the one you requested.