Model Details
Nano Banana 2 is a highly efficient and versatile text-to-image model, optimized for a balance of speed, quality, and cost. It is an excellent choice for a wide variety of creative and commercial applications, from generating marketing assets to creating photorealistic scenes and artistic illustrations from simple text prompts.
The model's deep language understanding allows it to interpret detailed, narrative descriptions to produce coherent and high-quality images. Key capabilities include:
- **Photorealism and Artistic Versatility:** Create stunning, realistic product mockups, professional-looking photographs, and explore a vast range of artistic styles by describing camera angles, lighting, and composition. - **Accurate Text Rendering:** Generate logos, infographics, and other designs that require legible and stylized text directly within the image. - **Real-Time Generation with Google Search:** By enabling the `google_search` option, the model can access real-time information to create timely and relevant images, such as a chart of current weather conditions or a graphic of a recent sporting event.
For best results, write descriptive, narrative prompts rather than just listing keywords. Explain the context and intent of the image, and don't hesitate to iterate with follow-up prompts to refine the output.
### Example Usage ```javascript import { modelrunner } from "@modelrunner/client";
const result = await modelrunner.subscribe("google/nano-banana-2", { input: { prompt: "Create a modern, minimalist logo for a coffee shop called 'The Daily Grind' in a clean, bold, sans-serif font. The color scheme is black and white.", aspect_ratio: "1:1", resolution: "2K", google_search: false }, }); ```
## Safety & Content Moderation The `safety_settings` parameter allows you to adjust the content moderation filters for your requests. You can configure a blocking threshold for four different categories of potentially harmful content. This provides more granular control for specific use cases, such as allowing more "dangerous" content when generating dialogue or scenes for a video game. This setting can only be configured via the API.
The available `category` options are: - `HARM_CATEGORY_HARASSMENT` - `HARM_CATEGORY_HATE_SPEECH` - `HARM_CATEGORY_SEXUALLY_EXPLICIT` - `HARM_CATEGORY_DANGEROUS_CONTENT`
The `threshold` determines the probability level at which content is blocked: - `BLOCK_NONE`: Always show content, regardless of safety probability. - `BLOCK_ONLY_HIGH`: Block content with a high probability of being unsafe. - `BLOCK_MEDIUM_AND_ABOVE`: Block content with a medium or high probability of being unsafe. - `BLOCK_LOW_AND_ABOVE`: Block content with a low, medium, or high probability of being unsafe. - `OFF`: Turn off the safety filter.
```javascript const result = await modelrunner.subscribe("google/nano-banana-2", { input: { prompt: "A gritty, noir art style comic panel of a detective in the rain.", safety_settings: [ { category: "HARM_CATEGORY_DANGEROUS_CONTENT", threshold: "BLOCK_MEDIUM_AND_ABOVE" }, { category: "HARM_CATEGORY_HATE_SPEECH", threshold: "BLOCK_LOW_AND_ABOVE" } ] }, }); ```
