atlas-php/atlas

A unified AI SDK for Laravel applications.

Maintainers

Package info

github.com/atlas-php/atlas

pkg:composer/atlas-php/atlas

Statistics

Installs: 43 749

Dependents: 0

Suggesters: 0

Stars: 52

Open Issues: 0

v3.6.0 2026-06-12 14:11 UTC

README

Atlas logo

Automated Tests Code Coverage Total Downloads PHP Version Laravel License

โœจ Features ย ยทย  ๐Ÿ“š Documentation ย ยทย  ๐Ÿงช Sandbox & Examples ย ยทย  โš–๏ธ Comparison

๐Ÿช Atlas

A unified AI SDK for Laravel โ€” agents, tools, and 10 modalities across every major provider.

One API for OpenAI, Anthropic, Google, xAI, ElevenLabs, and any OpenAI-compatible endpoint โ€” with no external AI dependency. Atlas runs the tool-call loop and adds optional persistence for conversations, tracking, and memory.

Every provider modality is live-tested against real provider APIs. See the API Audit.

โšก It's this simple

use Atlasphp\Atlas\Atlas;

$response = Atlas::text('openai', 'gpt-4o-mini')
    ->message('Draft a brief, friendly email letting a client know their project is running two days behind, and propose Thursday for delivery.')
    ->asText();

echo $response->text;
//  Hi Jordan โ€” a quick heads-up that we're running about two days behind
//  on the project. We're aiming to have everything to you by Thursday..."

No agent classes, no config. Add ->instructions() and ->withTools() when you need them, or graduate to a reusable Agent as your app grows.

๐ŸŽฏ Highlights

  • Every modality โ€” text, images, audio, music, SFX, video, realtime voice, embeddings, reranking, moderation. Voice, music, SFX, and video are Atlas-only.
  • A real agent framework โ€” first-class agents, sub-agents with guards and true parallel fan-out, auditable execution trees.
  • Production-grade persistence โ€” conversation memory, execution tracking, retry & branch, media assets on disk (S3/local).
  • Operational services โ€” pre-flight token counting, provider-call observability, runtime model/voice discovery.
  • Control at every layer โ€” middleware across agent, step, tool, and provider boundaries.
  • Multi-provider, one API โ€” every major provider plus any OpenAI-compatible endpoint; swap by changing a string.

๐Ÿ’ก Why Atlas?

Plenty of AI libraries get you a response and stop there. Atlas handles everything after the happy path โ€” the retries, errors, and tracking real apps run into.

  • Tested for real, not mocked. Every modality runs against the live provider API (API Audit), and every feature ships with automated tests. What the docs say is what ships.
  • Production-hardened. Automatic retries, typed exceptions, observability, and cost tracking that survives interrupted streams โ€” the failure modes real apps hit are already handled.
  • Keeps pace with the providers. New models, tools, and capabilities land fast โ€” the CHANGELOG shows the cadence.

And where it counts, Atlas simply does more: realtime voice, video, retry & branch, pre-flight token counting, and ~50%-cheaper batch processing are all Atlas-only among Laravel AI libraries. See the full comparison โ†’

๐Ÿš€ 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 PlantShopAgent 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 Fern, the friendly plant-care and order specialist for {shop_name}.

        ## Customer
        - **Name:** {customer_name}
        - **Member since:** {member_since}

        ## How you help
        - Greet {customer_name} by name and keep it warm.
        - For anything about an order, call `lookup_order` first โ€” never guess a status.
        - If a plant arrived damaged, use `start_return` to open a replacement, then reassure them.
        - Drop in a genuinely useful care tip when it fits.
        PROMPT;
    }

    public function tools(): array
    {
        return [
            LookupOrderTool::class,
            StartReturnTool::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 the status and contents of an order by its ID';
    }

    public function parameters(): array
    {
        return [
            new StringField('order_id', 'The order ID, e.g. "5512"'),
        ];
    }

    public function handle(array $args, array $context): mixed
    {
        $order = $this->orders->find($args['order_id']);

        return $order ? $order->toArray() : 'No order found with that ID.';
    }
}

Chat with the Agent

$response = Atlas::agent('plant-shop')
    ->withVariables([
        'shop_name' => 'Leaf & Co.',
        'customer_name' => 'Sarah',
        'member_since' => '2023',
    ])
    ->message('My monstera arrived with a snapped leaf โ€” order #5512. Can I get a replacement?')
    ->asText();

