atlas-php / atlas
A unified AI SDK for Laravel applications.
Requires
- php: ^8.2
- illuminate/contracts: ^11.0|^12.0|^13.0
- illuminate/events: ^11.0|^12.0|^13.0
- illuminate/http: ^11.0|^12.0|^13.0
- illuminate/pipeline: ^11.0|^12.0|^13.0
- illuminate/support: ^11.0|^12.0|^13.0
- spatie/fork: ^1.2
- textalk/websocket: ^1.6
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/pint: ^1.18
- orchestra/testbench: ^9.0|^10.0|^11.0
- pestphp/pest: ^3.0
README
๐ Documentation
๐ช Atlas
Atlas is a unified AI SDK for Laravel applications. It owns its own provider layer โ no external AI package dependency. Atlas talks directly to AI provider APIs, manages the tool call loop, and provides optional persistence for conversations, execution tracking, and agent memory.
โจ Features
- Agents โ Reusable classes encapsulating provider, model, instructions, tools, and behavior
- Tools โ Typed tool classes with parameter schemas and dependency injection
- 10 Modalities โ Text, images, audio (speech, music, sound effects), video, voice, embeddings, reranking
- Variable Interpolation โ
{variable}placeholders in instructions resolved at runtime - Middleware โ Four layers (agent, step, tool, provider) for logging, auth, metrics, and control
- Structured Output โ Schema-validated JSON responses from any provider
- Streaming โ SSE and Laravel Broadcasting with real-time chunk delivery
- Voice โ Real-time bidirectional voice conversations with tool support
- Conversations โ Multi-turn chat with message history, retry, and sibling tracking
- Persistence โ Optional execution tracking and asset storage
- Queue Support โ Async execution with broadcasting and callbacks
- Testing โ Full fake system with assertions โ no API keys required
- Provider Tools โ Web search, code interpreter, file search via provider-native tools
- Provider Discovery โ List available models, voices, and run content moderation
- Custom Providers โ OpenAI-compatible endpoints or fully custom drivers
- All Providers โ OpenAI, Anthropic, Google (Gemini), xAI (Grok), ElevenLabs, Cohere, Jina, plus any OpenAI-compatible API (Ollama, Groq, DeepSeek, Together, OpenRouter, LM Studio)
๐ Quick Start
composer require atlas-php/atlas
Supports Laravel 11+.
php artisan vendor:publish --tag=atlas-config
Define an Agent
use Atlasphp\Atlas\Agent; class SupportAgent extends Agent { public function provider(): ?string { return 'anthropic'; } public function model(): ?string { return 'claude-sonnet-4-20250514'; } public function instructions(): ?string { return <<<'PROMPT' You are a customer support specialist for {company_name}. ## Customer Context - **Name:** {customer_name} - **Account Tier:** {account_tier} ## Guidelines - Always greet the customer by name - For order inquiries, use `lookup_order` before providing details - Before processing refunds, verify eligibility using order data PROMPT; } public function tools(): array { return [ LookupOrderTool::class, ProcessRefundTool::class, ]; } }
Build a Tool
use Atlasphp\Atlas\Tools\Tool; use Atlasphp\Atlas\Schema\Fields\StringField; class LookupOrderTool extends Tool { public function __construct( private OrderService $orders ) {} public function name(): string { return 'lookup_order'; } public function description(): string { return 'Look up order details by order ID'; } public function parameters(): array { return [ new StringField('order_id', 'The order ID to look up'), ]; } public function handle(array $args, array $context): mixed { $order = $this->orders->find($args['order_id']); return $order ? $order->toArray() : 'Order not found'; } }
Chat with the Agent
$response = Atlas::agent('support') ->withVariables([ 'company_name' => 'Acme', 'customer_name' => 'Sarah', 'account_tier' => 'Premium', ]) ->message('Where is my order #12345?') ->asText(); $response->text; // "Hello Sarah! Let me look that up..." $response->usage; // Token usage $response->steps; // Tool call loop history
Speak with the Agent (Voice to Voice)
$session = Atlas::agent('support') ->withVariables([ 'company_name' => 'Acme', 'customer_name' => 'Sarah', 'account_tier' => 'Premium', ]) ->asVoice(); return response()->json($session->toClientPayload()); // Returns ephemeral token + connection URL for WebRTC/WebSocket
See the Voice Integration Guide for full setup instructions.
๐ก Why Atlas?
The problem: Prompts scattered across controllers, duplicated configurations, business logic tightly coupled with AI calls, and no consistent way to add logging, validation, or error handling.
Atlas structures your AI layer:
- Agents โ AI configurations live in dedicated classes, not inline across your codebase.
- Tools โ Business logic stays in tool classes with typed parameters. Agents call tools; tools call your services.
- Middleware โ Add logging, auth, or metrics at four execution layers without coupling the codebase.
- Testable โ Full fake system with per-modality assertions using standard Laravel testing patterns.
๐ Documentation
atlasphp.org โ Full guides, API reference, and examples.
- Getting Started โ Installation and configuration
- Agents โ Define reusable AI configurations
- Tools โ Connect agents to your application
- Middleware โ Extend with four middleware layers
- Modalities โ Text, images, audio, video, voice, embeddings, and more
- Conversations โ Multi-turn chat with persistence
- Voice โ Real-time voice conversations
- Streaming โ SSE and broadcasting
- Queue โ Background execution
- Testing โ Fakes and assertions
๐งช Sandbox
A fully functional chat interface demonstrating Atlas agents in action. Built with Vue 3, Tailwind CSS, and a Laravel JSON API.
See the Sandbox README for setup instructions and details.
๐งน Testing and Code Quality
Atlas uses several tools to maintain high code quality:
composer check
| Tool | Purpose |
|---|---|
| Pest | Testing framework |
| Larastan | Static analysis |
| Laravel Pint | Code style |
| Codecov |
๐ค Contributing
We welcome contributions!
Support the community by giving a GitHub star. Thank you!
Please see our Contributing Guide for details.
๐ License
Atlas is open-sourced software licensed under the MIT license.
