Use this file to discover all available pages before exploring further.
ImageResult is the value object returned after an image generation request completes. It exposes the first generated image directly through the output convenience property, the full set of generated images through images, and the standard token usage and provider metadata fields shared by all result types.
The first generated image, provided as a convenience so single-image workflows do not need to index into the images array. This is always the same object as images[0].
A URL pointing to the generated image, when the provider returns a hosted URL instead of inline Base64 data. null when the image was returned as Base64.
Decodes base64 into raw binary and returns it. Returns null when base64 is null or when strict Base64 decoding fails. Use this to feed image data directly into PHP image functions or HTTP responses.
Decodes the Base64 image data and writes the raw bytes to the file at $path. Returns the $path that was written. Throws AiSdkException if the image contains no decodable binary content or if the write fails.
The unmodified response payload returned by the provider’s API. Useful for debugging or accessing provider-specific fields not surfaced in the structured properties above.
Provider-specific metadata keyed by provider name. Contents vary across providers and may include safety ratings, seed values, or model-specific annotations.
$result = $ai->image('A photorealistic red panda in a bamboo forest, golden hour.');// Save directly using the convenience property$result->output->save('/var/www/storage/red-panda.png');// Or decode to bytes for streaming in an HTTP responseheader('Content-Type: ' . $result->output->mimeType);echo $result->output->bytes();
$result = $ai->image('Minimalist vector logo for a tech startup.');$image = $result->output;if ($image->url !== null) { // Provider returned a hosted URL — use it directly echo "Image URL: {$image->url}\n";} elseif ($image->base64 !== null) { // Provider returned inline Base64 data $image->save('/tmp/logo.png');}