{"id":29111906,"url":"https://github.com/utopia-php/agents","last_synced_at":"2026-02-24T08:47:58.833Z","repository":{"id":281928181,"uuid":"946535881","full_name":"utopia-php/agents","owner":"utopia-php","description":"Lite \u0026 fast micro PHP AI agents library that is **easy to use**.","archived":false,"fork":false,"pushed_at":"2026-02-19T08:42:42.000Z","size":196,"stargazers_count":8,"open_issues_count":1,"forks_count":0,"subscribers_count":6,"default_branch":"main","last_synced_at":"2026-02-19T13:57:23.947Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/utopia-php.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"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-03-11T09:45:02.000Z","updated_at":"2026-02-19T08:42:27.000Z","dependencies_parsed_at":null,"dependency_job_id":"28d1055a-80b9-421e-a54c-9eaefc647672","html_url":"https://github.com/utopia-php/agents","commit_stats":null,"previous_names":["eldadfux/agents","utopia-php/agents"],"tags_count":18,"template":false,"template_full_name":null,"purl":"pkg:github/utopia-php/agents","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fagents","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fagents/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fagents/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fagents/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/utopia-php","download_url":"https://codeload.github.com/utopia-php/agents/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/utopia-php%2Fagents/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29776982,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-02-24T04:54:30.205Z","status":"ssl_error","status_checked_at":"2026-02-24T04:53:58.628Z","response_time":75,"last_error":"SSL_read: 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":[],"created_at":"2025-06-29T10:02:20.064Z","updated_at":"2026-02-24T08:47:58.806Z","avatar_url":"https://github.com/utopia-php.png","language":"PHP","funding_links":[],"categories":["LLMs \u0026 AI APIs"],"sub_categories":["Recommended core stack"],"readme":"# Utopia Agents\n\n[![Build Status](https://travis-ci.org/utopia-php/agents.svg?branch=master)](https://travis-ci.org/utopia-php/agents)\n![Total Downloads](https://img.shields.io/packagist/dt/utopia-php/agents.svg)\n[![Discord](https://img.shields.io/discord/564160730845151244?label=discord)](https://appwrite.io/discord)\n\nUtopia Agents is a simple and lite library for building and managing AI agents in PHP applications. This library provides a collection of tools and utilities for creating, managing, and orchestrating AI agents with support for multiple AI providers. This library is maintained by the [Appwrite team](https://appwrite.io).\n\nAlthough this library is part of the [Utopia Framework](https://github.com/utopia-php/framework) project it is dependency free and can be used as standalone with any other PHP project or framework.\n\n## Getting Started\n\nInstall using composer:\n```bash\ncomposer require utopia-php/agents\n```\n\n## System Requirements\n\nUtopia Framework requires PHP 8.0 or later. We recommend using the latest PHP version whenever possible.\n\n## Features\n\n- **Multiple AI Providers** - Support for OpenAI, Anthropic, Deepseek, Perplexity, and XAI APIs\n- **Flexible Message Types** - Support for text and structured content in messages\n- **Conversation Management** - Easy-to-use conversation handling between agents and users\n- **Model Selection** - Choose from various AI models (GPT-4, Claude 3, Deepseek Chat, Sonar, Grok, etc.)\n- **Parameter Control** - Fine-tune model behavior with temperature and token controls\n\n## Usage\n\n### Basic Example\n\n```php\n\u003c?php\n\nuse Utopia\\Agents\\Agent;\nuse Utopia\\Agents\\Roles\\User;\nuse Utopia\\Agents\\Messages\\Text;\nuse Utopia\\Agents\\Conversation;\nuse Utopia\\Agents\\Adapters\\OpenAI;\n\n// Create an agent with OpenAI\n$adapter = new OpenAI('your-api-key', OpenAI::MODEL_GPT_4_TURBO);\n$agent = new Agent($adapter);\n\n// Create a user\n$user = new User('user-1', 'John');\n\n// Start a conversation\n$conversation = new Conversation($agent);\n$conversation\n    -\u003emessage($user, new Text('What is artificial intelligence?'))\n    -\u003esend();\n```\n\n### Using Different AI Providers\n\n#### OpenAI\n\n```php\nuse Utopia\\Agents\\Adapters\\OpenAI;\n\n$openai = new OpenAI(\n    apiKey: 'your-api-key',\n    model: OpenAI::MODEL_GPT_4_TURBO,\n    maxTokens: 2048,\n    temperature: 0.7\n);\n```\n\nAvailable OpenAI Models:\n- `MODEL_GPT_5_NANO`: GPT-5 Nano - Small GPT-5 variant optimized for low latency and cost-sensitive workloads\n- `MODEL_GPT_4_5_PREVIEW`: GPT-4.5 Preview - OpenAI's most advanced model with enhanced reasoning, broader knowledge, and improved instruction following\n- `MODEL_GPT_4_1`: GPT-4.1 - Advanced large language model with strong reasoning capabilities and improved context handling\n- `MODEL_GPT_4O`: GPT-4o - Multimodal model optimized for both text and image processing with faster response times\n- `MODEL_O4_MINI`: o4-mini - Compact version of GPT-4o offering good performance with higher throughput and lower latency\n- `MODEL_O3`: o3 - Balanced model offering good performance for general language tasks with efficient resource usage\n- `MODEL_O3_MINI`: o3-mini - Streamlined model optimized for speed and efficiency while maintaining good capabilities for routine tasks\n\n#### Anthropic\n\n```php\nuse Utopia\\Agents\\Adapters\\Anthropic;\n\n$anthropic = new Anthropic(\n    apiKey: 'your-api-key',\n    model: Anthropic::MODEL_CLAUDE_3_HAIKU,\n    maxTokens: 2048,\n    temperature: 0.7\n);\n```\n\nAvailable Anthropic Models:\n- `MODEL_CLAUDE_4_OPUS`: Flagship model with exceptional reasoning for the most demanding tasks\n- `MODEL_CLAUDE_3_OPUS`: Premium model with superior performance on complex analysis and creative work\n- `MODEL_CLAUDE_4_SONNET`: Intelligent and responsive model optimized for productivity workflows\n- `MODEL_CLAUDE_3_7_SONNET`: Enhanced model with improved reasoning and coding capabilities\n- `MODEL_CLAUDE_3_5_SONNET`: Versatile model balancing capability and speed for general use\n- `MODEL_CLAUDE_3_5_HAIKU`: Ultra-fast model for quick responses and lightweight processing\n- `MODEL_CLAUDE_3_HAIKU`: Rapid model designed for speed and efficiency on straightforward tasks\n\n#### Deepseek\n\n```php\nuse Utopia\\Agents\\Adapters\\Deepseek;\n\n$deepseek = new Deepseek(\n    apiKey: 'your-api-key',\n    model: Deepseek::MODEL_DEEPSEEK_CHAT,\n    maxTokens: 2048,\n    temperature: 0.7\n);\n```\n\nAvailable Deepseek Models:\n- `MODEL_DEEPSEEK_CHAT`: General-purpose chat model\n- `MODEL_DEEPSEEK_CODER`: Specialized for code-related tasks\n\n#### Perplexity\n\n```php\nuse Utopia\\Agents\\Adapters\\Perplexity;\n\n$perplexity = new Perplexity(\n    apiKey: 'your-api-key',\n    model: Perplexity::MODEL_SONAR,\n    maxTokens: 2048,\n    temperature: 0.7\n);\n```\n\nAvailable Perplexity Models:\n- `MODEL_SONAR`: General-purpose search model\n- `MODEL_SONAR_PRO`: Enhanced search model\n- `MODEL_SONAR_DEEP_RESEARCH`: Advanced search model\n- `MODEL_SONAR_REASONING`: Reasoning model\n- `MODEL_SONAR_REASONING_PRO`: Enhanced reasoning model\n\n#### XAI\n\n```php\nuse Utopia\\Agents\\Adapters\\XAI;\n\n$xai = new XAI(\n    apiKey: 'your-api-key',\n    model: XAI::MODEL_GROK_3_MINI,\n    maxTokens: 2048,\n    temperature: 0.7\n);\n```\n\nAvailable XAI Models:\n- `MODEL_GROK_3`: Latest Grok model\n- `MODEL_GROK_3_MINI`: Mini version of Grok model\n- `MODEL_GROK_2_IMAGE`: Latest Grok model with image support\n\n### Managing Conversations\n\n```php\nuse Utopia\\Agents\\Roles\\User;\nuse Utopia\\Agents\\Roles\\Assistant;\nuse Utopia\\Agents\\Messages\\Text;\n\n// Create a conversation with system instructions\n$agent = new Agent($adapter);\n$agent-\u003esetInstructions([\n    'description' =\u003e 'You are a helpful assistant that can answer questions and help with tasks.',\n    'tone' =\u003e 'friendly and helpful',\n]);\n\n// Initialize roles\n$user = new User('user-1'); \n$assistant = new Assistant('assistant-1');\n\n$conversation = new Conversation($agent);\n$conversation\n    -\u003emessage($user, new Text('Hello!'))\n    -\u003emessage($assistant, new Text('Hi! How can I help you today?'))\n    -\u003emessage($user, new Text('What is the capital of France?'));\n\n// Send and get response\n$response = $conversation-\u003esend();\n```\n\n### Working with Messages\n\n```php\nuse Utopia\\Agents\\Messages\\Text;\nuse Utopia\\Agents\\Messages\\Image;\n\n// Text message\n$textMessage = new Text('Hello, how are you?');\n\n// Image message\n$imageMessage = new Image($imageBinaryContent);\n$mimeType = $imageMessage-\u003egetMimeType(); // Get the MIME type of the image\n```\n\n## Schema and Schema Objects\n\nYou can use the `Schema` class to define a schema for a structured output. The `Schema` class utilizes `SchemaObject`s to define each property of the schema, following the [JSON Schema](https://json-schema.org/) format.\n\n```php\nuse Utopia\\Agents\\Schema\\Schema;\nuse Utopia\\Agents\\Schema\\SchemaObject;\n\n$object = new SchemaObject();\n$object-\u003eaddProperty('location', [\n    'type' =\u003e SchemaObject::TYPE_STRING,\n    'description' =\u003e 'The city and state, e.g. San Francisco, CA',\n]);\n\n$schema = new Schema(\n    name: 'get_weather',\n    description: 'Get the current weather in a given location in well structured JSON',\n    object: $object,\n    required: $object-\u003egetNames()\n);\n\n$agent-\u003esetSchema($schema);\n```\n\n## Tests\n\nTo run all unit tests, use the following Docker command:\n\n```bash\ndocker compose exec tests vendor/bin/phpunit --configuration phpunit.xml tests\n```\n\nTo run static code analysis, use the following Psalm command:\n\n```bash\ndocker compose exec tests vendor/bin/psalm --show-info=true\n```\n\n## Security\n\nWe take security seriously. If you discover any security-related issues, please email security@appwrite.io instead of using the issue tracker.\n\n## Contributing\n\nAll code contributions - including those of people having commit access - must go through a pull request and be approved by a core developer before being merged. This is to ensure a proper review of all the code.\n\nWe truly ❤️ pull requests! If you wish to help, you can learn more about how you can contribute to this project in the [contribution guide](CONTRIBUTING.md).\n\n## Copyright and license\n\nThe MIT License (MIT) [http://www.opensource.org/licenses/mit-license.php](http://www.opensource.org/licenses/mit-license.php) \n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fagents","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Futopia-php%2Fagents","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Futopia-php%2Fagents/lists"}