$response->text;    // "Oh no, Sarah! Let me pull up #5512 for you..."
$response->usage;   // Token usage
$response->steps;   // Tool call loop โ€” lookup_order, then start_return

Speak with the Agent (Voice to Voice)

$session = Atlas::agent('plant-shop')
    ->withVariables([
        'shop_name' => 'Leaf & Co.',
        'customer_name' => 'Sarah',
        'member_since' => '2023',
    ])
    ->asVoice();

return response()->json($session->toClientPayload());
// Returns ephemeral token + connection URL for WebRTC/WebSocket

See the Voice Integration Guide for full setup instructions.

Optional: Enable Persistence

Atlas runs fully stateless by default โ€” no database required. To unlock conversation history, execution tracking, media-asset storage, and retry & branch, publish and run the migrations:

php artisan vendor:publish --tag=atlas-migrations
php artisan migrate

Then turn it on in .env:

ATLAS_PERSISTENCE_ENABLED=true

That's it โ€” ->for($user) and ->forConversation($id) now load and persist history automatically.

โœจ Features

Core generation

  • Text & structured output โ€” schema-validated JSON from any provider
  • Streaming โ€” SSE + Laravel Broadcasting, real-time chunks
  • Tool calling โ€” typed tools, multi-step loop, concurrent execution
  • Reasoning โ€” configure, stream, and persist extended thinking
  • Prompt caching โ€” cache long system prompts to cut cost
  • Token counting โ€” count input (with tools & images) before sending

Agent framework

  • Agents โ€” provider, model, instructions, and tools in one reusable class
  • Sub-agents โ€” delegation with depth/cycle guards, lineage, and parallel fan-out
  • Conversations & memory โ€” multi-turn history, retry & branch, agent memory
  • Execution tracking โ€” steps, tools, usage, and assets persisted
  • Media assets โ€” auto-stored to disk (S3/local), linked to messages
  • Middleware โ€” agent, step, tool, and provider layers
  • Variable interpolation โ€” {var} placeholders resolved at runtime
  • Queues โ€” async execution with broadcasting and callbacks

Modalities

  • 10 modalities โ€” text, images, audio, music, sound effects, video, voice, embeddings, reranking, moderation
  • Realtime voice โ€” bidirectional voice conversations with tools
  • Similarity search โ€” whole-record or chunked embeddings, diff-based re-embedding

Ecosystem & tooling

  • Provider tools โ€” web search, code interpreter, file search
  • MCP โ€” composes with Laravel MCP
  • Provider discovery โ€” list models/voices, validate keys, inspect capabilities
  • Observability โ€” trace every provider call, correlation IDs across retries
  • Testing โ€” full per-modality fakes, no API keys required
  • Custom providers โ€” OpenAI-compatible endpoints or fully custom drivers

๐Ÿ”Œ Providers

Atlas talks to every major provider through one interface. Switch by changing a string โ€” your agents, tools, and middleware stay the same.

First-party drivers

OpenAI ยท Anthropic ยท Google (Gemini) ยท xAI (Grok) ยท ElevenLabs ยท Cohere ยท Jina

Any OpenAI-compatible API

Ollama ยท Groq ยท DeepSeek ยท Together ยท OpenRouter ยท LM Studio ยท Mistral ยท Perplexity

๐Ÿ“– 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
  • Sub-agents โ€” Agent-to-agent delegation, including concurrent (parallel) fan-out
  • Middleware โ€” Extend with four middleware layers
  • Similarity Search โ€” Semantic search over whole-record or chunked embeddings
  • 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 โ€” multi-agent chat, tool calling, conversation memory, and live image/video generation. Built with Vue 3, Tailwind CSS, and a Laravel JSON API.

Switch between multiple agents
Pick from multiple agents โ€” each with its own model and tools
Multi-image input
Multi-modal input โ€” attach multiple images in one message
Extended thinking in the execution trace
Extended thinking โ€” stream the model's reasoning and inspect it per step
Tool call execution trace
Tool calling โ€” full execution trace with arguments and results
Rich Markdown chat
Streaming Markdown chat with full execution traces
Generate images
Image generation rendered inline from a tool call
Generate video
Video generation that plays right in the thread
Edit an uploaded image
Image editing โ€” upload a photo and have an agent restyle it
Retry and branch responses
Retry & branch โ€” regenerate any reply and step through versions
Realtime voice โ€” listening
Realtime voice โ€” AI speaking
Realtime voice โ€” live waveform as you speak and as the AI replies

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
API Audit Every provider modality verified against real provider APIs
Codecov 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.