Image Generation
Create the .prompty File
Section titled “Create the .prompty File”Set apiType: image and pick a DALL-E model. Image options go in
model.options.additionalProperties:
---name: image-gendescription: Generate images from text descriptionsmodel: id: dall-e-3 provider: openai apiType: image connection: kind: key apiKey: ${env:OPENAI_API_KEY} options: additionalProperties: size: "1024x1024" quality: standard style: vividinputs: - name: prompt kind: string default: A serene mountain landscape at sunset---{{prompt}}Generate an Image
Section titled “Generate an Image”invoke() returns the generated image URL:
from prompty import invoke
url = invoke("image-gen.prompty", inputs={ "prompt": "A cat astronaut floating in space, digital art"})print(url) # https://oaidalleapiprodscus.blob.core.windows.net/...import { invoke } from "@prompty/core";import "@prompty/openai";
const url = await invoke("image-gen.prompty", { prompt: "A cat astronaut floating in space, digital art",});console.log(url);using Prompty.Core;
var url = await Pipeline.InvokeAsync("image-gen.prompty", new() { ["prompt"] = "A cat astronaut floating in space, digital art" });Console.WriteLine(url);Configuration Options
Section titled “Configuration Options”All options live under model.options.additionalProperties:
DALL-E 3
Section titled “DALL-E 3”| Option | Values | Default |
|---|---|---|
size | 1024x1024, 1792x1024, 1024x1792 | 1024x1024 |
quality | standard, hd | standard |
style | vivid, natural | vivid |
DALL-E 2
Section titled “DALL-E 2”| Option | Values | Default |
|---|---|---|
size | 256x256, 512x512, 1024x1024 | 1024x1024 |
n | 1–10 | 1 |
Azure OpenAI
Section titled “Azure OpenAI”Same pattern — switch provider and connection:
---name: azure-image-genmodel: id: ${env:AZURE_OPENAI_IMAGE_DEPLOYMENT} provider: azure apiType: image connection: kind: key endpoint: ${env:AZURE_OPENAI_ENDPOINT} apiKey: ${env:AZURE_OPENAI_API_KEY} options: additionalProperties: size: "1024x1024" quality: standardinputs: - name: prompt kind: string---{{prompt}}The calling code is identical — only the .prompty file changes.
Further Reading
Section titled “Further Reading”- File format reference — full
.promptyfrontmatter syntax - Connections — configuring provider connections