Shark AI/Models/

gemini-3.1-flash-image-preview

Image

Model Information

Model IDgoogle/gemini-3.1-flash-image-preview
CategoryImage
Endpoint/api/v1/images/generations
Input Modalitiestext, image
Output Modalitiesimage

Request

POST https://shark.ai/api/v1/images/generations

Authentication: Authorization: Bearer <api-key>

Request Parameters

ParameterTypeRequiredDefaultDescription
modelstringModel ID: google/gemini-3.1-flash-image-preview
nnumber (1..4)1Number of images
seednumber-1Random seed (-1 for random)
imagearray<any>Optional reference image URLs or base64 images for editing
promptstringImage description
image_sizeenum: 1K | 2K | 4K"1K"Image size
aspect_ratioenum: 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_formatenum: 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

HTTPTypeDescription
400invalid_request_errorInvalid parameters
400content_moderationContent blocked by safety system
400input_too_largeInput exceeds model limit
401auth_errorInvalid API key
402insufficient_creditsNot enough credits
429rate_limit_errorToo many requests
502provider_errorUpstream error, retry later
504timeout_errorRequest timed out
Try in PlaygroundAPI ReferenceAll Models