Skip to content

Commit 1b5fa14

Browse files
committed
doc: Add vision feature to documentation
1 parent 74ee7c6 commit 1b5fa14

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

README.md

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Supports **PHP 8.2+**, built with **OOP best practices**, and **fully type-safe*
1818
- [Installation](#installation)
1919
- [Quick Start](#quick-start)
2020
- [Basic Usage](#basic-usage)
21+
- [Vision Analysis](#vision-analysis-image-recognition)
2122
- [Advanced Configuration](#advanced-configuration)
2223
- [Available Grok AI Models](#available-grok-ai-models)
2324
- [Streaming Responses](#streaming-responses)
@@ -88,6 +89,33 @@ echo "AI Response: " . $response['choices'][0]['message']['content'];
8889

8990
---
9091

92+
### Vision Analysis (Image Recognition)
93+
The **Vision API** allows you to send images for analysis using **Grok-2-Vision** models.
94+
95+
```php
96+
use GrokPHP\Client\Clients\GrokClient;
97+
use GrokPHP\Client\Config\GrokConfig;
98+
99+
// Initialize the client
100+
$config = new GrokConfig('your-api-key');
101+
$client = new GrokClient($config);
102+
103+
// Use the Vision API to analyze an image
104+
$response = $client->vision()->analyze('https://example.com/image.jpg', 'Describe this image.');
105+
106+
echo "Vision Response: " . $response['choices'][0]['message']['content'];
107+
```
108+
109+
#### Supported Models for Vision
110+
| Model Enum | API Model Name | Description |
111+
|-----------------------------|----------------------|----------------------------------|
112+
| `Model::GROK_2_VISION` | grok-2-vision | Base Vision Model |
113+
| `Model::GROK_2_VISION_LATEST` | grok-2-vision-latest | Latest Vision Model |
114+
| `Model::GROK_2_VISION_1212` | grok-2-vision-1212 | Default model for image analysis |
115+
116+
**Note:** If you attempt to use an **unsupported model** for vision, an exception will be thrown.
117+
118+
---
91119
### **Advanced Configuration**
92120

93121
```php

0 commit comments

Comments
 (0)