The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.

Image and Video Generation

library(foundryR)

foundryR supports current v1 preview image generation and editing parameters, while keeping the legacy deployment-style image endpoint available with api = "deployment".

Configure image resources

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_set_image_endpoint(Sys.getenv("AZURE_FOUNDRY_IMAGE_ENDPOINT"))
foundry_set_image_key("your-image-api-key")

Sys.setenv(AZURE_FOUNDRY_IMAGE_MODEL = "my-image-deployment")

Generate an image

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:36

Decode 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"
)

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.

Edit an image

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:

edited_path <- tempfile(fileext = ".jpeg")
edited <- foundry_image_edit(
  image = img_path,
  prompt = "Use a blue, Microsoft-inspired color palette.",
  model = "gpt-image-2",
  output_format = "jpeg"
)

foundry_save_image(edited, edited_path)
unlink(edited_path)

Generate video (preview)

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)

When to use these APIs

These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.