{"id":33587636,"url":"https://github.com/tigusigalpa/yandexgpt-php","last_synced_at":"2026-04-13T06:23:45.024Z","repository":{"id":317001800,"uuid":"1065614942","full_name":"tigusigalpa/yandexgpt-php","owner":"tigusigalpa","description":"🚀 YandexGPT PHP - многофункциональная библиотека для интеграции с Яндекс AI API. Простое подключение YandexGPT и YandexART к PHP-приложениям с поддержкой Laravel. Генерация текста, чат-боты, AI-ассистенты, Alice AI. Полная документация, примеры кода. Быстрый старт с Яндекс Cloud AI.","archived":false,"fork":false,"pushed_at":"2026-03-04T03:24:20.000Z","size":284,"stargazers_count":22,"open_issues_count":0,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-03-04T08:07:40.560Z","etag":null,"topics":["ai","api","gpt","laravel","php","sdk","yandex","yandex-cloud","yandex-cloud-api","yandex-cloud-client","yandex-gpt","yandexart","yandexcloud","yandexgpt","yandexgpt-api","yandexgpt-integration"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tigusigalpa.png","metadata":{"files":{"readme":"README-en.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-09-28T04:42:28.000Z","updated_at":"2026-03-04T03:24:23.000Z","dependencies_parsed_at":"2025-10-19T06:17:18.907Z","dependency_job_id":"75cefb05-5a5b-410a-a0d9-b14b38fc6695","html_url":"https://github.com/tigusigalpa/yandexgpt-php","commit_stats":null,"previous_names":["tigusigalpa/yandexgpt-php"],"tags_count":8,"template":false,"template_full_name":null,"purl":"pkg:github/tigusigalpa/yandexgpt-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigusigalpa%2Fyandexgpt-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigusigalpa%2Fyandexgpt-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigusigalpa%2Fyandexgpt-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigusigalpa%2Fyandexgpt-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tigusigalpa","download_url":"https://codeload.github.com/tigusigalpa/yandexgpt-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tigusigalpa%2Fyandexgpt-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31742208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-13T05:13:27.074Z","status":"ssl_error","status_checked_at":"2026-04-13T05:13:25.150Z","response_time":93,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["ai","api","gpt","laravel","php","sdk","yandex","yandex-cloud","yandex-cloud-api","yandex-cloud-client","yandex-gpt","yandexart","yandexcloud","yandexgpt","yandexgpt-api","yandexgpt-integration"],"created_at":"2025-11-29T10:00:44.724Z","updated_at":"2026-04-13T06:23:45.010Z","avatar_url":"https://github.com/tigusigalpa.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# YandexGPT PHP SDK\n\n![YandexGPT PHP SDK](https://i.postimg.cc/Qx2kShKX/yandexgpt-php-banner.jpg)\n\n[![Latest Version](https://img.shields.io/packagist/v/tigusigalpa/yandexgpt-php.svg?style=flat-square)](https://packagist.org/packages/tigusigalpa/yandexgpt-php)\n[![PHP Version](https://img.shields.io/packagist/php-v/tigusigalpa/yandexgpt-php.svg?style=flat-square)](https://packagist.org/packages/tigusigalpa/yandexgpt-php)\n[![License](https://img.shields.io/packagist/l/tigusigalpa/yandexgpt-php.svg?style=flat-square)](https://packagist.org/packages/tigusigalpa/yandexgpt-php)\n[![Dependencies](https://img.shields.io/packagist/dm/tigusigalpa/yandexgpt-php.svg?style=flat-square)](https://packagist.org/packages/tigusigalpa/yandexgpt-php)\n\n**Language:** English | [Русский](README.md)\n\nPHP SDK for YandexGPT API and YandexART. Text generation, dialogues, images, Conversations API. Works with any PHP 8.0+\nproject and has built-in Laravel support.\n\n\u003e For cloud infrastructure management (organizations, clouds, folders)\n\u003e see [yandex-cloud-client-php](https://github.com/tigusigalpa/yandex-cloud-client-php).\n\n\u003e 📖 **[Full documentation available on Wiki](https://github.com/tigusigalpa/yandexgpt-php/wiki)**\n\n## Features\n\n- All YandexGPT models: Lite, Pro, Alice AI\n- Image generation via YandexART\n- Conversations API — server-side conversations\n- Reasoning mode (Chain of Thought)\n- Automatic OAuth/IAM token management\n- Laravel: Service Provider, Facade, configuration\n- PHP 8.0+, Laravel 8.0+, Guzzle HTTP\n\n---\n\n## Installation\n\nVia Composer:\n\n```bash\ncomposer require tigusigalpa/yandexgpt-php\n```\n\n### Local Development\n\nIf you want to use the package locally for development or testing:\n\n#### Method 1: Via local repository\n\n1. **Clone or place the package in your project folder:**\n\n   ```bash\n   # In the root of your Laravel project\n   mkdir -p packages\n   cd packages\n   git clone https://github.com/tigusigalpa/yandexgpt-php.git\n   # or copy the package folder to packages/yandexgpt-php\n   ```\n\n2. **Add the local repository to your project's composer.json:**\n\n   ```json\n   {\n       \"repositories\": [\n           {\n               \"type\": \"path\",\n               \"url\": \"./packages/yandexgpt-php\"\n           }\n       ],\n       \"require\": {\n           \"tigusigalpa/yandexgpt-php\": \"@dev\"\n       }\n   }\n   ```\n\n3. **Install the dependencies:**\n\n   ```bash\n   composer install\n   # or if the package was already installed\n   composer update tigusigalpa/yandexgpt-php\n   ```\n\n#### Method 2: Via symlinks\n\n1. **Create a symlink in vendor:**\n\n   ```bash\n   # Remove the existing package (if any)\n   rm -rf vendor/tigusigalpa/yandexgpt-php\n\n   # Create a symlink\n   ln -s ../../packages/yandexgpt-php vendor/tigusigalpa/yandexgpt-php\n   ```\n\n#### Method 3: Via VCS repository\n\n```json\n{\n    \"repositories\": [\n        {\n            \"type\": \"vcs\",\n            \"url\": \"https://github.com/tigusigalpa/yandexgpt-php.git\"\n        }\n    ],\n    \"require\": {\n        \"tigusigalpa/yandexgpt-php\": \"dev-main\"\n    }\n}\n```\n\n### For Laravel\n\nThe package is automatically registered in Laravel thanks to auto-discovery. Publish the configuration file:\n\n```bash\nphp artisan vendor:publish --tag=yandexgpt-config\n```\n\n---\n\n## Configuration\n\n### 1. Getting an OAuth token\n\nDocumentation: [OAuth-token](https://yandex.cloud/en/docs/iam/concepts/authorization/oauth-token)\n\nFollow the link\nto [get an OAuth token](https://oauth.yandex.com/authorize?response_type=token\u0026client_id=1a6990aa636648e9b2ef855fa7bec2fb):\n\n```\nhttps://oauth.yandex.com/authorize?response_type=token\u0026client_id=1a6990aa636648e9b2ef855fa7bec2fb\n```\n\n### 2. Environment configuration\n\nAdd to your `.env` file:\n\n```env\nYANDEX_GPT_OAUTH_TOKEN=your_oauth_token_here\n# get folder_id via special request\nYANDEX_GPT_FOLDER_ID=your_folder_id_here\nYANDEX_GPT_DEFAULT_MODEL=yandexgpt-lite\nYANDEX_GPT_TEMPERATURE=0.6\nYANDEX_GPT_MAX_TOKENS=2000\n```\n\n### 3. Yandex Cloud preparation\n\nTo work with the YandexGPT API, you need to perform several steps in Yandex Cloud. The SDK automates most of them, but\nit is important to understand the process:\n\n#### 3.1. Getting an IAM token\n\nDocumentation: [Getting an IAM token for a Yandex account](https://yandex.cloud/en/docs/iam/operations/iam-token/create#exchange-token)\n\nThe IAM token is obtained automatically through the SDK using the OAuth token. The token is valid for 12 hours and is\nrenewed automatically.\n\n**Getting via SDK:**\n\n```php\nuse Tigusigalpa\\YandexCloudClient\\YandexCloudClient;\n\n// Create Yandex Cloud client\n$cloudClient = new YandexCloudClient('your_oauth_token');\n\n// Get an IAM token\n$iamToken = $cloudClient-\u003egetAuthManager()-\u003egetIamToken();\n\necho \"IAM Token: \" . $iamToken . \"\\n\";\n```\n\n**Automatic token management via YandexGPTClient:**\n\n```php\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\n\n// The client automatically gets and renews IAM tokens\n$client = new YandexGPTClient('your_oauth_token', 'your_folder_id');\n\n// Get Yandex Cloud client for cloud management\n$cloudClient = $client-\u003egetCloudClient();\n$iamToken = $cloudClient-\u003egetAuthManager()-\u003egetIamToken();\n```\n\n**Manual retrieval via API:**\n\n```bash\ncurl -d \"{\\\"yandexPassportOauthToken\\\":\\\"YOUR_OAUTH_TOKEN\\\"}\" \\\n  \"https://iam.api.cloud.yandex.net/iam/v1/tokens\"\n```\n\n#### 3.2. Getting Cloud ID\n\n**Documentation:** [Getting a list of Cloud resources](https://yandex.cloud/en/docs/resource-manager/api-ref/Cloud/list)\n\n**Via SDK:**\n\n```php\nuse Tigusigalpa\\YandexCloudClient\\YandexCloudClient;\n\n$cloudClient = new YandexCloudClient('your_oauth_token');\n\n// Laravel:\n// use Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\n// $cloudClient = YandexGPT::getCloudClient();\n$clouds = $cloudClient-\u003eclouds()-\u003elist();\n\nforeach ($clouds as $cloud) {\n    echo \"Cloud ID: \" . $cloud['id'] . \"\\n\";\n    echo \"Name: \" . $cloud['name'] . \"\\n\";\n}\n```\n\n**Via Yandex Cloud CLI:**\n\n```bash\nyc resource-manager cloud list\n```\n\n**Via web console:** [Yandex Cloud Console](https://console.cloud.yandex.com/) → select a cloud → copy the ID\n\n#### 3.3. Getting Folder ID\n\n**Documentation:\n** [Getting a list of Folder resources in the specified cloud](https://yandex.cloud/en/docs/resource-manager/api-ref/Folder/list)\n\n**Via SDK:**\n\n```php\nuse Tigusigalpa\\YandexCloudClient\\YandexCloudClient;\n\n$cloudClient = new YandexCloudClient('your_oauth_token');\n\n// Get existing folders\n$folders = $cloudClient-\u003efolders()-\u003elist('cloud_id');\nforeach ($folders as $folder) {\n    echo \"Folder ID: \" . $folder['id'] . \"\\n\";\n    echo \"Name: \" . $folder['name'] . \"\\n\";\n}\n```\n\n**Via Yandex Cloud CLI:**\n\n```bash\n# Create a folder\nyc resource-manager folder create --name my-ai-folder --cloud-id YOUR_CLOUD_ID\n\n# List folders\nyc resource-manager folder list --cloud-id YOUR_CLOUD_ID\n```\n\n#### Creating a folder\n\n```php\nuse Tigusigalpa\\YandexCloudClient\\YandexCloudClient;\n\n$cloudClient = new YandexCloudClient('your_oauth_token');\n\n// Laravel:\n// use Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\n// $cloudClient = YandexGPT::getCloudClient();\n\n// Create a folder\n$folder = $cloudClient-\u003efolders()-\u003ecreate('cloud_id', 'my-ai-folder', 'Folder for AI projects');\n$folderId = $folder['metadata']['folderId'];\n\n```\n\nDocumentation: [Creating a folder](https://yandex.cloud/en/docs/resource-manager/operations/folder/create)\n\n#### 3.4. Assigning roles to folder or cloud\n\nDocumentation:\n\n[Authentication in Yandex AI Studio API](https://yandex.cloud/en/docs/ai-studio/api-ref/authentication)\n\n[Access management in Yandex AI Studio](https://yandex.cloud/en/docs/ai-studio/security/)\n\n[Assign a role to a folder or cloud](https://yandex.cloud/en/docs/iam/operations/roles/grant#cloud-or-folder)\n\n[Assigning a role to a cloud](https://yandex.cloud/en/docs/resource-manager/api-ref/Cloud/updateAccessBindings)\n\n[Subject object for cloud](https://yandex.cloud/en/docs/resource-manager/api-ref/Cloud/updateAccessBindings#yandex.cloud.access.Subject)\n\n[Assigning a role to a folder](https://yandex.cloud/en/docs/resource-manager/api-ref/Folder/updateAccessBindings)\n\n[Subject object for folder](https://yandex.cloud/en/docs/resource-manager/api-ref/Folder/updateAccessBindings#yandex.cloud.access.Subject)\n\n[Step-by-step instructions for Identity and Access Management](https://yandex.cloud/en/docs/iam/operations/)\n\n[UserAccount API](https://yandex.cloud/en/docs/iam/api-ref/UserAccount/)\n\n[Identity and Access Management API, REST: YandexPassportUserAccount.GetByLogin](https://yandex.cloud/en/docs/iam/api-ref/YandexPassportUserAccount/getByLogin)\n\n**Via SDK:**\n\n```php\nuse Tigusigalpa\\YandexCloudClient\\YandexCloudClient;\n\n$cloudClient = new YandexCloudClient('your_oauth_token');\n\n// Laravel:\n// use Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\n// $cloudClient = YandexGPT::getCloudClient();\n\n// 1. Get User ID by Yandex login\n$userInfo = $cloudClient-\u003eyandexPassportUserAccounts()-\u003egetByLogin('username@yandex.ru');\n$userId = $userInfo['id'];\n\n// 2. Get user information by UserAccountId\n$userAccount = $cloudClient-\u003euserAccounts()-\u003eget($userId);\n\n// 3. Assign role to folder\n$cloudClient-\u003efolders()-\u003eupdateAccessBindings(\n    'folder_id',\n    [\n        [\n            'action' =\u003e 'ADD',\n            'accessBinding' =\u003e [\n                'roleId' =\u003e 'ai.languageModels.user',\n                'subject' =\u003e [\n                    'id' =\u003e $userId,\n                    'type' =\u003e 'userAccount'\n                ]\n            ]\n        ]\n    ]\n);\n\n// 4. Assign role to cloud\n$cloudClient-\u003eclouds()-\u003eupdateAccessBindings(\n    'cloud_id',\n    [\n        [\n            'action' =\u003e 'ADD',\n            'accessBinding' =\u003e [\n                'roleId' =\u003e 'viewer',\n                'subject' =\u003e [\n                    'id' =\u003e $userId,\n                    'type' =\u003e 'userAccount'\n                ]\n            ]\n        ]\n    ]\n);\n```\n\n**Via Yandex Cloud CLI:**\n\n```bash\n# Assign a role to a user\nyc resource-manager folder add-access-binding \\\n  --id YOUR_FOLDER_ID \\\n  --role ai.languageModels.user \\\n  --user-account-id YOUR_USER_ID\n\n# Assign a role to a service account\nyc resource-manager folder add-access-binding \\\n  --id YOUR_FOLDER_ID \\\n  --role ai.languageModels.user \\\n  --service-account-id YOUR_SERVICE_ACCOUNT_ID\n```\n\n**Via web console:**\n\n1. Open [Yandex Cloud Console](https://console.cloud.yandex.com/)\n2. Select a folder\n3. Go to the \"Access rights\" section\n4. Click \"Assign roles\"\n5. Select a user and the `ai.languageModels.user` role\n\nDocumentation:\n\n- [Assigning roles](https://yandex.cloud/en/docs/iam/operations/roles/grant)\n- [Roles for Yandex Foundation Models](https://yandex.cloud/en/docs/foundation-models/security/)\n\n#### 3.5. Full setup example\n\n```php\n\u003c?php\n\nuse Tigusigalpa\\YandexCloudClient\\YandexCloudClient;\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\n\n// 1. Initialize Yandex Cloud client\n$cloudClient = new YandexCloudClient('your_oauth_token');\n\n// Laravel:\n// use Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\n// $cloudClient = YandexGPT::getCloudClient();\n\n// 2. Get the list of clouds\n$clouds = $cloudClient-\u003eclouds()-\u003elist();\n$cloudId = $clouds[0]['id']; // Take the first cloud\n\n// 3. Create a folder (if needed)\n$folder = $cloudClient-\u003efolders()-\u003ecreate($cloudId, 'ai-projects', 'Folder for AI');\n$folderId = $folder['metadata']['folderId'];\n\n// 4. Get User ID by login (if needed)\n$userInfo = $cloudClient-\u003eyandexPassportUserAccounts()-\u003egetByLogin('username@yandex.ru');\n$userId = $userInfo['id'];\n\n// 5. Assign role to folder\n$cloudClient-\u003efolders()-\u003eupdateAccessBindings(\n    $folderId,\n    [\n        [\n            'action' =\u003e 'ADD',\n            'accessBinding' =\u003e [\n                'roleId' =\u003e 'ai.languageModels.user',\n                'subject' =\u003e ['id' =\u003e $userId, 'type' =\u003e 'userAccount']\n            ]\n        ]\n    ]\n);\n\n// Or assign role to cloud\n$cloudClient-\u003eclouds()-\u003eupdateAccessBindings(\n    $cloudId,\n    [\n        [\n            'action' =\u003e 'ADD',\n            'accessBinding' =\u003e [\n                'roleId' =\u003e 'editor',\n                'subject' =\u003e ['id' =\u003e $userId, 'type' =\u003e 'userAccount']\n            ]\n        ]\n    ]\n);\n\n// 6. Use the client\n$client = new YandexGPTClient('your_oauth_token', $folderId);\n$response = $client-\u003egenerateText('Hello, how are you?');\n\necho $response['result']['alternatives'][0]['message']['text'];\n```\n\n#### 3.6. Useful links\n\n- [YandexGPT Quickstart](https://yandex.cloud/en/docs/foundation-models/quickstart/yandexgpt)\n- [API Authentication](https://yandex.cloud/en/docs/iam/concepts/authorization/iam-token)\n- [Resource Management](https://yandex.cloud/en/docs/resource-manager/)\n- [API Foundation Models](https://yandex.cloud/en/docs/foundation-models/concepts/api)\n- [YandexGPT Pricing](https://yandex.cloud/en/docs/foundation-models/pricing)\n\n---\n\n## Usage\n\n### Basic usage (without Laravel)\n\n```php\n\u003c?php\n\nrequire_once 'vendor/autoload.php';\n\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\n\n// Create a client\n$client = new YandexGPTClient('your_oauth_token', 'your_folder_id');\n\n// Simple request\n$response = $client-\u003egenerateText(\n    'Tell me about the benefits of PHP',\n    YandexGPTModel::YANDEX_GPT_LITE\n);\n\necho $response['result']['alternatives'][0]['message']['text'];\n\n// Using Alice AI model for conversational tasks\n$response = $client-\u003egenerateText(\n    'Hello! Tell me an interesting story',\n    YandexGPTModel::ALICE_AI,\n    [\n        'completionOptions' =\u003e [\n            'temperature' =\u003e 0.7,\n            'maxTokens' =\u003e 2000\n        ]\n    ]\n);\n\necho $response['result']['alternatives'][0]['message']['text'];\n```\n\n### Usage with Laravel\n\n#### Via facade\n\n```php\n\u003c?php\n\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\n\n// Simple request\n$response = YandexGPT::generateText('Hello, how are you?');\n\n// With specified model and parameters\n$response = YandexGPT::generateText(\n    'Write a poem about programming',\n    YandexGPTModel::YANDEX_GPT,\n    [\n        'completionOptions' =\u003e [\n            'temperature' =\u003e 0.8,\n            'maxTokens' =\u003e 1000\n        ]\n    ]\n);\n\necho $response['result']['alternatives'][0]['message']['text'];\n```\n\n#### Via dependency injection\n\n```php\n\u003c?php\n\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\n\nclass ChatController extends Controller\n{\n    public function __construct(private YandexGPTClient $yandexGPT)\n    {\n    }\n\n    public function generateResponse(Request $request)\n    {\n        $response = $this-\u003eyandexGPT-\u003egenerateText($request-\u003einput('message'));\n        \n        return response()-\u003ejson([\n            'response' =\u003e $response['result']['alternatives'][0]['message']['text']\n        ]);\n    }\n}\n```\n\n### Working with dialogues\n\n```php\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\n\n$messages = [\n    [\n        'role' =\u003e 'system',\n        'text' =\u003e 'You are a helpful programmer assistant'\n    ],\n    [\n        'role' =\u003e 'user',\n        'text' =\u003e 'How to create a REST API in Laravel?'\n    ],\n    [\n        'role' =\u003e 'assistant',\n        'text' =\u003e 'To create a REST API in Laravel, use the command php artisan make:controller...'\n    ],\n    [\n        'role' =\u003e 'user',\n        'text' =\u003e 'And how to add validation?'\n    ]\n];\n\n$response = YandexGPT::generateFromMessages($messages);\n```\n\n### Managing Yandex Cloud resources\n\n```php\n\u003c?php\n\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\n\n$client = new YandexGPTClient('oauth_token', 'folder_id');\n$authManager = $client-\u003egetAuthManager();\n\n// Get an IAM token\n$iamToken = $authManager-\u003egetIamToken();\n\n// Get the list of clouds\n$clouds = $authManager-\u003egetClouds($iamToken);\n\n// Create a folder\n$folder = $authManager-\u003ecreateFolder(\n    $iamToken,\n    'cloud_id',\n    'my-yandexgpt-folder',\n    'Folder for working with YandexGPT'\n);\n\n// Get User ID by Yandex login\n$userId = $authManager-\u003egetUserIdByLogin('username@yandex.ru');\n\n// Get user information\n$userInfo = $authManager-\u003egetUserByLogin('username@yandex.ru');\n// or by UserAccountId\n$userAccount = $authManager-\u003egetUserAccount($userId);\n\n// Assign role to folder\n$authManager-\u003eassignRoleToFolder(\n    $iamToken,\n    $folder['id'],\n    $userId,\n    'ai.languageModels.user',\n    'userAccount'  // or 'serviceAccount'\n);\n\n// Assign role to cloud\n$authManager-\u003eassignRoleToCloud(\n    $iamToken,\n    'cloud_id',\n    $userId,\n    'editor',\n    'userAccount'\n);\n```\n\n---\n\n## Available Models\n\n| Model            | Constant                          | Context | Use case                      |\n|------------------|-----------------------------------|---------|-------------------------------|\n| `yandexgpt-lite` | `YandexGPTModel::YANDEX_GPT_LITE` | 32K     | Simple queries, chatbots, FAQ |\n| `yandexgpt`      | `YandexGPTModel::YANDEX_GPT`      | 32K     | Content, analysis, reasoning  |\n| `aliceai-llm`    | `YandexGPTModel::ALICE_AI`        | 32K     | Dialogues, assistants         |\n\nFull list: [Generation models in Yandex AI Studio](https://yandex.cloud/en/docs/ai-studio/concepts/generation/models)\n\n```php\n$models = YandexGPT::getAvailableModels();\n$descriptions = YandexGPT::getModelDescriptions();\n```\n\n---\n\n## Generation parameters\n\n```php\n$options = [\n    'completionOptions' =\u003e [\n        'stream' =\u003e false,           // Streaming (not yet supported)\n        'temperature' =\u003e 0.6,        // Creativity (0.0 - 1.0)\n        'maxTokens' =\u003e 2000         // Maximum number of tokens\n    ]\n];\n\n$response = YandexGPT::generateText('Your request', 'yandexgpt-lite', $options);\n```\n\n### Reasoning Mode\n\nReasoning mode allows the model to break down tasks into steps and perform sequential chains of computations to improve\nanswer accuracy. This mode is especially useful for tasks requiring logical reasoning.\n\nDocumentation: [Reasoning mode in generative models](https://yandex.cloud/en/docs/ai-studio/concepts/generation/chain-of-thought)\n\n**Available modes:**\n\n- `DISABLED` - reasoning mode is disabled (default)\n- `ENABLED_HIDDEN` - reasoning mode is enabled, but the reasoning chain is not returned in the response\n\n**Effort levels:**\n\n- `low` - priority on speed and token economy\n- `medium` - balance between speed and reasoning accuracy\n- `high` - priority on more complete and thorough reasoning\n\n#### Using ReasoningOptions object\n\n```php\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\nuse Tigusigalpa\\YandexGPT\\Models\\ReasoningOptions;\n\n// Enable reasoning mode with low effort level\n$response = YandexGPT::generateText(\n    'Solve the problem: if there are 5 apples and 3 pears in a basket, how many fruits are there in total?',\n    YandexGPTModel::YANDEX_GPT,\n    [\n        'reasoningOptions' =\u003e ReasoningOptions::enabledHidden(ReasoningOptions::EFFORT_LOW)\n    ]\n);\n\n// Enable reasoning mode with high effort level\n$response = YandexGPT::generateText(\n    'Explain quantum entanglement in simple terms',\n    YandexGPTModel::YANDEX_GPT,\n    [\n        'reasoningOptions' =\u003e ReasoningOptions::enabledHidden(ReasoningOptions::EFFORT_HIGH)\n    ]\n);\n\n// Disable reasoning mode (explicitly)\n$response = YandexGPT::generateText(\n    'Hello, how are you?',\n    YandexGPTModel::YANDEX_GPT,\n    [\n        'reasoningOptions' =\u003e ReasoningOptions::disabled()\n    ]\n);\n```\n\n#### Using array\n\n```php\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\n\n// Enable reasoning mode\n$response = YandexGPT::generateText(\n    'What are the advantages of using Docker in development?',\n    YandexGPTModel::YANDEX_GPT,\n    [\n        'reasoningOptions' =\u003e [\n            'mode' =\u003e 'ENABLED_HIDDEN',\n            'effort' =\u003e 'medium'\n        ]\n    ]\n);\n\n// Mode only, without specifying effort level\n$response = YandexGPT::generateText(\n    'Write a bubble sort algorithm',\n    YandexGPTModel::YANDEX_GPT,\n    [\n        'reasoningOptions' =\u003e [\n            'mode' =\u003e 'ENABLED_HIDDEN'\n        ]\n    ]\n);\n```\n\n#### Using with dialogs\n\n```php\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\nuse Tigusigalpa\\YandexGPT\\Models\\ReasoningOptions;\n\n$messages = [\n    [\n        'role' =\u003e 'system',\n        'text' =\u003e 'You are a math assistant'\n    ],\n    [\n        'role' =\u003e 'user',\n        'text' =\u003e 'Solve the equation: 2x + 5 = 15'\n    ]\n];\n\n$response = YandexGPT::generateFromMessages(\n    $messages,\n    YandexGPTModel::YANDEX_GPT,\n    [\n        'reasoningOptions' =\u003e ReasoningOptions::enabledHidden(ReasoningOptions::EFFORT_MEDIUM),\n        'completionOptions' =\u003e [\n            'temperature' =\u003e 0.3,\n            'maxTokens' =\u003e 1000\n        ]\n    ]\n);\n```\n\n#### Checking reasoning token usage\n\nWhen using reasoning mode, the response may contain information about the number of tokens used for reasoning:\n\n```php\n$response = YandexGPT::generateText(\n    'Complex mathematical problem...',\n    YandexGPTModel::YANDEX_GPT,\n    [\n        'reasoningOptions' =\u003e ReasoningOptions::enabledHidden(ReasoningOptions::EFFORT_HIGH)\n    ]\n);\n\n// Check reasoning tokens\nif (isset($response['result']['alternatives'][0]['reasoningTokens'])) {\n    $reasoningTokens = $response['result']['alternatives'][0]['reasoningTokens'];\n    echo \"Reasoning tokens used: {$reasoningTokens}\\n\";\n}\n\necho $response['result']['alternatives'][0]['message']['text'];\n```\n\n**Note:** Reasoning mode is available for the YandexGPT Pro model and may increase the total number of request tokens.\n\n---\n\n## Error handling\n\n```php\n\u003c?php\n\nuse Tigusigalpa\\YandexGPT\\Exceptions\\AuthenticationException;\nuse Tigusigalpa\\YandexGPT\\Exceptions\\ApiException;\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\n\ntry {\n    $response = YandexGPT::generateText('Hello!');\n} catch (AuthenticationException $e) {\n    // Authentication errors (invalid token, access rights)\n    Log::error('YandexGPT Auth Error: ' . $e-\u003egetMessage());\n} catch (ApiException $e) {\n    // API errors (invalid parameters, limits)\n    Log::error('YandexGPT API Error: ' . $e-\u003egetMessage());\n} catch (Exception $e) {\n    // Other errors\n    Log::error('YandexGPT Error: ' . $e-\u003egetMessage());\n}\n```\n\n---\n\n## Configuration file\n\nFull configuration file `config/yandexgpt.php`:\n\n```php\n\u003c?php\n\nreturn [\n    // OAuth token\n    'oauth_token' =\u003e env('YANDEX_GPT_OAUTH_TOKEN'),\n    \n    // Folder ID\n    'folder_id' =\u003e env('YANDEX_GPT_FOLDER_ID'),\n    \n    // Default model\n    'default_model' =\u003e env('YANDEX_GPT_DEFAULT_MODEL', 'yandexgpt-lite'),\n    \n    // Default parameters\n    'default_options' =\u003e [\n        'temperature' =\u003e (float) env('YANDEX_GPT_TEMPERATURE', 0.6),\n        'maxTokens' =\u003e (int) env('YANDEX_GPT_MAX_TOKENS', 2000),\n        'stream' =\u003e false,\n    ],\n    \n    // HTTP client settings\n    'http_options' =\u003e [\n        'timeout' =\u003e (int) env('YANDEX_GPT_TIMEOUT', 30),\n        'connect_timeout' =\u003e (int) env('YANDEX_GPT_CONNECT_TIMEOUT', 10),\n    ],\n];\n```\n\n---\n\n## Examples\n\n#### 1. Laravel Chatbot with Conversation History\n\n```php\n\u003c?php\n\nnamespace App\\Http\\Controllers;\n\nuse Illuminate\\Http\\Request;\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\n\nclass ChatBotController extends Controller\n{\n    public function chat(Request $request)\n    {\n        $request-\u003evalidate([\n            'message' =\u003e 'required|string|max:1000',\n            'history' =\u003e 'array'\n        ]);\n\n        $messages = $request-\u003einput('history', []);\n        $messages[] = [\n            'role' =\u003e 'user',\n            'text' =\u003e $request-\u003einput('message')\n        ];\n\n        try {\n            $response = YandexGPT::generateFromMessages(\n                $messages,\n                YandexGPTModel::YANDEX_GPT_LITE\n            );\n\n            $botResponse = $response['result']['alternatives'][0]['message']['text'];\n            \n            $messages[] = [\n                'role' =\u003e 'assistant',\n                'text' =\u003e $botResponse\n            ];\n\n            return response()-\u003ejson([\n                'success' =\u003e true,\n                'response' =\u003e $botResponse,\n                'history' =\u003e $messages\n            ]);\n\n        } catch (\\Exception $e) {\n            return response()-\u003ejson([\n                'success' =\u003e false,\n                'error' =\u003e 'An error occurred while generating the response'\n            ], 500);\n        }\n    }\n}\n```\n\n#### 2. SEO-Optimized Content Generation\n\n```php\n\u003c?php\n\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\n\nclass ContentGenerator\n{\n    public function generateArticle(string $topic, int $length = 1000): string\n    {\n        $prompt = \"Write an article on the topic '{$topic}'. The article should be approximately {$length} words long. Include an introduction, main body, and conclusion.\";\n\n        $response = YandexGPT::generateText(\n            $prompt,\n            YandexGPTModel::YANDEX_GPT,\n            [\n                'completionOptions' =\u003e [\n                    'temperature' =\u003e 0.7,\n                    'maxTokens' =\u003e $length * 2 // Approximately 2 tokens per word\n                ]\n            ]\n        );\n\n        return $response['result']['alternatives'][0]['message']['text'];\n    }\n\n    public function generateSEODescription(string $content): string\n    {\n        $prompt = \"Create an SEO description (meta description) for the following content. The description should be up to 160 characters:\\n\\n{$content}\";\n\n        $response = YandexGPT::generateText($prompt, YandexGPTModel::YANDEX_GPT_LITE);\n\n        return $response['result']['alternatives'][0]['message']['text'];\n    }\n\n    public function generateProductDescription(array $productData): string\n    {\n        $prompt = \"Create an attractive product description for an online store:\\n\";\n        $prompt .= \"Name: {$productData['name']}\\n\";\n        $prompt .= \"Features: \" . implode(', ', $productData['features']) . \"\\n\";\n        $prompt .= \"The description should be SEO-optimized, contain keywords and a call to action.\";\n\n        $response = YandexGPT::generateText(\n            $prompt,\n            YandexGPTModel::YANDEX_GPT,\n            [\n                'completionOptions' =\u003e [\n                    'temperature' =\u003e 0.6,\n                    'maxTokens' =\u003e 500\n                ]\n            ]\n        );\n\n        return $response['result']['alternatives'][0]['message']['text'];\n    }\n\n    public function generateBlogPost(string $topic, array $keywords): array\n    {\n        $keywordsList = implode(', ', $keywords);\n        $prompt = \"Write an SEO-optimized blog article on the topic: '{$topic}'.\\n\";\n        $prompt .= \"Be sure to use keywords: {$keywordsList}.\\n\";\n        $prompt .= \"Structure: H1 title, introduction, 3-4 H2 subheadings with content, conclusion.\\n\";\n        $prompt .= \"Length: 1500-2000 words.\";\n\n        $response = YandexGPT::generateText(\n            $prompt,\n            YandexGPTModel::YANDEX_GPT,\n            [\n                'completionOptions' =\u003e [\n                    'temperature' =\u003e 0.7,\n                    'maxTokens' =\u003e 3000\n                ],\n                'reasoningOptions' =\u003e ReasoningOptions::enabledHidden(ReasoningOptions::EFFORT_MEDIUM)\n            ]\n        );\n\n        $content = $response['result']['alternatives'][0]['message']['text'];\n        $metaDescription = $this-\u003egenerateSEODescription($content);\n\n        return [\n            'content' =\u003e $content,\n            'meta_description' =\u003e $metaDescription,\n            'keywords' =\u003e $keywords\n        ];\n    }\n}\n```\n\n#### 3. Customer Support Automation\n\n```php\n\u003c?php\n\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\n\nclass CustomerSupportBot\n{\n    private array $knowledgeBase;\n\n    public function __construct()\n    {\n        $this-\u003eknowledgeBase = [\n            'Information about company, products, services, return policies, etc.'\n        ];\n    }\n\n    public function answerQuestion(string $question, array $conversationHistory = []): string\n    {\n        $systemPrompt = \"You are a support assistant. Use the following knowledge base for answers:\\n\";\n        $systemPrompt .= implode(\"\\n\", $this-\u003eknowledgeBase);\n\n        $messages = [\n            ['role' =\u003e 'system', 'text' =\u003e $systemPrompt],\n            ...$conversationHistory,\n            ['role' =\u003e 'user', 'text' =\u003e $question]\n        ];\n\n        $response = YandexGPT::generateFromMessages(\n            $messages,\n            YandexGPTModel::ALICE_AI,\n            [\n                'completionOptions' =\u003e [\n                    'temperature' =\u003e 0.5,\n                    'maxTokens' =\u003e 1000\n                ]\n            ]\n        );\n\n        return $response['result']['alternatives'][0]['message']['text'];\n    }\n}\n```\n\n#### 4. Sentiment Analysis and Review Processing\n\n```php\n\u003c?php\n\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\n\nclass ReviewAnalyzer\n{\n    public function analyzeSentiment(string $review): array\n    {\n        $prompt = \"Analyze the sentiment of the following review and return the result in JSON format:\\n\";\n        $prompt .= \"Review: {$review}\\n\\n\";\n        $prompt .= \"Response format: {\\\"sentiment\\\": \\\"positive/negative/neutral\\\", \\\"score\\\": 0-10, \\\"key_points\\\": [\\\"point1\\\", \\\"point2\\\"]}\";\n\n        $response = YandexGPT::generateText(\n            $prompt,\n            YandexGPTModel::YANDEX_GPT,\n            [\n                'completionOptions' =\u003e [\n                    'temperature' =\u003e 0.3,\n                    'maxTokens' =\u003e 500\n                ]\n            ]\n        );\n\n        $result = $response['result']['alternatives'][0]['message']['text'];\n        return json_decode($result, true) ?? [];\n    }\n\n    public function generateResponse(string $review, string $sentiment): string\n    {\n        $prompt = \"Generate a professional response to a customer review (sentiment: {$sentiment}):\\n{$review}\";\n\n        $response = YandexGPT::generateText(\n            $prompt,\n            YandexGPTModel::YANDEX_GPT,\n            [\n                'completionOptions' =\u003e [\n                    'temperature' =\u003e 0.7,\n                    'maxTokens' =\u003e 300\n                ]\n            ]\n        );\n\n        return $response['result']['alternatives'][0]['message']['text'];\n    }\n}\n```\n\n#### 5. Content Image Generation\n\n```php\n\u003c?php\n\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\n\nclass ContentImageGenerator\n{\n    public function generateArticleImage(string $articleTitle, string $articleSummary): string\n    {\n        // First, generate an optimal prompt for the image\n        $promptGeneration = \"Create a detailed prompt for generating an image for an article:\\n\";\n        $promptGeneration .= \"Title: {$articleTitle}\\n\";\n        $promptGeneration .= \"Summary: {$articleSummary}\\n\";\n        $promptGeneration .= \"The prompt should describe the visual concept, style, color palette.\";\n\n        $textResponse = YandexGPT::generateText(\n            $promptGeneration,\n            YandexGPTModel::YANDEX_GPT_LITE\n        );\n\n        $imagePrompt = $textResponse['result']['alternatives'][0]['message']['text'];\n\n        // Generate the image\n        $result = YandexGPT::generateImage($imagePrompt);\n        \n        // Save the image\n        $filename = 'article_' . time() . '.jpg';\n        $path = storage_path('app/public/images/' . $filename);\n        file_put_contents($path, base64_decode($result['image_base64']));\n\n        return $filename;\n    }\n}\n```\n\n---\n\n## Testing\n\n```bash\ncomposer install\ncomposer test\ncomposer test-coverage\n```\n\n---\n\n## Troubleshooting\n\n**\"Class 'YandexGPTClient' not found\"** — `composer show tigusigalpa/yandexgpt-php`, then `composer dump-autoload`.\n\n**\"OAuth token not configured\"** — check `YANDEX_GPT_OAUTH_TOKEN` in `.env`, then `php artisan config:clear`.\n\n**401 Unauthorized** — check your OAuth token (valid for 1 year) and folder access rights.\n\n**403 Forbidden** — the user must have the `ai.languageModels.user` role on the folder.\n\n**Connection timeout** — increase `timeout` in `config/yandexgpt.php`.\n\n---\n\n## Conversations API\n\nThe SDK supports the Conversations API for managing conversations and their items on the Yandex Cloud server side.\n\nDocumentation: [REST: Conversations](https://yandex.cloud/ru/docs/ai-studio/conversations/)\n\n### Available Methods\n\n| Method          | Description                         |\n|-----------------|-------------------------------------|\n| `create()`      | Create a new conversation           |\n| `get()`         | Retrieve a conversation by ID       |\n| `update()`      | Update conversation metadata        |\n| `delete()`      | Delete a conversation               |\n| `createItems()` | Add items to a conversation         |\n| `listItems()`   | List conversation items             |\n| `getItem()`     | Retrieve a single conversation item |\n| `deleteItem()`  | Delete an item from a conversation  |\n\n### Managing Conversations\n\n```php\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\n\n$client = new YandexGPTClient('your_oauth_token', 'your_folder_id');\n\n// Create a conversation with metadata\n$conversation = $client-\u003econversations()-\u003ecreate([\n    'title' =\u003e 'Technical Support',\n    'user_id' =\u003e '12345',\n]);\n\n$conversationId = $conversation['id'];\necho \"Conversation ID: \" . $conversationId . \"\\n\";\necho \"Created at: \" . $conversation['created_at'] . \"\\n\";\n\n// Retrieve a conversation\n$conversation = $client-\u003econversations()-\u003eget($conversationId);\n\n// Update conversation metadata\n$conversation = $client-\u003econversations()-\u003eupdate($conversationId, [\n    'title' =\u003e 'Updated Title',\n    'status' =\u003e 'active',\n]);\n\n// Delete a conversation\n$result = $client-\u003econversations()-\u003edelete($conversationId);\n// $result['deleted'] === true\n```\n\n### Managing Conversation Items\n\n```php\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\n\n$client = new YandexGPTClient('your_oauth_token', 'your_folder_id');\n$conversationId = 'conv_123';\n\n// Add items to a conversation\n$items = $client-\u003econversations()-\u003ecreateItems($conversationId, [\n    [\n        'type' =\u003e 'message',\n        'role' =\u003e 'user',\n        'content' =\u003e [['type' =\u003e 'input_text', 'text' =\u003e 'Hello! How are you?']],\n    ],\n    [\n        'type' =\u003e 'message',\n        'role' =\u003e 'assistant',\n        'content' =\u003e [['type' =\u003e 'output_text', 'text' =\u003e 'Hi! I am doing great, how can I help?']],\n    ],\n]);\n\n// List items (with pagination)\n$items = $client-\u003econversations()-\u003elistItems($conversationId, 20, 'asc');\nforeach ($items['data'] as $item) {\n    echo $item['role'] . ': ' . ($item['content'][0]['text'] ?? '') . \"\\n\";\n}\n\n// Pagination: get the next page\nif ($items['has_more']) {\n    $nextPage = $client-\u003econversations()-\u003elistItems(\n        $conversationId,\n        20,\n        'asc',\n        $items['last_id']\n    );\n}\n\n// Retrieve a single item\n$item = $client-\u003econversations()-\u003egetItem($conversationId, 'item_123');\n\n// Delete an item\n$client-\u003econversations()-\u003edeleteItem($conversationId, 'item_123');\n```\n\n### Using via Laravel Facade\n\n```php\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\n\n// Create a conversation\n$conversation = YandexGPT::conversations()-\u003ecreate(['title' =\u003e 'New Conversation']);\n\n// Add messages\nYandexGPT::conversations()-\u003ecreateItems($conversation['id'], [\n    [\n        'type' =\u003e 'message',\n        'role' =\u003e 'user',\n        'content' =\u003e [['type' =\u003e 'input_text', 'text' =\u003e 'User question']],\n    ],\n]);\n\n// Get history\n$history = YandexGPT::conversations()-\u003elistItems($conversation['id'], 50, 'asc');\n```\n\n---\n\n## Image Generation (YandexART)\n\n\u003cimg src=\"https://github.com/user-attachments/assets/e9fdb285-e575-40ef-b240-824a990e097f\" alt=\"YandexART Hero Image\"\u003e\n\n\u003e Resources:\n\u003e - Documentation: https://yandex.cloud/en/docs/ai-studio/quickstart/yandexart\n\u003e - [Request documentation](https://yandex.cloud/en/docs/ai-studio/operations/generation/yandexart-request#generate-text)\n\u003e - Website: https://ya.ru/ai/papers/paper-yaart-v1\n\nThe SDK supports image generation using YandexART. There are three methods available:\n\n- **generateImageAsync** — submit a generation request and receive an Operation object\n- **getOperation** — check the operation status by its ID\n- **generateImage** — synchronous wrapper that waits for the result\n\nAccess requirements:\n\n- You must assign the `ai.imageGeneration.user` role to the Folder where image generation will be performed\n- For text models, the `ai.languageModels.user` role is also required\n\nYandexART model:\n\n- Uses `yandex-art/latest` with URI `art://\u003cfolder_id\u003e/yandex-art/latest`\n\nUsage examples\n\n1) Basic asynchronous generation:\n\n```php\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\n\n$client = new YandexGPTClient(env('YANDEX_GPT_OAUTH_TOKEN'), env('YANDEX_GPT_FOLDER_ID'));\n\n// Prompt string or an array of messages (see format below)\n$operation = $client-\u003egenerateImageAsync('Rocky sea shore at sunset, painting style');\n$operationId = $operation['id'];\n\n// Check operation status\n$op = $client-\u003egetOperation($operationId);\nif (!empty($op['done']) \u0026\u0026 empty($op['error'])) {\n    $imageBase64 = $op['response']['image'] ?? null;\n    if ($imageBase64) {\n        file_put_contents('art.jpg', base64_decode($imageBase64));\n    }\n}\n```\n\n2) Synchronous generation with result waiting:\n\n```php\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\n\n$client = new YandexGPTClient(env('YANDEX_GPT_OAUTH_TOKEN'), env('YANDEX_GPT_FOLDER_ID'));\n\n$result = $client-\u003egenerateImage('Futuristic city at night, neon lights');\nfile_put_contents('city.jpg', base64_decode($result['image_base64']));\necho '\u003cimg src=\"data:image/png;base64,'.$response['image_base64'].'\"\u003e';\n```\n\n### Example of a generated image of Omsk\n\n![Omsk city](https://github.com/user-attachments/assets/96b69b45-0d3d-4c17-90c8-e08ace4c7f59)\n\n3) Using Laravel Facade:\n\n```php\nuse Tigusigalpa\\YandexGPT\\Laravel\\Facades\\YandexGPT;\n\n$result = YandexGPT::generateImage('Cozy cabin by the lake in winter, watercolor style');\nfile_put_contents('lake.jpg', base64_decode($result['image_base64']));\necho '\u003cimg src=\"data:image/png;base64,'.$response['image_base64'].'\"\u003e';\n```\n\n4) Prompt chaining (YandexGPT → YandexART):\n\n```php\nuse Tigusigalpa\\YandexGPT\\YandexGPTClient;\nuse Tigusigalpa\\YandexGPT\\Models\\YandexGPTModel;\n\n$client = new YandexGPTClient(env('YANDEX_GPT_OAUTH_TOKEN'), env('YANDEX_GPT_FOLDER_ID'));\n\n// First, generate a text prompt with YandexGPT\n$textResponse = $client-\u003egenerateText(\n    \"Generate a concise, detailed prompt for an image in digital painting style on the theme: 'Flight over the Alpine mountains'. Specify the style, color palette, and key details.\",\n    YandexGPTModel::YANDEX_GPT_LITE\n);\n\n$generatedPrompt = $textResponse['result']['alternatives'][0]['message']['text'] ?? null;\n\n// Then pass the resulting prompt to YandexART\nif ($generatedPrompt) {\n    $result = $client-\u003egenerateImage($generatedPrompt);\n    file_put_contents('alps.jpg', base64_decode($result['image_base64']));\n}\n```\n\nMessage format for YandexART\n\nThe method accepts either a string (single prompt) or an array of messages.\nEach message can be:\n\n- a string: 'scene description'\n- an array: ['text' =\u003e 'description', 'weight' =\u003e 1]\n\nExample of a messages array:\n\n```php\n$messages = [\n    ['text' =\u003e 'Mountains at sunrise', 'weight' =\u003e 1],\n    ['text' =\u003e 'a lake in the foreground', 'weight' =\u003e 1],\n    ['text' =\u003e 'impressionism style', 'weight' =\u003e 1],\n];\n$operation = $client-\u003egenerateImageAsync($messages);\n```\n\ngenerationOptions parameters\n\nThe generationOptions parameter (optional) allows you to set generation settings.\nThe list of available options depends on the YandexART API. Example options:\n\n```php\n$generationOptions = [\n    // Example: specify image type and size (check the docs for up-to-date keys)\n    // @link https://yandex.cloud/en/docs/ai-studio/quickstart/yandexart#generate-image\n    // 'mimeType' =\u003e 'image/jpeg',\n    // 'size' =\u003e ['width' =\u003e 1024, 'height' =\u003e 1024],\n    // 'aspectRatio' =\u003e ['widthRatio' =\u003e 16, 'heightRatio' =\u003e 9],\n    // 'seed' =\u003e 1863,\n];\n$operation = $client-\u003egenerateImageAsync('Scene description', $generationOptions);\n```\n\nError handling\n\nMethods may throw ApiException and AuthenticationException.\nCheck the error field in the operation response and the presence of response.image when completed successfully.\n\n---\n\n## Requirements\n\n- PHP 8.0 or higher\n- Laravel 8.0 or higher (for Laravel integration)\n- Guzzle HTTP 7.0 or higher\n\n---\n\n## License\n\nThis package is distributed under the MIT license. See the [LICENSE](LICENSE) file for details.\n\n---\n\n## Links\n\n- [Wiki — Documentation \u0026 Guides](https://github.com/tigusigalpa/yandexgpt-php/wiki)\n- [YandexGPT API Documentation](https://yandex.cloud/en/docs/foundation-models/)\n- [Quickstart](https://yandex.cloud/en/docs/foundation-models/quickstart/yandexgpt)\n- [List of models](https://yandex.cloud/en/docs/ai-studio/concepts/generation/models)\n\n---\n\n## Contributing\n\nWe welcome contributions! Please see the [contribution guide](CONTRIBUTING.md).\n\n---\n\n## Security\n\nIf you discover a security vulnerability, please send an email to sovletig@gmail.com instead of creating an issue.\n\n---\n\n## Author\n\n[Igor Sazonov](https://github.com/tigusigalpa) — sovletig@gmail.com\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigusigalpa%2Fyandexgpt-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftigusigalpa%2Fyandexgpt-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftigusigalpa%2Fyandexgpt-php/lists"}