Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

3. OpenAI Image Target

OpenAIImageTarget supports two different modes:

  • Generating a brand new image from a text prompt.

  • Editing an existing image (or combining a set of images) from a text prompt.

Generating Images (Text --> Image)

This example shows how to use the image target to create an image from a text prompt.

Found default environment files: ['./.pyrit/.env']
Loaded environment file: ./.pyrit/.env

────────────────────────────────────────────────────────────────────────────────────────────────────
🔹 Turn 1 - USER
────────────────────────────────────────────────────────────────────────────────────────────────────
  Give me an image of a raccoon pirate as a Spanish baker in Spain

────────────────────────────────────────────────────────────────────────────────────────────────────
🔸 ASSISTANT
────────────────────────────────────────────────────────────────────────────────────────────────────
  /workspace/dbdata/prompt-memory-entries/images/1773850714710505.jpeg
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1024x1024>

────────────────────────────────────────────────────────────────────────────────────────────────────
/workspace/dbdata/prompt-memory-entries/images/1773850714710505.jpeg

────────────────────────────────────────────────────────────────────────────────────────────────────
🔹 Turn 1 - USER
────────────────────────────────────────────────────────────────────────────────────────────────────
  Give me an image of a cafe in Paris

────────────────────────────────────────────────────────────────────────────────────────────────────
🔸 ASSISTANT
────────────────────────────────────────────────────────────────────────────────────────────────────
  /workspace/dbdata/prompt-memory-entries/images/1773850773132301.jpeg
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1024x1024>

────────────────────────────────────────────────────────────────────────────────────────────────────
/workspace/dbdata/prompt-memory-entries/images/1773850773132301.jpeg

Editing Images (Text + Image --> Image)

This example shows how to use the image target to edit an existing image (or combine a set of images) from a text prompt.


────────────────────────────────────────────────────────────────────────────────────────────────────
🔹 Turn 1 - USER
────────────────────────────────────────────────────────────────────────────────────────────────────
  Make the character in the first image fit in the cafe in the second image
  /workspace/dbdata/prompt-memory-entries/images/1773850714710505.jpeg
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1024x1024>
  /workspace/dbdata/prompt-memory-entries/images/1773850773132301.jpeg
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1024x1024>

────────────────────────────────────────────────────────────────────────────────────────────────────
🔸 ASSISTANT
────────────────────────────────────────────────────────────────────────────────────────────────────
  /workspace/dbdata/prompt-memory-entries/images/1773850838768350.jpeg
<PIL.JpegImagePlugin.JpegImageFile image mode=RGB size=1024x1024>

────────────────────────────────────────────────────────────────────────────────────────────────────
/workspace/dbdata/prompt-memory-entries/images/1773850838768350.jpeg