vercel.AiGatewayImageClient
The Vercel AI Gateway image client: POST {base_url}/image-model.
Signature
class vercel.AiGatewayImageClientThe Vercel AI Gateway image client: POST {base_url}/image-model.
client "ai-gateway-images/bfl/flux-2-pro" in an LLM function constructs
this class. The gateway fronts many image providers behind one endpoint; the
model id — including its provider prefix — rides in the ai-model-id header,
not in the body.
function DrawLamp(subject: string) -> image {
client "ai-gateway-images/bfl/flux-2-pro"
prompt `A studio photograph of ${subject}.`
}
Image inputs ARE supported: an image prompt part becomes a files[] entry,
which is how the endpoint does editing and variations —
function Restyle(source: image) -> image {
client "ai-gateway-images/openai/gpt-image-1"
prompt `Redraw ${source} in watercolor.`
}
Audio/video/pdf inputs have no representation and are rejected, as is tool
calling. (mask, the other editing input, has no first-class field yet; pass
it through request_body as {"mask": {"type": "file", "mediaType": …, "data": …}}.)
Source:<builtin>/vercel/images.bamlbytes 1103–5618
Fields
model
stringapi_key
ai.Credential | nullbase_url
ai.Credential | nulln
int | nullsize
string | nullaspect_ratio
string | nullseed
int | 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 gateway's
conventional variable. (sys_llm had no env default here and required
api_key: env.AI_GATEWAY_API_KEY in every client declaration.)
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 gateway default.
Implementations
ai.Client for vercel.AiGatewayImageClient
Instance methods
id
(self) -> stringinvoke
(render
(Source:<builtin>/vercel/images.bamlbytes 4815–5428