# 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.

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

To start monitoring your Agents you need to 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 %}

When your agents are being executed, you will see the details of their internal steps on the Inspector dashboard.

<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. You can do this in the agent constructor:

```php
namespace App\Neuron;

use NeuronAI\Agent\Agent;
use NeuronAI\Agent\SystemPrompt;
use NeuronAI\Providers\AIProviderInterface;
use NeuronAI\Observability\InspectorObserver;

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

    protected function provider(): AIProviderInterface
    {
        // return an instance of Anthropic, OpenAI, Gemini, Ollama, etc...
        return ...;
    }
}
```

### 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: 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:

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

The question should be specific, self-contained, and written in natural language.
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.
