Skip to content
Doppar AI

AI Without Leaving pure PHP.

Doppar AI runs transformer models on your own server and talks to OpenAI, Gemini, Claude, OpenRouter or a self-hosted model, with no separate AI service to deploy.

Works with the models you already use
OpenAI Google Gemini Claude OpenRouter LM Studio HuggingFace

AI integration for Doppar

Doppar AI makes shipping AI features enjoyable

Local Pipelines

Sixteen transformer tasks run on your server through Transformers.php. No API calls, no per-request cost.

use Doppar\AI\Pipeline;
use Doppar\AI\Enum\TaskEnum;

$result = Pipeline::execute(
    task: TaskEnum::SENTIMENT_ANALYSIS,
    data: 'This movie was terrible and boring.'
);

Swap Providers Freely

One fluent interface for OpenAI, Gemini, Claude, OpenRouter and self-hosted models. Change the class, keep the call.

$response = Agent::using(Gemini::class)
    ->withKey(env('GEMINI_API_KEY'))
    ->model('gemini-2.0-flash')
    ->prompt('What are the SOLID principles?')
    ->send();

Streaming Responses

Stream tokens to the browser as the model produces them, instead of waiting for the full answer.

$stream = Agent::using(OpenAI::class)
    ->withKey(env('OPENAI_API_KEY'))
    ->model('gpt-4')
    ->prompt('Write a short story about a robot.')
    ->withStreaming()
    ->send();

foreach ($stream as $chunk) {
    echo $chunk;
    flush();
}

Tool Calling

Let an agent call your own PHP methods. Mark a class with an attribute and pass it to withTools().

#[AsTool('get_weather', 'Get the current weather')]
class WeatherTool
{
    public function __invoke(string $city): string
    {
        return "Sunny, 24°C in {$city}";
    }
}

A complete toolkit to build upon

Memory, typed output, routing and retrieval, ready to use

Agent Memory

Give an agent persistent facts it remembers across calls, without resending them in every prompt. See Agent Memory.

$response = Agent::using(OpenAI::class)
    ->withKey(env('OPENAI_API_KEY'))
    ->model('gpt-4')
    ->remember('VIP Customer.', 'Prefers email')
    ->prompt('How should I follow up with this customer?')
    ->send();

Structured Output

Get the response back as a typed PHP object instead of free text. See Structured Output.

$result = Agent::using(OpenAI::class)
    ->withKey(env('OPENAI_API_KEY'))
    ->model('gpt-4')
    ->asStructured(WeatherReport::class)
    ->prompt('What is the weather like in Paris today?')
    ->complete()
    ->send();

$report = $result->getContent(); 

Multi-Agent Handoff

Route each prompt to a specialized agent automatically, with a fallback. See Multi-Agent Handoff.

$response = MultiAgent::make($orchestrator)
    ->handoff($billing, when: ['invoice', 'payment'])
    ->handoff($support, when: ['bug', 'error', 'help'])
    ->fallback($support)
    ->prompt('My invoice total looks wrong this month')
    ->send();

Persistent Conversations

Save and restore multi-turn threads with a store, so a conversation picks up exactly where it stopped.

$store = new CacheStore('./storage/doppar_ai_store');

$agent = Agent::using(OpenAI::class)
    ->withKey(env('OPENAI_API_KEY'))
    ->withStore($store);

$response = $agent->loadMessages('support-thread-42')
    ->prompt('It\'s order #9931.')
    ->send();

$agent->store('support-thread-42', $response);

Vector and RAG

Cosine similarity and context retrieval for Retrieval Augmented Generation. See Vector & RAG.

use Doppar\AI\Vector\Vector;

$s = Vector::cosineSimilarity($vectorA, $vectorB);

Self-Hosted Models

Point an agent at any OpenAI-compatible endpoint you run yourself, such as LM Studio.

$response = Agent::using(SelfHost::class)
    ->withHost('http://localhost:1234')
    ->model('local-model-name')
    ->prompt('Generate a PHP function.')
    ->send();

Teach your Doppar app a new trick

One composer require, one launcher, and your app can think, stream and remember. No extra service to run.