{"id":36274500,"url":"https://github.com/droath/nextus-ai","last_synced_at":"2026-01-13T23:03:39.204Z","repository":{"id":321712318,"uuid":"1086889354","full_name":"droath/nextus-ai","owner":"droath","description":"Nextus AI is a unified Laravel client library for multiple LLM providers (OpenAI, Anthropic, Perplexity), providing seamless backend integration for AI-powered applications.","archived":false,"fork":false,"pushed_at":"2025-11-02T19:55:19.000Z","size":149,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-01-11T13:38:23.828Z","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/droath.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE.md","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},"funding":{"github":"Droath"}},"created_at":"2025-10-31T04:02:29.000Z","updated_at":"2025-11-02T20:59:25.000Z","dependencies_parsed_at":"2025-10-31T05:41:34.837Z","dependency_job_id":"07b09065-7588-41b7-b059-acb1efbca358","html_url":"https://github.com/droath/nextus-ai","commit_stats":null,"previous_names":["droath/nexus-ai","droath/nextus-ai"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/droath/nextus-ai","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droath%2Fnextus-ai","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droath%2Fnextus-ai/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droath%2Fnextus-ai/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droath%2Fnextus-ai/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/droath","download_url":"https://codeload.github.com/droath/nextus-ai/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/droath%2Fnextus-ai/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28403757,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-13T21:51:37.118Z","status":"ssl_error","status_checked_at":"2026-01-13T21:45:14.585Z","response_time":56,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":[],"created_at":"2026-01-11T08:54:47.581Z","updated_at":"2026-01-13T23:03:39.199Z","avatar_url":"https://github.com/droath.png","language":"PHP","funding_links":["https://github.com/sponsors/Droath"],"categories":[],"sub_categories":[],"readme":"# Nextus AI - Laravel LLM Provider Client\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/droath/nextus-ai.svg?style=flat-square)](https://packagist.org/packages/droath/nextus-ai)\n[![GitHub Tests Action Status](https://img.shields.io/github/actions/workflow/status/droath/nextus-ai/run-tests.yml?branch=main\u0026label=tests\u0026style=flat-square)](https://github.com/droath/nextus-ai/actions?query=workflow%3Arun-tests+branch%3Amain)\n[![GitHub Code Style Action Status](https://img.shields.io/github/actions/workflow/status/droath/nextus-ai/phpstan.yml?branch=main\u0026label=code%20style\u0026style=flat-square)](https://github.com/droath/nextus-ai/actions?query=workflow%3A\"Fix+PHP+code+style+issues\"+branch%3Amain)\n[![Total Downloads](https://img.shields.io/packagist/dt/droath/nextus-ai.svg?style=flat-square)](https://packagist.org/packages/droath/nextus-ai)\n\nNextus AI is a unified Laravel client library designed for multiple LLM\nproviders, including OpenAI, Anthropic Claude, and Perplexity. This package\noffers a consistent interface for working with Large Language Models, featuring\nagent coordination, tool execution, and flexible memory strategies.\n\n## Features\n\n- **Multi-Provider Support**: Seamlessly switch between OpenAI, Anthropic\n  Claude, and Perplexity with a unified API\n- **Driver Pattern Architecture**: Clean abstraction layer for LLM provider\n  integrations\n- **Agent System**: Coordinate multiple AI agents with parallel, sequential, or\n  router strategies\n- **Tool Integration**: Define and execute tools that LLMs can call during\n  conversations\n- **Memory Strategies**: Flexible memory management with database, session, or\n  null strategies\n- **Streaming Support**: Real-time streaming responses from compatible providers\n- **Testing Helpers**: Built-in fake clients and testing utilities\n- **Laravel Integration**: Native Laravel service provider with auto-discovery\n\n## Requirements\n\n- PHP 8.3 or higher\n- Laravel 11.x or higher\n- Valid API keys for desired LLM providers\n\n## Installation\n\nInstall the package via Composer:\n\n```bash\ncomposer require droath/nextus-ai\n```\n\nThe service provider will be automatically discovered by Laravel.\n\n## Configuration\n\nPublish the configuration file:\n\n```bash\nphp artisan vendor:publish --tag=\"nextus-ai-config\"\n```\n\nThis will create `config/nextus-ai.php` where you can configure your LLM\nproviders.\n\n### Environment Variables\n\nAdd your API keys to your `.env` file:\n\n```env\n# OpenAI Configuration\nOPENAI_API_KEY=your-openai-api-key\nOPENAI_ORGANIZATION=your-org-id  # Optional\n\n# Anthropic Claude Configuration\nCLAUDE_API_KEY=your-claude-api-key\n\n# Perplexity Configuration\nPERPLEXITY_API_KEY=your-perplexity-api-key\n```\n\n### Database Migrations\n\nIf you plan to use the database memory strategy or agent memory features, run\nthe migrations:\n\n```bash\nphp artisan migrate\n```\n\n## Usage\n\n### Basic Chat Example\n\n```php\nuse Droath\\NextusAi\\Facades\\NextusAiClient;\nuse Droath\\NextusAi\\Drivers\\Enums\\LlmProvider;\nuse Droath\\NextusAi\\Messages\\UserMessage;\n\n// Using OpenAI with Message objects (recommended)\n$response = NextusAiClient::driver(LlmProvider::OPENAI)\n    -\u003echat()\n    -\u003ewithMessages([\n        UserMessage::make('What is Laravel?')\n    ])();\n\necho $response-\u003egetMessage();\n\n// Alternative: Using array syntax (also supported)\n$response = NextusAiClient::driver(LlmProvider::OPENAI)\n    -\u003echat()\n    -\u003ewithMessages([\n        ['role' =\u003e 'user', 'content' =\u003e 'What is Laravel?']\n    ])();\n```\n\n### Using Different Providers\n\n```php\nuse Droath\\NextusAi\\Facades\\NextusAiClient;\nuse Droath\\NextusAi\\Messages\\UserMessage;\nuse Droath\\NextusAi\\Messages\\SystemMessage;\nuse Droath\\NextusAi\\Drivers\\Enums\\LlmProvider;\n\n// Using Claude with Message objects\n$driver = NextusAiClient::driver(LlmProvider::CLAUDE);\n$claudeResponse = $driver-\u003echat()\n    -\u003ewithModel('claude-3-5-sonnet-20241022')\n    -\u003ewithMessages([\n        SystemMessage::make('You are a helpful programming assistant.'),\n        UserMessage::make('Explain async programming')\n    ])();\n\n// Using Perplexity\n$driver = NextusAiClient::driver(LlmProvider::PERPLEXITY);\n$perplexityResponse = $driver-\u003echat()\n    -\u003ewithMessages([\n        UserMessage::make('Latest news on AI developments')\n    ])();\n```\n\n### Message Classes\n\nThe package provides dedicated message classes for better type safety and\nstructure:\n\n```php\nuse Droath\\NextusAi\\Facades\\NextusAiClient;\nuse Droath\\NextusAi\\Drivers\\Enums\\LlmProvider;\nuse Droath\\NextusAi\\Messages\\UserMessage;\nuse Droath\\NextusAi\\Messages\\SystemMessage;\nuse Droath\\NextusAi\\Messages\\AssistantMessage;\n\n// Create messages using the make() method\n$systemMessage = SystemMessage::make('You are a helpful assistant.');\n$userMessage = UserMessage::make('Hello, how are you?');\n\n// Send conversation with multiple messages\n$driver = NextusAiClient::driver(LlmProvider::OPENAI);\n$response = $driver-\u003echat()\n    -\u003ewithMessages([\n        SystemMessage::make('You are a helpful assistant specialized in Laravel.'),\n        UserMessage::make('What are the new features in Laravel 11?'),\n    ])();\n\n// UserMessage supports context for additional metadata\n$messageWithContext = UserMessage::make(\n    'Analyze this code',\n    context: 'This is a Laravel controller with CRUD operations'\n);\n```\n\n**Available Message Classes:**\n\n- `UserMessage` - Messages from the user\n- `SystemMessage` - System instructions/prompts\n- `AssistantMessage` - Messages from the AI assistant\n\n### Working with Agents\n\nCreate intelligent agents that can coordinate tasks:\n\n```php\nuse Droath\\NextusAi\\Agents\\Agent;\nuse Droath\\NextusAi\\Agents\\AgentCoordinator;\nuse Droath\\NextusAi\\Agents\\Enums\\AgentStrategy;\n\n// Create specialized agents\n$researchAgent = Agent::make()\n    -\u003esetSystemPrompt('You are a research assistant specialized in gathering information.');\n\n$writerAgent = Agent::make()\n    -\u003esetSystemPrompt('You are a content writer who creates engaging articles.');\n\n// Coordinate agents with a strategy\n$coordinator = AgentCoordinator::make(\n    'Create a blog post about Laravel',\n    [$researchAgent, $writerAgent],\n    AgentStrategy::SEQUENTIAL\n);\n\n$result = $coordinator-\u003erun($resource);\n```\n\n### Using Tools\n\nDefine tools that LLMs can invoke:\n\n```php\nuse Droath\\NextusAi\\Facades\\NextusAiClient;\nuse Droath\\NextusAi\\Drivers\\Enums\\LlmProvider;\nuse Droath\\NextusAi\\Messages\\UserMessage;\nuse Droath\\NextusAi\\Tools\\Tool;\nuse Droath\\NextusAi\\Tools\\ToolProperty;\n\n$weatherTool = Tool::make('get_weather')\n    -\u003edescribe('Get the current weather for a location')\n    -\u003eusing(function (array $arguments) {\n        // Your tool implementation here\n        $location = $arguments['location'];\n        $unit = $arguments['unit'] ?? 'fahrenheit';\n\n        // Example: fetch weather from an API\n        return \"The current weather in {$location} is 72 degrees {$unit}.\";\n    })\n    -\u003ewithProperties([\n        ToolProperty::make('location', 'string')\n            -\u003edescribe('The city and state, e.g. San Francisco, CA')\n            -\u003erequired(),\n        ToolProperty::make('unit', 'string')\n            -\u003edescribe('Temperature unit: celsius or fahrenheit')\n            -\u003ewithEnums(['celsius', 'fahrenheit']),\n    ]);\n\n$driver = NextusAiClient::driver(LlmProvider::OPENAI);\n$response = $driver-\u003echat()\n    -\u003ewithTools([$weatherTool])\n    -\u003ewithMessages([\n        UserMessage::make('What is the weather in San Francisco?')\n    ])();\n\n// If the LLM decides to use the tool, it will be automatically executed\n// and the response will include the tool's output\n```\n\n### Memory Strategies\n\nUse memory to maintain context across interactions:\n\n```php\nuse Droath\\NextusAi\\Memory\\MemoryDefinition;\nuse Droath\\NextusAi\\Memory\\MemoryStrategyFactory;\nuse Droath\\NextusAi\\Agents\\Agent;\n\n// Database memory strategy\n$memoryDefinition = new MemoryDefinition('database', [\n    'connection' =\u003e 'mysql',\n    'table' =\u003e 'llm_agent_memory'\n]);\n\n$factory = new MemoryStrategyFactory($memoryDefinition);\n$memory = $factory-\u003ecreateInstance();\n\n$agent = Agent::make()\n    -\u003esetSystemPrompt('You remember previous conversations')\n    -\u003esetMemory($memory);\n\n// Store information\n$memory-\u003eset('user_preference', 'prefers concise answers');\n\n// Retrieve later\n$preference = $memory-\u003eget('user_preference');\n```\n\n### Streaming Responses\n\nGet real-time streaming responses using callbacks:\n\n```php\nuse Droath\\NextusAi\\Facades\\NextusAiClient;\nuse Droath\\NextusAi\\Messages\\UserMessage;\nuse Droath\\NextusAi\\Drivers\\Enums\\LlmProvider;\nuse Droath\\NextusAi\\Responses\\NextusAiResponseMessage;\n\n$driver = NextusAiClient::driver(LlmProvider::OPENAI);\n$streamOutput = '';\n\n$chat = $driver-\u003echat()\n    -\u003ewithModel('gpt-4')\n    -\u003ewithMessages([\n        UserMessage::make('Write a long story')\n    ])\n    -\u003eusingStream(\n        function (string $chunk, bool $initialized) use (\u0026$streamOutput) {\n            // Process each chunk as it arrives\n            echo $chunk;\n            $streamOutput .= $chunk;\n        },\n        function (NextusAiResponseMessage $response) {\n            // Called when streaming is complete\n            echo \"\\n\\nStreaming finished!\";\n        }\n    );\n\n// Execute the chat request\n$response = $chat();\n```\n\n## Supported LLM Providers\n\n### OpenAI\n\n- Models: GPT-4, GPT-4 Turbo, GPT-3.5 Turbo, and more\n- Features: Chat, embeddings, function calling, streaming\n- Configuration: API key, organization ID (optional), base URL (optional)\n\n### Anthropic Claude\n\n- Models: Claude 3.5 Sonnet, Claude 3 Opus, Claude 3 Haiku\n- Features: Chat, function calling, streaming\n- Configuration: API key\n\n### Perplexity\n\n- Models: Various Perplexity models\n- Features: Chat with web search capabilities\n- Configuration: API key\n\n## Advanced Features\n\n### Agent Coordination Strategies\n\n1. **Parallel**: Execute multiple agents simultaneously\n2. **Sequential**: Execute agents one after another, passing results\n3. **Router**: Intelligently route requests to the most appropriate agent\n\n### Memory Strategies\n\n- **Database Strategy**: Persistent storage using Laravel's database\n- **Session Strategy**: Session-based temporary storage\n- **Null Strategy**: No memory persistence (stateless)\n\n### Custom Drivers\n\nExtend the package to support additional LLM providers by implementing the\ndriver interface:\n\n```php\nuse Droath\\NextusAi\\Drivers\\NextusAiDriver;\n\nclass CustomDriver extends NextusAiDriver\n{\n    // Implement required methods\n}\n```\n\n## Testing\n\nRun the test suite:\n\n```bash\ncomposer test\n```\n\nRun code style checks:\n\n```bash\nvendor/bin/pint\n```\n\nRun static analysis:\n\n```bash\nvendor/bin/phpstan analyse\n```\n\n### Testing Your Application\n\nUse the built-in fake client for testing:\n\n```php\nuse Droath\\NextusAi\\Facades\\NextusAi;\nuse Droath\\NextusAi\\Responses\\NextusAiResponseMessage;\n\nNextusAi::fake(\n    responseCallback: fn() =\u003e NextusAiResponseMessage::fromString('Fake response')\n);\n\n// Your test code here\n```\n\n## Console Commands\n\n### Memory Cleanup\n\nClean up expired memory entries:\n\n```bash\n# Perform cleanup\nphp artisan nextus-ai:memory:cleanup\n\n# Dry run to see what would be cleaned\nphp artisan nextus-ai:memory:cleanup --dry-run\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n## Credits\n\n- [Travis Tomka](https://github.com/droath)\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more\ninformation.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdroath%2Fnextus-ai","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdroath%2Fnextus-ai","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdroath%2Fnextus-ai/lists"}