hf_text_to_image: Generate an Image from Text

View source: R/multimodal.R

hf_text_to_imageR Documentation

Generate an Image from Text

Description

Generate an image from a prompt and write it to disk using a text-to-image model via the Hugging Face Inference Providers API.

Usage

hf_text_to_image(
  prompt,
  output = NULL,
  seed = NULL,
  model = hf_default_model("text_to_image"),
  token = NULL,
  endpoint_url = NULL,
  overwrite = FALSE,
  ...
)

Arguments

prompt

Character vector of prompts.

output

Character path(s) or NULL. When NULL, files are written to temporary paths with an extension inferred from the response content type.

seed

Integer or NULL. Optional random seed for reproducibility when the provider/model supports it.

model

Character string. Model ID from Hugging Face Hub. Default: "black-forest-labs/FLUX.1-schnell".

token

Character string or NULL. API token for authentication.

endpoint_url

Character string or NULL. A custom Inference Endpoint URL.

overwrite

Logical. If TRUE, overwrite existing output files.

...

Additional generation parameters passed to the model.

Value

A tibble with columns: prompt, path, content_type, image.

See Also

https://huggingface.co/docs/inference-providers/tasks/text-to-image

Examples

## Not run: 
img <- hf_text_to_image("a small red cube on a white background", seed = 42)
img$path

## End(Not run)

huggingfaceR documentation built on Aug. 30, 2026, 1:06 a.m.