Try image generation (Vertex AI Studio)
This page describes how you can set an optional Imagen on Vertex AI parameter to specify the prompt language that you use. If you don't specify a language, then Imagen automatically detects the language.
![]() 1 A pile of books seen from above. The topmost book contains a watercolor illustration of a bird. VERTEX AI is written in bold letters on the book. |
![]() 2 Woman wearing bright colors, in the style of dark yellow and dark cyan, wearing earrings, postmodern fashion photography. |
Set text prompt language
The following input values are supported for the text-prompt lanague:
- Chinese (simplified) (
zh
/zh-CN
) - Chinese (traditional) (
zh-TW
) - English (
en
, default value) - French (
fr
) - German (
de
) - Hindi (
hi
) - Japanese (
ja
) - Korean (
ko
) - Portuguese (
pt
) Spanish (
es
)
Console
If your prompt is in one of the supported languages, Imagen detects and translates your text and returns your generated or edited images.
If your prompt is in an unsupported language, Imagen uses the text verbatim for the request. This might result in unexpected output.
REST
Before using any of the request data, make the following replacements:
- PROJECT_ID: Your Google Cloud project ID.
- TEXT_PROMPT: The text prompt that guides what images the model generates. This field is required for both generation and editing.
- PROMPT_LANGUAGE: string. Optional. The language code that corresponds to your text
prompt language.
In this example it would be
hi
. Available values:auto
- Automatic detection. If Imagen detects a supported language, the prompt (and optionally, a negative prompt), are translated to English. If the language detected is not supported, Imagen uses the input text verbatim, which might result in unexpected output. No error code is returned.en
- English (default value if omitted)es
- Spanishhi
- Hindija
- Japaneseko
- Koreanpt
- Portuguesezh-TW
- Chinese (traditional)zh
orzh-CN
- Chinese (simplified)
HTTP method and URL:
POST https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/imagegeneration@005:predict
Request JSON body:
{ "instances": [ { "prompt": "सूर्यास्त के समय एक समुद्र तट। उड़ते पक्षी, हवा में लहराते नारियल के पेड़। लोग समुद्र तट पर सैर का आनंद ले रहे हैं।" } ], "parameters": { "language": "PROMPT_LANGUAGE" } }
To send your request, choose one of these options:
curl
Save the request body in a file named request.json
,
and execute the following command:
curl -X POST \
-H "Authorization: Bearer $(gcloud auth print-access-token)" \
-H "Content-Type: application/json; charset=utf-8" \
-d @request.json \
"https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/imagegeneration@005:predict"
PowerShell
Save the request body in a file named request.json
,
and execute the following command:
$cred = gcloud auth print-access-token
$headers = @{ "Authorization" = "Bearer $cred" }
Invoke-WebRequest `
-Method POST `
-Headers $headers `
-ContentType: "application/json; charset=utf-8" `
-InFile request.json `
-Uri "https://us-central1-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/us-central1/publishers/google/models/imagegeneration@005:predict" | Select-Object -Expand Content
"sampleCount": 2
. The response returns two prediction objects, with
the generated image bytes base64-encoded.
{ "predictions": [ { "bytesBase64Encoded": "BASE64_IMG_BYTES", "mimeType": "image/png" }, { "mimeType": "image/png", "bytesBase64Encoded": "BASE64_IMG_BYTES" } ] }
What's next
- Use prompt rewriter
- Configure aspect ratio
- Omit content using a negative prompt
- Generate deterministic images