PHPackages                             claude-php/claude-php-sdk-laravel - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. claude-php/claude-php-sdk-laravel

ActiveLibrary[API Development](/categories/api)

claude-php/claude-php-sdk-laravel
=================================

Laravel integration for the Claude PHP SDK - Anthropic Claude API

v1.1.1(3mo ago)5010.8k↓27.3%MITPHPPHP ^8.2CI passing

Since Nov 26Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/claude-php/Claude-PHP-SDK-Laravel)[ Packagist](https://packagist.org/packages/claude-php/claude-php-sdk-laravel)[ Docs](https://github.com/claude-php/Claude-PHP-SDK-Laravel)[ GitHub Sponsors](https://github.com/sponsors/claude-php)[ RSS](/packages/claude-php-claude-php-sdk-laravel/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (8)Versions (6)Used By (0)

Claude PHP SDK for Laravel
==========================

[](#claude-php-sdk-for-laravel)

[![Latest Version](https://camo.githubusercontent.com/5522e161a8f815982e724c15863cd643163b9189dd346e721db353fc66b2e684/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c617564652d7068702f636c617564652d7068702d73646b2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/claude-php/claude-php-sdk-laravel)[![Total Downloads](https://camo.githubusercontent.com/9632d7571dda87b02b658c73443df7d189760d869e6b9f8d7c6c225d06078059/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c617564652d7068702f636c617564652d7068702d73646b2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/claude-php/claude-php-sdk-laravel)[![GitHub Stars](https://camo.githubusercontent.com/0698b4e14ef68eb2c74d9eea3757db27fae2a7bf5efe6dc0f3fa116773c24211/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f636c617564652d7068702f436c617564652d5048502d53444b2d4c61726176656c3f7374796c653d666c61742d737175617265)](https://github.com/claude-php/Claude-PHP-SDK-Laravel/stargazers)[![License](https://camo.githubusercontent.com/02a498c10343e8cf1cf13279c3d03c36f13eef379ff3c3633a74579500ed4ab8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636c617564652d7068702f636c617564652d7068702d73646b2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![PHP Version](https://camo.githubusercontent.com/7da98c0be7570421183fb1b0c1169e73eb6f2febc5542e58a12331ae8e214095/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f636c617564652d7068702f636c617564652d7068702d73646b2d6c61726176656c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/claude-php/claude-php-sdk-laravel)[![Laravel Version](https://camo.githubusercontent.com/2557965064af1e052691dbe4b1770d6922ce108fe1a70208b645a46b1af372fe/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c61726176656c2d31312e7825323025374325323031322e782d7265642e7376673f7374796c653d666c61742d737175617265)](https://laravel.com)

The unofficial Laravel integration for the [Claude PHP SDK](https://github.com/claude-php/Claude-PHP-SDK), providing seamless access to Anthropic's Claude API in your Laravel applications.

If this saves you time, a star on GitHub helps other Laravel developers find it.

Requirements
------------

[](#requirements)

- PHP 8.2+
- Laravel 11.x or 12.x

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require claude-php/claude-php-sdk-laravel
```

The package will automatically register the service provider and facade.

Configuration
-------------

[](#configuration)

Publish the configuration file:

```
php artisan vendor:publish --tag=claude-config
```

Add your Anthropic API key to your `.env` file:

```
ANTHROPIC_API_KEY=your-api-key-here
```

### Available Configuration Options

[](#available-configuration-options)

OptionEnvironment VariableDefaultDescription`api_key``ANTHROPIC_API_KEY``null`Your Anthropic API key`base_url``ANTHROPIC_BASE_URL``https://api.anthropic.com/v1`API base URL`timeout``ANTHROPIC_TIMEOUT``30.0`Request timeout in seconds`max_retries``ANTHROPIC_MAX_RETRIES``2`Maximum retry attempts`headers`-`[]`Custom headers for requests---

📚 More Examples &amp; Tutorials
-------------------------------

[](#-more-examples--tutorials)

This Laravel package wraps the [Claude PHP SDK](https://github.com/claude-php/Claude-PHP-SDK) (v0.6.0+). The main SDK contains **85+ examples** and **17 comprehensive tutorials** covering advanced topics like:

- 🤖 **Agentic Patterns**: ReAct, Chain-of-Thought, Tree-of-Thoughts, Plan-and-Execute
- 🔧 **Tool Use**: Function calling, Computer Use, Bash tools, MCP integration
- 🧠 **Extended Thinking**: Deep reasoning with thinking budgets
- 📄 **Document Processing**: PDFs, images, citations
- ⚡ **Streaming**: Real-time responses with event handling
- 📦 **Batch Processing**: High-volume request handling

### Using SDK Examples with Laravel

[](#using-sdk-examples-with-laravel)

All examples in the main SDK can be adapted for Laravel by replacing the client initialization with the Facade:

**SDK Example (standalone):**

```
use ClaudePhp\ClaudePhp;

$client = new ClaudePhp(apiKey: $_ENV['ANTHROPIC_API_KEY']);
$response = $client->messages()->create([...]);
```

**Laravel (using Facade):**

```
use ClaudePhp\Laravel\Facades\Claude;

$response = Claude::messages()->create([...]);
```

**Laravel (using Dependency Injection):**

```
use ClaudePhp\ClaudePhp;

public function __construct(private ClaudePhp $claude) {}

// Then use: $this->claude->messages()->create([...]);
```

👉 **[Browse Examples](https://github.com/claude-php/Claude-PHP-SDK/tree/main/examples)** | **[Read Tutorials](https://github.com/claude-php/Claude-PHP-SDK/tree/main/tutorials)**

---

What's New in SDK v0.6.0
------------------------

[](#whats-new-in-sdk-v060)

The underlying `claude-php/claude-php-sdk` was updated to v0.6.0, adding full parity with the Python SDK v0.80.0. All new features are available through the `Claude` facade immediately.

```
use ClaudePhp\Types\ModelParam;

// Adaptive thinking — claude-opus-4-6 decides whether to think
Claude::messages()->create([
    'model'    => ModelParam::MODEL_CLAUDE_OPUS_4_6,
    'thinking' => ['type' => 'adaptive'],
    'messages' => [['role' => 'user', 'content' => 'Design a caching strategy.']],
]);

// Fast-mode inference via beta messages
Claude::beta()->messages()->create([
    'model'   => ModelParam::MODEL_CLAUDE_OPUS_4_6,
    'speed'   => 'fast',
    'messages' => [['role' => 'user', 'content' => 'Classify: spam or not spam?']],
]);

// Code execution, memory, and web fetch server-side tools
Claude::messages()->create([
    'model'   => ModelParam::MODEL_CLAUDE_SONNET_4_5,
    'tools'   => [['name' => 'code_execution', 'type' => 'code_execution_20250825']],
    'messages' => [['role' => 'user', 'content' => 'Compute the 100th prime.']],
]);
```

Use `ModelParam` constants for IDE autocomplete and typo-safe model IDs:

```
use ClaudePhp\Types\ModelParam;

ModelParam::MODEL_CLAUDE_OPUS_4_6    // claude-opus-4-6  (Feb 2026)
ModelParam::MODEL_CLAUDE_SONNET_4_6  // claude-sonnet-4-6
ModelParam::MODEL_CLAUDE_SONNET_4_5  // claude-sonnet-4-5-20250929
ModelParam::MODEL_CLAUDE_HAIKU_4_5   // claude-haiku-4-5-20251001
```

See the [SDK CHANGELOG](https://github.com/claude-php/Claude-PHP-SDK/blob/main/CHANGELOG.md) for the full v0.6.0 feature list.

---

Usage Examples
--------------

[](#usage-examples)

### Basic Message

[](#basic-message)

```
use ClaudePhp\Laravel\Facades\Claude;

$response = Claude::messages()->create([
    'model' => 'claude-sonnet-4-5-20250929',
    'max_tokens' => 1024,
    'messages' => [
        ['role' => 'user', 'content' => 'Hello, Claude!']
    ]
]);

echo $response['content'][0]['text'];
```

### Using in a Controller

[](#using-in-a-controller)

```
