Skip to contents

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.

Examples

if (FALSE) { # \dontrun{
img <- hf_text_to_image("a small red cube on a white background", seed = 42)
img$path
} # }