Given a description, the model generates image.
import os
from friendli import SyncFriendli
with SyncFriendli(
token=os.getenv("FRIENDLI_TOKEN", ""),
) as friendli:
res = friendli.container.image.generate(
prompt="An orange Lamborghini driving down a hill road at night with a beautiful ocean view in the background.",
model="(adapter-route)",
num_inference_steps=10,
guidance_scale=3.5,
control_images=[
{
"image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png",
},
],
)
# Handle response
print(res)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
prompt |
str | ✔️ | A text description of the desired image. | |
model |
OptionalNullable[str] | ➖ | Routes the request to a specific adapter. | (adapter-route) |
num_inference_steps |
Optional[int] | ➖ | The number of inference steps to use during image generation. Defaults to 20. Supported range: [1, 50]. | |
guidance_scale |
Optional[float] | ➖ | Adjusts the alignment of the generated image with the input prompt. Higher values (e.g., 8-10) make the output more faithful to the prompt, while lower values (e.g., 1-5) encourage more creative freedom. Defaults to 0. This parameter may be irrelevant for certain models, such as FLUX.Schnell. |
|
seed |
OptionalNullable[int] | ➖ | The seed to use for image generation. | |
response_format |
OptionalNullable[models.ContainerImageGenerationBodyResponseFormat] | ➖ | The format in which the generated image will be returned. One of raw and jpeg. |
|
control_images |
List[models.ImageInput] | ➖ | Optional input images used to condition or guide the generation process (e.g., for ControlNet or image editing models). This field is only applicable when using ControlNet or image editing models. | |
controlnet_weights |
List[float] | ➖ | A list of weights that determine the influence of each ControlNet model in the generation process. Each value must be within [0, 1], where 0 disables the corresponding ControlNet and 1 applies it fully. When multiple ControlNet models are used, the list length must match the number of control images. If omitted, all ControlNet models default to full influence (1.0). This field is only applicable when using ControlNet models. | |
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. | |
server_url |
Optional[str] | ➖ | An optional server URL to use. | http://localhost:8080 |
models.ContainerImageGenerateSuccess
| Error Type | Status Code | Content Type |
|---|---|---|
| models.SDKError | 4XX, 5XX | */* |
Given an image and a description, the model edits the image.
import os
from friendli import SyncFriendli
with SyncFriendli(
token=os.getenv("FRIENDLI_TOKEN", ""),
) as friendli:
res = friendli.container.image.edit(
image=[
{
"image": "https://huggingface.co/datasets/huggingface/documentation-images/resolve/main/diffusers/cat.png",
},
],
prompt="Add a red sports car in the foreground.",
model="(adapter-route)",
num_inference_steps=20,
guidance_scale=0,
)
# Handle response
print(res)| Parameter | Type | Required | Description | Example |
|---|---|---|---|---|
image |
models.ContainerImageEditBodyImage | ✔️ | The image(s) to edit. Must be in a supported image format. | |
prompt |
str | ✔️ | A text description of the desired image. | |
model |
OptionalNullable[str] | ➖ | Routes the request to a specific adapter. | (adapter-route) |
num_inference_steps |
Optional[int] | ➖ | The number of inference steps to use during image generation. Defaults to 20. Supported range: [1, 50]. | |
guidance_scale |
Optional[float] | ➖ | Adjusts the alignment of the generated image with the input prompt. Higher values (e.g., 8-10) make the output more faithful to the prompt, while lower values (e.g., 1-5) encourage more creative freedom. Defaults to 0. This parameter may be irrelevant for certain models, such as FLUX.Schnell. |
|
seed |
OptionalNullable[int] | ➖ | The seed to use for image generation. | |
response_format |
OptionalNullable[models.ContainerImageEditBodyResponseFormat] | ➖ | The format in which the generated image will be returned. One of raw and jpeg. |
|
retries |
Optional[utils.RetryConfig] | ➖ | Configuration to override the default retry behavior of the client. | |
server_url |
Optional[str] | ➖ | An optional server URL to use. | http://localhost:8080 |
models.ContainerImageGenerateSuccess
| Error Type | Status Code | Content Type |
|---|---|---|
| models.SDKError | 4XX, 5XX | */* |