PapiAI vs Neuron AI
Two PHP agentic frameworks, different philosophies.
The PHP AI ecosystem now has multiple serious options for building agentic applications. Two of the most capable are PapiAI and Neuron AI. Both support multiple LLM providers, tool calling, streaming, structured output, and RAG. Both work with Laravel and Symfony. Both are open source under MIT.
But they make fundamentally different architectural choices. This post looks at those differences to help you decide which fits your project.
Architecture
PapiAI is built around composition. You instantiate an Agent, pass it a provider, tools, and configuration, and run it. The core has zero runtime dependencies — no Guzzle, no PSR-18 client, no monitoring SDK. Provider packages use ext-curl directly. Everything is explicit: you see every piece of the agent in your code.
$agent = Agent::build()
->provider(new AnthropicProvider(apiKey: $key))
->model('claude-sonnet-4-20250514')
->instructions('You are a support agent.')
->tools(Tool::fromClass(new OrderLookup()))
->addMiddleware(new RetryMiddleware(maxRetries: 3))
->maxTurns(8)
->create();
$response = $agent->run('Where is my order?');
Neuron AI is built around inheritance. You extend an Agent base class and implement protected methods — provider(), instructions(), tools(). The framework resolves configuration from the class definition. It ships with Guzzle and the Inspector monitoring SDK as hard dependencies.
class SupportAgent extends Agent
{
protected function provider(): AIProviderInterface
{
return new Anthropic(apiKey: $key);
}
protected function instructions(): string
{
return 'You are a support agent.';
}
protected function tools(): array
{
return [/* tools */];
}
}
$response = SupportAgent::make()->chat(new UserMessage('Where is my order?'));
Neither approach is wrong. Composition gives you more flexibility and testability — you can build agents dynamically, swap pieces at runtime, and inject mocks without extending classes. Inheritance gives you a self-contained unit that's easy to scaffold and reason about in isolation.
Dependencies
This is one of the sharpest differences.
PapiAI's core package (papi-ai/papi-core) requires only php: ^8.2. Zero runtime dependencies. Provider packages add ext-curl and nothing else. Your dependency tree stays clean.
Neuron AI requires guzzlehttp/guzzle and inspector-apm/inspector-php. The Inspector SDK is a hard dependency, not optional — every installation pulls it in whether you use Inspector monitoring or not. This matters if you have strict dependency policies, existing HTTP clients you'd rather use, or simply don't want third-party monitoring baked into your AI layer.
Tool calling
PapiAI defines tools using PHP attributes on regular classes:
class OrderLookup
{
#[Tool('Find an order by its ID')]
public function find(
#[Description('The order ID, e.g. ORD-12345')] string $orderId,
): string {
$order = Order::where('order_id', $orderId)->first();
return json_encode(['status' => $order->status]);
}
}
The tool is a plain class. No base class to extend, no interface to implement. The agent discovers the tool name, description, and parameter schema from the attributes. You can have multiple tool methods on one class.
Neuron AI uses a builder pattern with Tool::make():
Tool::make(
'find_order',
'Find an order by its ID',
)
->addProperty(
new ToolProperty(
name: 'order_id',
type: PropertyType::STRING,
description: 'The order ID, e.g. ORD-12345',
required: true,
),
)
->setCallable(function (?string $order_id): string {
$order = Order::where('order_id', $order_id)->first();
return json_encode(['status' => $order->status]);
})
Both approaches work. PapiAI's attribute-based tools are more concise and keep the logic in regular PHP methods that are easy to unit test independently. Neuron's builder is more verbose but makes the schema explicit without relying on reflection.
Neuron also has built-in MCP (Model Context Protocol) support for connecting to external tool servers, which PapiAI does not currently include.
Structured output
PapiAI has a Zod-inspired schema system that's a first-class feature of the library:
$schema = Schema::object([
'sentiment' => Schema::enum(['positive', 'negative', 'neutral']),
'confidence' => Schema::number()->min(0)->max(1),
'topics' => Schema::array(Schema::string())->minItems(1),
]);
Neuron uses PHP attributes on data classes:
class SentimentResult
{
#[SchemaProperty(description: 'The sentiment')]
public string $sentiment;
#[SchemaProperty(description: 'Confidence score')]
public float $confidence;
}
PapiAI's approach gives you runtime validation with composable constraints (min, max, minItems, enum values) that are checked after the LLM responds. Neuron's approach is terser for simple cases and returns hydrated PHP objects directly.
Middleware and observability
PapiAI has a composable middleware pipeline with four built-in middlewares (retry, rate limiting, caching, logging) and a simple interface for writing your own:
$agent = Agent::build()
->addMiddleware(new RetryMiddleware(maxRetries: 3))
->addMiddleware(new RateLimitMiddleware(maxRequests: 60, perSeconds: 60))
->addMiddleware(new CacheMiddleware($psr6Cache, ttl: 3600))
->addMiddleware(new LoggingMiddleware($psrLogger))
->create();
PapiAI also provides lifecycle hooks (beforeToolCall, afterToolCall, etc.) that let you observe the agent's behavior without coupling to a specific monitoring platform.
Neuron bakes in observability via Inspector. If you set INSPECTOR_INGESTION_KEY, you get execution timeline visualization, token tracking, and debugging out of the box. This is convenient if you use Inspector, but it's not pluggable — you can't swap it for Datadog, New Relic, or your own system without working around the hard dependency.
Streaming
Both libraries support streaming. PapiAI uses a generator-based approach with typed events:
foreach ($agent->streamEvents($message) as $event) {
match ($event->type) {
StreamEvent::TYPE_TEXT => handleText($event->text),
StreamEvent::TYPE_TOOL_CALL => handleTool($event->tool),
StreamEvent::TYPE_DONE => null,
};
}
Neuron returns a stream handler with chunk types:
$handler = MyAgent::make()->stream(new UserMessage('Hello'));
foreach ($handler->events() as $chunk) {
echo $chunk->content;
}
Neuron ships with stream adapters for Vercel AI SDK and AG-UI, which is useful if you're building frontends with those tools. PapiAI leaves the SSE/transport layer to your application code, which gives you more control but requires more wiring.
Multi-agent workflows
Neuron has a built-in Workflow system for orchestrating multiple agents with event-driven transitions and human-in-the-loop support. This is a significant feature if you need complex multi-step pipelines where agents hand off to each other or pause for human approval.
PapiAI doesn't have a dedicated workflow abstraction. You compose multi-agent flows in application code — one agent's output feeds into another's input. This is simpler and more transparent, but you write the orchestration logic yourself.
Framework support
Both work with any PHP framework. PapiAI provides official bridges for Laravel and Symfony with service providers, facades, bundle configuration, and DI integration. Neuron has an official Laravel SDK and works with Symfony, WordPress, and others through manual wiring.
Summary
| Aspect | PapiAI | Neuron AI |
|---|---|---|
| Architecture | Composition | Inheritance |
| Runtime dependencies | Zero (core) | Guzzle + Inspector SDK |
| PHP version | 8.2+ | 8.1+ |
| Tool definition | PHP attributes on classes | Builder pattern + closures |
| MCP support | No | Yes |
| Structured output | Zod-like schema API | PHP attribute classes |
| Middleware pipeline | Yes (4 built-in + custom) | No (Inspector built-in) |
| Observability | Hooks (pluggable) | Inspector (bundled) |
| Multi-agent workflows | Application code | Built-in Workflow system |
| Stream adapters | Manual | Vercel AI, AG-UI |
| LLM providers | 10 + ElevenLabs | 14+ |
| Symfony bridge | Official bundle | Manual |
| Laravel bridge | Official package | Official SDK |
When to choose which
Choose PapiAI if you value zero dependencies, composition over inheritance, explicit agent configuration, a pluggable middleware pipeline, and framework-agnostic code that works identically in Laravel, Symfony, or standalone PHP.
Choose Neuron AI if you want built-in multi-agent workflows, MCP server integration, stream adapters for modern frontend frameworks, or you already use Inspector for monitoring and want tight observability out of the box.
Both libraries are actively maintained, well-documented, and production-capable. The PHP AI ecosystem is better for having both.