Mulai 29 April 2025, model Gemini 1.5 Pro dan Gemini 1.5 Flash tidak tersedia di project yang belum pernah menggunakan model ini, termasuk project baru. Untuk mengetahui detailnya, lihat Versi dan siklus proses model.
Imagen di Vertex AI menawarkan alat penulisan ulang perintah berbasis LLM, yang juga dikenal sebagai
penulis ulang perintah. Penulis ulang perintah membantu Anda mendapatkan gambar output berkualitas lebih tinggi dengan menambahkan lebih banyak detail ke perintah Anda.
Jika Anda menonaktifkan penulis ulang perintah, kualitas gambar dan seberapa baik output menyerupai perintah yang Anda berikan dapat terpengaruh. Fitur ini diaktifkan secara default untuk versi model berikut:
imagen-4.0-generate-001
imagen-4.0-fast-generate-001
imagen-4.0-ultra-generate-001
imagen-3.0-generate-002
Perintah yang ditulis ulang hanya dikirimkan oleh respons API jika perintah asli memiliki panjang kurang dari 30 kata.
Menggunakan penulis ulang perintah
Untuk menggunakan penulis ulang perintah, lakukan tindakan berikut:
Konsol
Di konsol Google Cloud , buka halaman Vertex AI > Media
Studio.
Klik Imagen. Halaman pembuatan gambar Imagen Media Studio akan ditampilkan.
Di panel Setelan, sesuaikan opsi berikut:
Model: Pilih model dari opsi yang tersedia.
Untuk mengetahui informasi selengkapnya tentang model yang tersedia, lihat Model Imagen
Jumlah hasil: Sesuaikan penggeser atau masukkan nilai antara
1 dan 4.
Di kotak Negative prompt, masukkan perintah yang menjelaskan hal yang tidak ingin Anda hasilkan dalam gambar.
Di kotak Tulis perintah Anda, klik Bantu tulis.
Jendela Tingkatkan kualitas perintah saya akan ditampilkan.
Di kotak Perintah saat ini, tulis perintah Anda, lalu klik
Tingkatkan.
Perintah yang ditulis ulang ditampilkan di kotak Perintah yang ditingkatkan. Anda
dapat mengedit perintah yang ditingkatkan atau menggunakannya seperti yang ditampilkan.
Klik Sisipkan untuk menggunakan perintah yang ditampilkan.
Perintah dimasukkan ke dalam kotak Tulis perintah Anda.
Klik sendBuat.
REST
Sebelum menggunakan salah satu data permintaan,
lakukan penggantian berikut:
MODEL_VERSION: Versi model pembuatan gambar yang akan digunakan.
Untuk mengetahui informasi selengkapnya tentang versi dan fitur model, lihat versi model.
LOCATION: Region project Anda. Misalnya,
us-central1, europe-west2, atau asia-northeast3. Untuk mengetahui daftar
region yang tersedia, lihat
Lokasi AI Generatif di Vertex AI.
TEXT_PROMPT: Perintah teks yang memandu gambar yang dihasilkan
model. Sebelum gambar dibuat, perintah dasar ini ditingkatkan dengan
lebih banyak detail dan bahasa deskriptif menggunakan alat penulisan ulang perintah berbasis LLM.
IMAGE_COUNT: Bilangan bulat, yang menjelaskan jumlah gambar yang akan dibuat. Nilai yang diterima adalah 1-4. Nilai
defaultnya adalah 4.
PROMPT_SETTING: Nilai boolean, true mengaktifkan
perintah yang ditingkatkan dan false menonaktifkan perintah yang ditingkatkan. Nilai defaultnya adalah true.
Metode HTTP dan URL:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_VERSION:predict
Dengan pengoptimalan perintah diaktifkan, respons akan menyertakan kolom
prompt tambahan yang menampilkan perintah yang dioptimalkan dan gambar yang dihasilkan
terkait:
Misalnya, contoh respons berikut adalah untuk permintaan dengan
"sampleCount": 2 dan "prompt": "A raccoon wearing formal
clothes, wearing a top hat. Oil painting in the style of Vincent Van
Gogh.". Respons ini menampilkan dua objek prediksi, masing-masing dengan perintah yang ditingkatkan dan byte gambar yang dihasilkan berenkode base64.
{
"predictions": [
{
"mimeType": "image/png",
"prompt": "An oil painting in the style of Vincent van Gogh,
depicting a raccoon adorned in a finely tailored tuxedo, complete with a
crisp white shirt and a bow tie. The raccoon also sports a classic top
hat, perched jauntily on its head. The painting uses thick, swirling
brushstrokes characteristic of van Gogh, with vibrant hues of blue,
yellow, and green in the background, contrasting with the dark tones of
the raccoon's attire. The light source is subtly placed, casting a
dramatic shadow of the raccoon's attire onto the surface it sits upon,
further enhancing the depth and dimensionality of the composition. The
overall impression is one of a whimsical and sophisticated character, a
raccoon elevated to a higher class through its formal attire, rendered
in van Gogh's iconic style.",
"bytesBase64Encoded": "BASE64_IMG_BYTES"
},
{
"mimeType": "image/png",
"prompt": "An oil painting in the style of Vincent van Gogh featuring
a raccoon in a dapper suit, complete with a black jacket, crisp white
shirt, and a black bow tie. The raccoon is wearing a black top hat,
adding a touch of elegance to its ensemble. The painting is rendered
with characteristic van Gogh brushwork, utilizing thick, impasto strokes
of color. The background is a swirl of blues, greens, and yellows,
creating a vibrant yet slightly chaotic atmosphere that contrasts with
the raccoon's formal attire. The lighting is dramatic, casting sharp
shadows and highlighting the textures of the fabric and the raccoon's
fur, enhancing the sense of realism within the fantastical scene. The
composition focuses on the raccoon's proud posture, highlighting the
whimsical contrast of a wild animal dressed in formal attire, captured
in the unique artistic language of van Gogh. ",
"bytesBase64Encoded": "BASE64_IMG_BYTES"
}
]
}
[[["Mudah dipahami","easyToUnderstand","thumb-up"],["Memecahkan masalah saya","solvedMyProblem","thumb-up"],["Lainnya","otherUp","thumb-up"]],[["Sulit dipahami","hardToUnderstand","thumb-down"],["Informasi atau kode contoh salah","incorrectInformationOrSampleCode","thumb-down"],["Informasi/contoh yang saya butuhkan tidak ada","missingTheInformationSamplesINeed","thumb-down"],["Masalah terjemahan","translationIssue","thumb-down"],["Lainnya","otherDown","thumb-down"]],["Terakhir diperbarui pada 2025-09-04 UTC."],[],[],null,["# Use prompt rewriter\n\n| **Caution:** Starting on June 24, 2025, Imagen versions 1 and 2 are deprecated. Imagen models `imagegeneration@002`, `imagegeneration@005`, and `imagegeneration@006` will be removed on September 24, 2025 . For more information about migrating to Imagen 3, see [Migrate to\n| Imagen 3](/vertex-ai/generative-ai/docs/image/migrate-to-imagen-3).\n\n\u003cbr /\u003e\n\n\n[Try image generation (Vertex AI Studio)](https://console.cloud.google.com/vertex-ai/studio/media/generate;tab=image)\n\n[Try Imagen in a Colab](https://colab.research.google.com/github/GoogleCloudPlatform/generative-ai/blob/main/vision/getting-started/imagen4_image_generation.ipynb)\n\nImagen on Vertex AI offers an LLM-based prompt rewriting tool, also known as a\nprompt rewriter. The prompt rewriter helps you obtain higher quality output\nimages by adding more detail to your prompt.\n\nIf you disable the prompt rewriter, the quality of the images and how well the\noutput resembles the prompt that you supplied may be impacted. This feature is\nenabled by default for the following model versions:\n\n- `imagen-4.0-generate-001`\n- `imagen-4.0-fast-generate-001`\n- `imagen-4.0-ultra-generate-001`\n- `imagen-3.0-generate-002`\n\nThe rewritten prompt is delivered by API response only if the original prompt\nis fewer than 30 words long.\n| **Important:** `imagen-4.0-fast-generate-001` may generate undesireable results if the prompt is complex and you use enhanced prompts. To fix this, avoid using **Help me write** in Google Cloud console, or set `enhancePrompt` to `false`.\n\nUse the prompt rewriter\n-----------------------\n\nTo use the prompt rewriter, do the following: \n\n### Console\n\n1. In the Google Cloud console, go to the **Vertex AI \\\u003e Media\n Studio** page.\n\n [Go to Media\n Studio](https://console.cloud.google.com/vertex-ai/studio/media/generate;tab=image)\n2. Click **Imagen**. The Imagen Media Studio image generation page is\n displayed.\n\n3. In the **Settings** panel, adjust the following options:\n\n - **Model**: Choose a model from the available options.\n\n For more information about available models, see [Imagen\n models](/vertex-ai/generative-ai/docs/models#imagen-models)\n - **Number of results** : Adjust the slider or enter a value between\n **1** and **4**.\n\n - In the **Negative prompt** box, enter a prompt that describes what\n you don't want generated in the image.\n\n4. In the **Write your prompt** box, click **Help me write**.\n\n The **Enhance my prompt** window is displayed.\n5. In the **Current prompt** box, write your prompt, and then click\n **Enhance**.\n\n The rewritten prompt is displayed in the **Enhanced prompt** box. You\n can edit the enhanced prompt or use it as displayed.\n6. Click **Insert** to use the displayed prompt.\n\n The prompt is inserted into the **Write your prompt** box.\n7. Click send **Generate**.\n\n### REST\n\n\nBefore using any of the request data,\nmake the following replacements:\n\n- \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e: Your Google Cloud [project ID](/resource-manager/docs/creating-managing-projects#identifiers).\n- \u003cvar translate=\"no\"\u003eMODEL_VERSION\u003c/var\u003e: The image generation model version to use.\n\n For more information about model versions and features, see [model versions](#model-versions).\n- \u003cvar translate=\"no\"\u003eLOCATION\u003c/var\u003e: Your project's region. For example, `us-central1`, `europe-west2`, or `asia-northeast3`. For a list of available regions, see [Generative AI on Vertex AI locations](/vertex-ai/generative-ai/docs/learn/locations-genai).\n- \u003cvar translate=\"no\"\u003eTEXT_PROMPT\u003c/var\u003e: The text prompt that guides what images the model generates. Before images are generated, this base prompt is enhanced with more detail and descripitive language using the LLM-based prompt rewriting tool.\n- \u003cvar translate=\"no\"\u003eIMAGE_COUNT\u003c/var\u003e: An integer, describing the number of images to generate. The accepted values are `1`-`4`. The default value is `4`.\n- \u003cvar translate=\"no\"\u003ePROMPT_SETTING\u003c/var\u003e: A boolean value, `true` enables enhanced prompts and `false` disables enhanced prompts. The default value is `true`.\n\n\nHTTP method and URL:\n\n```\nPOST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_VERSION:predict\n```\n\n\nRequest JSON body:\n\n```\n{\n \"instances\": [\n {\n \"prompt\": \"TEXT_PROMPT\"\n }\n ],\n \"parameters\": {\n \"sampleCount\": IMAGE_COUNT,\n \"enhancePrompt\": \u003cvar translate=\"no\"\u003ePROMPT_SETTING\u003c/var\u003e\n }\n}\n```\n\nTo send your request, choose one of these options: \n\n#### curl\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) , or by using [Cloud Shell](/shell/docs), which automatically logs you into the `gcloud` CLI . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\ncurl -X POST \\\n -H \"Authorization: Bearer $(gcloud auth print-access-token)\" \\\n -H \"Content-Type: application/json; charset=utf-8\" \\\n -d @request.json \\\n \"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_VERSION:predict\"\n```\n\n#### PowerShell\n\n| **Note:** The following command assumes that you have logged in to the `gcloud` CLI with your user account by running [`gcloud init`](/sdk/gcloud/reference/init) or [`gcloud auth login`](/sdk/gcloud/reference/auth/login) . You can check the currently active account by running [`gcloud auth list`](/sdk/gcloud/reference/auth/list).\n\n\nSave the request body in a file named `request.json`,\nand execute the following command:\n\n```\n$cred = gcloud auth print-access-token\n$headers = @{ \"Authorization\" = \"Bearer $cred\" }\n\nInvoke-WebRequest `\n -Method POST `\n -Headers $headers `\n -ContentType: \"application/json; charset=utf-8\" `\n -InFile request.json `\n -Uri \"https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_VERSION:predict\" | Select-Object -Expand Content\n```\nWith prompt enhancement enabled, the response includes an additional `prompt` field that shows the enhanced prompt and its associated generated image: \n\n```json\n {\n \"predictions\": [\n {\n \"mimeType\": \"\u003cvar translate=\"no\"\u003eMIME_TYPE\u003c/var\u003e\",\n \"prompt\": \"\u003cvar translate=\"no\"\u003eENHANCED_PROMPT_1\u003c/var\u003e\",\n \"bytesBase64Encoded\": \"\u003cvar translate=\"no\"\u003eBASE64_IMG_BYTES_1\u003c/var\u003e\"\n },\n {\n \"mimeType\": \"\u003cvar translate=\"no\"\u003eMIME_TYPE\u003c/var\u003e\",\n \"prompt\": \"\u003cvar translate=\"no\"\u003eENHANCED_PROMPT_2\u003c/var\u003e\",\n \"bytesBase64Encoded\": \"\u003cvar translate=\"no\"\u003eBASE64_IMG_BYTES_2\u003c/var\u003e\"\n }\n ]\n }\n```\n\n\nFor example, the following sample response is for a request with\n`\"sampleCount\": 2` and `\"prompt\": \"A raccoon wearing formal\nclothes, wearing a top hat. Oil painting in the style of Vincent Van\nGogh.\"`. The response returns two prediction objects, each with their\nenhanced prompt and the generated image bytes base64-encoded.\n\n```\n{\n \"predictions\": [\n {\n \"mimeType\": \"image/png\",\n \"prompt\": \"\u003cvar translate=\"no\"\u003eAn oil painting in the style of Vincent van Gogh,\n depicting a raccoon adorned in a finely tailored tuxedo, complete with a\n crisp white shirt and a bow tie. The raccoon also sports a classic top\n hat, perched jauntily on its head. The painting uses thick, swirling\n brushstrokes characteristic of van Gogh, with vibrant hues of blue,\n yellow, and green in the background, contrasting with the dark tones of\n the raccoon's attire. The light source is subtly placed, casting a\n dramatic shadow of the raccoon's attire onto the surface it sits upon,\n further enhancing the depth and dimensionality of the composition. The\n overall impression is one of a whimsical and sophisticated character, a\n raccoon elevated to a higher class through its formal attire, rendered\n in van Gogh's iconic style.\u003c/var\u003e\",\n \"bytesBase64Encoded\": \"BASE64_IMG_BYTES\"\n },\n {\n \"mimeType\": \"image/png\",\n \"prompt\": \"\u003cvar translate=\"no\"\u003eAn oil painting in the style of Vincent van Gogh featuring\n a raccoon in a dapper suit, complete with a black jacket, crisp white\n shirt, and a black bow tie. The raccoon is wearing a black top hat,\n adding a touch of elegance to its ensemble. The painting is rendered\n with characteristic van Gogh brushwork, utilizing thick, impasto strokes\n of color. The background is a swirl of blues, greens, and yellows,\n creating a vibrant yet slightly chaotic atmosphere that contrasts with\n the raccoon's formal attire. The lighting is dramatic, casting sharp\n shadows and highlighting the textures of the fabric and the raccoon's\n fur, enhancing the sense of realism within the fantastical scene. The\n composition focuses on the raccoon's proud posture, highlighting the\n whimsical contrast of a wild animal dressed in formal attire, captured\n in the unique artistic language of van Gogh. \u003c/var\u003e\",\n \"bytesBase64Encoded\": \"BASE64_IMG_BYTES\"\n }\n ]\n}\n```\n\n\u003cbr /\u003e\n\nWhat's next\n-----------\n\n- [Set text prompt language](/vertex-ai/generative-ai/docs/image/set-text-prompt-language)\n- [Configure aspect ratio](/vertex-ai/generative-ai/docs/image/configure-aspect-ratio)\n- [Omit content using a negative prompt](/vertex-ai/generative-ai/docs/image/omit-content-using-a-negative-prompt)\n- [Generate deterministic images](/vertex-ai/generative-ai/docs/image/generate-deterministic-images)"]]