Configuration (imagewright.config)¶
imagewright.config
¶
Image backend configuration: the backend enum, the config dataclass and its env factory.
ImageBackend
¶
Bases: str, Enum
Image generation backend.
ImageConfig(backend=ImageBackend.MFLUX_SERVE, server_url='', api_key='', model='', steps=4)
dataclass
¶
Configuration for an image synthesis backend.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
backend
|
ImageBackend
|
Which image provider to use. |
MFLUX_SERVE
|
server_url
|
str
|
Image server base URL override (empty = use backend default). |
''
|
api_key
|
str
|
OpenAI API key (empty = read from OPENAI_API_KEY at call time).
Left out of |
''
|
model
|
str
|
Model-id override (empty = use backend default). |
''
|
steps
|
int
|
Inference steps for mflux backends (ignored for OpenAI). |
4
|
resolved_model()
¶
Return the model id, or the backend's default when none is set.
Returns:
| Type | Description |
|---|---|
str
|
Model id. |
Source code in src/imagewright/config.py
58 59 60 61 62 63 | |
resolved_server_url()
¶
Return the server URL, or the backend's default when none is set.
Returns:
| Type | Description |
|---|---|
str
|
Base URL, or an empty string for backends without a server. |
Source code in src/imagewright/config.py
51 52 53 54 55 56 | |
env_image_endpoint()
¶
Return the image server URL configured in the environment.
Returns:
| Type | Description |
|---|---|
str
|
|
Source code in src/imagewright/config.py
66 67 68 69 70 71 | |
image_config_from_env()
¶
Build an ImageConfig from environment variables.
Reads IMAGE_BACKEND (default mflux-serve; an unknown value also gives
mflux-serve), IMAGE_ENDPOINT, IMAGE_API_KEY, IMAGE_MODEL and
IMAGE_STEPS. GUTENKG_IMAGE_ENDPOINT and GUTENKG_IMAGE_MODEL are
fallbacks for the endpoint and model, and OPENAI_API_KEY for the key.
Returns:
| Type | Description |
|---|---|
ImageConfig
|
The configuration the environment describes. |
Source code in src/imagewright/config.py
74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |