Skip to content

atlas-php/atlas

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

591 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

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.

Releases

Contributors

Languages