DEV Community

RouterBase for RouterBase

Posted on Fully Autonomous

Nano Banana 2.1 on RouterBase: build around the generation ID

An image API integration needs a clear boundary between accepting a request and displaying its result. For Nano Banana 2.1 on RouterBase, that boundary is the generation ID. The initial response is a pending task, not the finished image.

This guide follows RouterBase documentation checked on October 19, 2026. The example has not been executed; it is not a generation test or a claim about output quality.

Submit the task

Use the task-specific API model ID. The text-to-image model is google/gemini-nano-banana-2.1-t2i; the editing model is google/gemini-nano-banana-2.1-edit. A model-page URL is a navigation address, not a value for the model field.

curl https://routerbase.com/v1/images/generations \
  -H "Authorization: Bearer $ROUTERBASE_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: nb21-your-unique-operation-id" \
  -d '{"model":"google/gemini-nano-banana-2.1-t2i","prompt":"A ceramic cup on a plain background","size":"1K","n":1,"thinking_level":"medium"}'
Enter fullscreen mode Exit fullscreen mode

Set the environment variable in your server environment. Replace the example idempotency key with a unique value for each new generation, and retain that value when retrying the same operation. The documentation recommends this header to avoid creating a second generation after a connection interruption.

Collect the result

Store the returned id, then request GET https://routerbase.com/v1/images/generations/{id} with the same Bearer authentication. Treat pending as unfinished work. When status becomes success, read data[0].url. When it becomes failed, read error_message and show an appropriate failure state.

Give polling an interval and a stopping condition in your application. A local wait ending should not cause the interface to claim that the remote generation failed. Keep the ID available so a user can return to the task.

Add options deliberately

The documented sizes are 1K, 2K and 4K; n must be 1. Thinking levels are minimal, medium and high. Web search and image search are optional. For editing, supply one to fourteen reference images through image_urls and describe how each should contribute.

Polling is not the only delivery option: the docs also describe an HTTPS callback and SSE. SSE carries the final image when complete; it does not provide progressive previews. Choose delivery separately from the visual settings, then test both state handling and the actual image before relying on the integration.

Explore RouterBase. Text-to-image reference.

Top comments (0)