Model Information
| Model ID | google/gemini-3.1-flash-image-preview |
| Category | Image |
| Endpoint | /api/v1/images/generations |
| Input Modalities | text, image |
| Output Modalities | image |
Request
POST https://shark.ai/api/v1/images/generationsAuthentication: Authorization: Bearer <api-key>
Request Parameters
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| model | string | ✓ | Model ID: google/gemini-3.1-flash-image-preview | |
| n | number (1..4) | 1 | Number of images | |
| seed | number | -1 | Random seed (-1 for random) | |
| image | array<any> | Optional reference image URLs or base64 images for editing | ||
| prompt | string | ✓ | Image description | |
| image_size | enum: 1K | 2K | 4K | "1K" | Image size | |
| aspect_ratio | enum: 1:1 | 2:3 | 3:2 | 3:4 | 4:3 | 4:5 | 5:4 | 9:16 | 16:9 | 21:9 | "1:1" | Aspect ratio | |
| response_format | enum: b64_json | url | "b64_json" | Response format |
Multimodal Input
This model supports image input. Use the content array format:
{
"role": "user",
"content": [
{
"type": "text",
"text": "Describe this"
},
{
"type": "image_url",
"image_url": {
"url": "https://example.com/photo.jpg"
}
}
]
}Multimodal Output
This model can output image. Add modalities to your request:
{
"model": "google/gemini-3.1-flash-image-preview",
"messages": [
{
"role": "user",
"content": "Draw a cat"
}
],
"modalities": [
"image"
]
}Image output does not support streaming. Set stream: false.
Code Examples
curl -X POST https://shark.ai/api/v1/images/generations \
-H "Authorization: Bearer <api-key>" \
-H "Content-Type: application/json" \
-d '{
"model": "google/gemini-3.1-flash-image-preview",
"n": 1,
"seed": -1,
"prompt": "Your prompt here",
"image_size": "1K",
"aspect_ratio": "1:1",
"response_format": "b64_json"
}'Response
Response (200 OK)
{
"created": 1700000000,
"data": [
{
"url": "https://cos.example.com/images/...signed..."
}
],
"usage": {
"input_tokens": 14,
"output_tokens": 1542,
"total_tokens": 1556
},
"credit": 90
}Error Codes
| HTTP | Type | Description |
|---|---|---|
| 400 | invalid_request_error | Invalid parameters |
| 400 | content_moderation | Content blocked by safety system |
| 400 | input_too_large | Input exceeds model limit |
| 401 | auth_error | Invalid API key |
| 402 | insufficient_credits | Not enough credits |
| 429 | rate_limit_error | Too many requests |
| 502 | provider_error | Upstream error, retry later |
| 504 | timeout_error | Request timed out |