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

# 安装

### 要求

* PHP：^8.1

### 安装

运行下面的 composer 命令以安装最新版本：

```bash
composer require neuron-core/neuron-ai
```

### 创建一个 Agent

您可以使用下面的命令轻松创建您的第一个 agent：

{% tabs %}
{% tab title="Unix" %}

```bash
./vendor/bin/neuron make:agent App\\Neuron\\MyAgent
```

{% endtab %}

{% tab title="Windows" %}

```powershell
.\vendor\bin\neuron make:agent App\Neuron\MyAgent
```

{% endtab %}
{% endtabs %}

```php
namespace App\Neuron;

use NeuronAI\Agent\Agent;
use NeuronAI\Agent\SystemPrompt;
use NeuronAI\Providers\Anthropic\Anthropic;

class MyAgent extends Agent
{
    protected function provider(): AIProviderInterface
    {
        // 返回一个 AI 提供商（Anthropic、OpenAI、Ollama、Gemini 等）
        return new Anthropic(
            key: 'ANTHROPIC_API_KEY',
            model: 'ANTHROPIC_MODEL',
        );
    }

    public function instructions(): string
    {
        return (string) new SystemPrompt(
            background: ["你是一个使用 Neuron 框架创建的友好 AI Agent。"],
        );
    }
}
```

### 与 Agent 对话

向 agent 发送提示，以从底层 LLM 获取响应：

```php
use NeuronAI\Chat\Messages\UserMessage;

$message = MyAgent::make()
    ->chat(new UserMessage("Hi, who are you?"))
    ->getMessage();

echo $message->getContent();
// 我是一个使用 Neuron 构建的友好 AI Agent，今天我能如何帮助你？
```

### 监控与调试

你使用 Neuron 构建的许多应用都会包含多个步骤，以及对 LLM 调用、工具、外部记忆系统等的多次调用。随着这些应用变得越来越复杂，能够检查你的 agentic 系统内部究竟发生了什么就变得至关重要。做到这一点的最佳方式是借助 [Inspector](https://inspector.dev/).

{% embed url="<https://docs.inspector.dev/guides/neuron-ai>" %}

### Laravel 应用程序视频教程

{% embed url="<https://www.youtube.com/watch?v=oSA1bP_j41w>" %}
