> For the complete documentation index, see [llms.txt](https://docs.inspector.dev/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.inspector.dev/guides/neuron-ai.md).

# Neuron AI

### The Problem With AI Systems <a href="#the-problem-with-ai-systems" id="the-problem-with-ai-systems"></a>

Integrating AI Agents into your application you're not working only with functions and deterministic code, you program your agent also influencing probability distributions. Same input ≠ output. That means reproducibility, versioning, and debugging become real problems.

Many of the Agents you build with Neuron will contain multiple steps with multiple invocations of LLM calls, tool usage, access to external memories, etc. As these applications get more and more complex, it becomes crucial to be able to inspect what exactly your agent is doing and why.

Why is the model making certain decisions? What data is the model reacting to? Prompting is not programming in the common sense. No static types, small changes break output, long prompts cost latency, and no two models behave exactly the same with the same prompt.

### Install

You need to install the Inspector PHP package only if you are not already using other inspector libraries like `inspector-laravel`, `inspector-symfony`, and others.

```shellscript
composer require inspector-apm/inspector-php
```

If you are building with Neuron AI inside a web framework, we strongly recommend to use the framework specific package in order to have a complete integration.

### Get Started <a href="#get-started-with-inspector" id="get-started-with-inspector"></a>

First add the `INSPECTOR_INGESTION_KEY` variable in your application environment file. Authenticate on [app.inspector.dev](https://app.inspector.dev/register) to create a new one.

{% code title=".env" %}

```
INSPECTOR_INGESTION_KEY=nwse877auxxxxxxxxxxxxxxxxxxxxxxxxxxxx
```

{% endcode %}

The second step is to register the `InspectorObserver` in your Agent, RAG, or Workflow. You can do it in the constructor:

```php
use Inspector\Neuron\InspectorObserver;

class MyAgent extends Agent
{
    public function __construct()
    {
        parent::__construct();
        
        // Register the InspectorObserver
        $this->observe(InspectorObserver::instance());
    }
    
    ...
}
```

When your agents are being executed, you will see the details of their inference steps, tool calls, and more.

<figure><img src="/files/SB3noPtYTg0LVupAxcop" alt=""><figcaption></figcaption></figure>

#### Create An Ingestion Key <a href="#create-an-ingestion-key" id="create-an-ingestion-key"></a>

To create an Ingestion key head to the [**Inspector dashboard**](https://app.inspector.dev/register) and create a new app.

{% hint style="success" %}
For any additional support drop in a live chat in the dashboard. We are happy to listen from your experience, find new possible improvements, and make the tool better overtime.
{% endhint %}

### Configure Observer

If your application already works with environment files, it is very likely that Neuron can automatically instrument itself if you add the `INSPECTOR_INGESTION_KEY` . If you have no access to environment variables, or you just want to customize the `InspectorObserver` configuration you can register it manually in your agent.&#x20;

```php
use Inspector\Neuron\InspectorObserver;

class MyAgent extends Agent
{
    public function __construct()
    {
        parent::__construct();
        
        // Register the InspectorObserver
        $this->observe(
            InspectorObserver::instance('INSPECTOR_INGESTION_KEY')
        );
    }

    ...
}
```

### Background Workers

If you are running your agent into a long running process like a queue worker or systems like Swoole, or Roadrunner, you need to explicitly configure the auto-flush of events:

```php
// Register Inspector
$this->observe(
    InspectorObserver::instance(
        key: 'INSPECTOR_INGESTION_KEY',
        autoFlush: true
    )
);
```

### Add The Framework Specific Package

If you are integrating Neuron in an already existing application built on top of a framework like Laravel, Symfony, or simialr, we strongly recommend to add the framework specific package for a better data collection.

It's not required, just recommended. You can continue to monitor Neuron without the framework specific package.&#x20;

{% content-ref url="/pages/-LuWcB8gWM5wptHOWiEF" %}
[Laravel / Lumen](/guides/laravel.md)
{% endcontent-ref %}

{% content-ref url="/pages/-MbG50kVKWT\_dmhrNUpX" %}
[Symfony](/guides/symfony.md)
{% endcontent-ref %}

{% content-ref url="/pages/GqQIK9NcYrhKhzY5acoB" %}
[CodeIgniter](/guides/codeigniter.md)
{% endcontent-ref %}

{% content-ref url="/pages/sFz09Y2ifm3lLFM7iSEA" %}
[Slim](/guides/slim.md)
{% endcontent-ref %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.inspector.dev/guides/neuron-ai.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
