Image Generation
ShuYou supports invoking image generation models via the Vertex AI protocol. This guide explains how to use ShuYou to generate images and save them locally.Supported Models
The currently supported image generation models include (continuously updated):gemini-3.1-flash-image-preview(Nano Banana 2)gemini-3-pro-image-preview(Nano Banana Pro)gemini-2.5-flash-image(Nano Banana)
API reference
Image generation APIs with interactive playgrounds:- GPT Image 2 —
POST /v1/predictions - Gemini 3.1 Flash Image Preview (Nano Banana 2) —
POST /v1/predictions - Gemini 3 Pro Image Preview (Nano Banana Pro) —
POST /v1/predictions - Gemini 2.5 Flash Image (Nano Banana) —
POST /v1/predictions
Reference Documentation
This guide only covers basic usage. For detailed configuration and advanced usage, refer to the official documentation below:Usage
Python
TypeScript
Configuration
Required Parameters
- api_key: Your ShuYou API key
- vertexai: Must be set to
trueto enable the Vertex AI protocol - base_url: ShuYou Vertex AI endpoint
https://api.shuyou.ai - responseModalities: Response modalities; image generation must include
["TEXT", "IMAGE"]
Invocation Modes
ShuYou supports two invocation modes:- Streaming (
generate_content_stream/generateContentStream): Ideal for scenarios requiring real-time feedback - Non-streaming (
generate_content/generateContent): Returns the complete response at once after processing
Best Practices
- Prompt Engineering: Use clear and specific descriptions to achieve better generation quality.
- Error Handling: Add exception handling to manage potential API call failures.
- Image Saving: The Python SDK provides a convenient
as_image()method to convert a response part into a PIL Image object. - Model Selection: Choose the appropriate model based on your needs; free models are suitable for testing, while paid models provide higher quality.