Imagen in Vertex AI bietet ein LLM-basiertes Tool zum Umschreiben von Prompts, auch als Prompt-Rewriter bezeichnet. Mit dem Prompt-Rewriter können Sie die Qualität der generierten Bilder verbessern, indem Sie Ihrem Prompt mehr Details hinzufügen.
Wenn Sie die Funktion zum Umschreiben von Prompts deaktivieren, kann sich das auf die Qualität der Bilder und darauf auswirken, wie gut die Ausgabe dem von Ihnen angegebenen Prompt entspricht. Diese Funktion ist standardmäßig für die folgenden Modellversionen aktiviert:
imagen-4.0-generate-001
imagen-4.0-fast-generate-001
imagen-4.0-ultra-generate-001
imagen-3.0-generate-002
Der umformulierte Prompt wird nur dann in der API-Antwort zurückgegeben, wenn der ursprüngliche Prompt weniger als 30 Wörter umfasst.
Prompt-Rewriter verwenden
So verwenden Sie die Funktion zum Umschreiben von Prompts:
Konsole
Rufen Sie in der Google Cloud Console die Seite Vertex AI > Media Studio auf.
Klicken Sie auf Imagen. Die Seite zur Bildgenerierung von Imagen Media Studio wird angezeigt.
Passen Sie im Bereich Einstellungen die folgenden Optionen an:
Modell: Wählen Sie ein Modell aus den verfügbaren Optionen aus.
Weitere Informationen zu den verfügbaren Modellen finden Sie unter Imagen-Modelle.
Anzahl der Ergebnisse: Stellen Sie den Schieberegler ein oder geben Sie einen Wert zwischen 1 und 4 ein.
Geben Sie im Feld Negativer Prompt einen Prompt ein, der beschreibt, was nicht im Bild generiert werden soll.
Klicken Sie im Feld Prompt eingeben auf Formuliere für mich.
Das Fenster Prompt optimieren wird angezeigt.
Geben Sie im Feld Aktueller Prompt Ihren Prompt ein und klicken Sie dann auf Optimieren.
Der neu formulierte Prompt wird im Feld Optimierter Prompt angezeigt. Sie können den optimierten Prompt bearbeiten oder ihn so verwenden, wie er angezeigt wird.
Klicken Sie auf Einfügen, um den angezeigten Prompt zu verwenden.
Der Prompt wird in das Feld Geben Sie Ihren Prompt ein eingefügt.
Klicken Sie auf sendErstellen.
REST
Ersetzen Sie diese Werte in den folgenden Anfragedaten:
MODEL_VERSION: Die zu verwendende Modellversion für die Bildgenerierung.
Weitere Informationen zu Modellversionen und -funktionen finden Sie unter Modellversionen.
LOCATION: Die Region Ihres Projekts. Beispiel: us-central1, europe-west2 oder asia-northeast3. Eine Liste der verfügbaren Regionen finden Sie unter Generative AI an Vertex AI-Standorten.
TEXT_PROMPT: Der Text-Prompt, der bestimmt, welche Bilder das Modell generiert. Bevor Bilder generiert werden, wird dieser Basis-Prompt mit dem LLM-basierten Tool zum Neuschreiben von Prompts mit weiteren Details und beschreibenderen Formulierungen optimiert.
IMAGE_COUNT: Eine Ganzzahl, die die Anzahl der zu generierenden Bilder angibt. Die zulässigen Werte sind 1–4. Der Standardwert ist 4.
PROMPT_SETTING: Ein boolescher Wert. Mit true werden erweiterte Prompts aktiviert, mit false deaktiviert. Der Standardwert ist true.
HTTP-Methode und URL:
POST https://LOCATION-aiplatform.googleapis.com/v1/projects/PROJECT_ID/locations/LOCATION/publishers/google/models/MODEL_VERSION:predict
Wenn die Prompt-Optimierung aktiviert ist, enthält die Antwort ein zusätzliches prompt-Feld mit dem optimierten Prompt und dem zugehörigen generierten Bild:
Die folgende Beispielantwort bezieht sich beispielsweise auf eine Anfrage mit "sampleCount": 2 und "prompt": "A raccoon wearing formal
clothes, wearing a top hat. Oil painting in the style of Vincent Van
Gogh.". Die Antwort gibt zwei Vorhersageobjekte zurück, jeweils mit dem optimierten Prompt und den generierten Bildbyte, die base64-codiert sind.
{
"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"
}
]
}
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 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)"]]