Home / Companies / OpenRouter / Blog / Post Details
Content Deep Dive

Nano Banana API: Edit Images with Gemini in Code

Blog post from OpenRouter

Post Details
Company
Date Published
Author
OpenRouter
Word Count
2,285
Company Posts That Month
24
Language
English
Hacker News Points
-
Post removed?
No
Summary

The guide explains how to edit existing images through OpenRouter’s API using Google’s Gemini “Nano Banana” image models, particularly the default google/gemini-3.1-flash-image model, by submitting a source image in input_references alongside a text editing instruction in prompt. It provides Python, TypeScript, and SDK-based examples for encoding local images as base64 data URLs, using public image URLs, decoding the base64-edited result returned in data[0].b64_json, and saving it to disk. It distinguishes image editing from text-to-image generation, recommends prompts that explicitly state both the desired change and elements to preserve, and advises performing complex work through small sequential edits by reusing each result as the next source image. The guide also compares available Nano Banana variants by speed, cost, and quality, notes that compatible alternatives such as OpenAI image models can be selected by changing the model field, and outlines practical concerns including supported formats, URL accessibility, oversized files, response errors, rate limits, retries, cost logging, and protecting API keys through environment variables.

Trends Found in this Post

No tracked trend matches for this post yet.

Use This Data

Use this post, company, and trend context to find content marketing opportunities, perform competitive analysis, or address product feature gaps via the Plushcap MCP server or the Plushcap API.