openai.ImageClient
The OpenAI image-generation client: POST {base_url}/images/generations.
Signature
class openai.ImageClientThe OpenAI image-generation client: POST {base_url}/images/generations.
client "openai-images/gpt-image-1" in an LLM function constructs this
class. Its output type is media — -> image, -> image[], -> image?,
-> string | image — which the runner builds from the turn's media blocks
(ai/runner.baml) instead of parsing text.
function DrawLamp(subject: string) -> image {
client "openai-images/gpt-image-1"
prompt `A studio photograph of ${subject}.`
}
The endpoint takes a text prompt only: media inputs are rejected (image editing is a different, multipart endpoint) and tools are not supported.
Source:<builtin>/openai/images.bamlbytes 690–7172
Fields
model
stringapi_key
ai.Credential | nullbase_url
ai.Credential | nulln
int | nullsize
string | nullquality
string | nullbackground
string | nulloutput_format
string | nulloutput_compression
int | nullmoderation
string | nullstyle
string | nulluser
string | nullresponse_format
string | nullrequest_body
baml.json.json | nullheaders
map<string, string> | nullquery_params
map<string, string> | nullcapture_wire
boolStatic methods
new
(Creates a client. Construction reads no environment variable, so declaring one is always safe; credentials and endpoints resolve when a request is built.
Instance methods
resolved_api_key
(The request-time credential: an explicit value, else the provider's
canonical one. A missing credential is a catchable
ai.errors.InvalidRequest rather than a panic, so the caller's
catch_all can fall back to another client.
resolved_base_url
(self) -> string | null throws baml.errors.Io | baml.errors.ParseErrorThe request-time base URL, or null for the provider default.
Implementations
ai.Client for openai.ImageClient
Instance methods
id
(self) -> stringinvoke
(render
(Source:<builtin>/openai/images.bamlbytes 6303–6901