Skip to content

Image Processing

Overview

Image class in Instructor PHP provides an easy way to include images in your prompts. It supports loading images from files, URLs, or base64 encoded strings. The image can be sent as part of the message content to the LLM.

Example

```php

asSystem('You are an expert in car damage assessment.') ->asUser((new Content) ->addContentPart(ContentPart::text('Describe the car damage in the image.')) ->addContentPart(Image::fromFile(__DIR__ . '/car-damage.jpg')->toContentPart()) ); $response = (new Inference) ->using('openai') ->withModel('gpt-4o-mini') ->withMessages($messages) ->get(); echo "Response: " . $response . "\n"; ?>