foundryR supports current v1 preview image generation and editing
parameters, while keeping the legacy deployment-style image endpoint
available with api = "deployment".
Image models may be deployed on the same Azure OpenAI resource as your text models, or on a separate resource. Use the image-specific helpers only when the resource or key differs. This setup chunk is illustrative and is not run:
foundry_image() returns one row per generated image with
the prompt, any model-revised prompt, the output format, and the image
bytes (as a URL or base64, depending on the model). Here we ask for a
small, compressed JPEG so the recorded fixture stays light.
image <- foundry_image(
"A friendly red panda reading a book, flat vector illustration",
model = "gpt-image-2",
size = "1024x1024",
quality = "low",
output_format = "jpeg",
output_compression = 40
)
image[, c("prompt", "revised_prompt", "output_format", "created")]
#> # A tibble: 1 × 4
#> prompt revised_prompt output_format created
#> <chr> <chr> <chr> <dttm>
#> 1 A friendly red panda reading… <NA> jpeg 2026-07-03 21:31:36Decode the returned bytes to a file with
foundry_save_image() and display the result:
img_path <- tempfile(fileext = ".jpeg")
foundry_save_image(image, img_path)
#> ✔ Image saved to '/tmp/RtmpTfwV4A/file1812b639901.jpeg' (from base64)
embed_image(
img_path,
alt = "AI-generated flat vector illustration of a friendly red panda reading a book"
)Image URLs are temporary. Save images that belong in reports,
stimuli, or audited records to a location you choose. This vignette uses
temporary files and removes them after use. Inline image display
requires the suggested base64enc package.
foundry_image_edit() takes an existing image and a
prompt. The call below is illustrative (it needs an image file on disk)
and is not run here:
Video generation is a preview, long-running workflow: create a job, poll it, and download the content once a generation succeeds. Because the job is asynchronous these calls are shown for reference and are not run here:
job <- foundry_video_job_create(
"A short animation of dots clustering into groups",
model = "my-video-model",
width = 1280,
height = 720,
n_seconds = 5
)
job <- foundry_video_job_get(job$job_id)
video_path <- tempfile(fileext = ".mp4")
foundry_video_download(
generation_id = job$generation_id,
path = video_path
)
unlink(video_path)foundry_image().foundry_image_edit().