Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message
Anthropic Php

Anthropic Php Laravel Package

mozex/anthropic-php

Community-maintained PHP SDK for the Anthropic API. Send messages, stream responses, call tools, use extended thinking, web search, code execution, files, and batches. PSR-18 compatible, works with any HTTP client; Laravel wrapper available.

View on GitHub
Deep Wiki
Context7

PHP client for the Anthropic API: messages, streaming, tool use, thinking, web search, code execution, batches, and more.

Frequently asked questions about Anthropic Php
How do I install **mozex/anthropic-php** in a Laravel project?
Run `composer require mozex/anthropic-php` for the base SDK. For Laravel-specific features (Service Container, config, facade), add `mozex/anthropic-laravel` via `composer require mozex/anthropic-laravel`. The Laravel wrapper auto-registers with your app’s container.
Does this package support Laravel’s built-in HTTP client (Guzzle)?
Yes. The package is PSR-18 compliant and works seamlessly with Laravel’s default Guzzle client (`illuminate/http-guzzle-promise`). No additional setup is required for basic usage.
Can I use custom HTTP clients like Symfony’s HttpClient instead of Guzzle?
Absolutely. The SDK uses `php-http/discovery` to auto-install a PSR-18 client, but you can override it by binding your preferred client (e.g., Symfony) in Laravel’s Service Container.
What Laravel versions does **mozex/anthropic-laravel** support?
The package supports Laravel 10.x and 11.x. Check the [mozex/anthropic-laravel GitHub](https://github.com/mozex/anthropic-laravel) for version-specific requirements and compatibility notes.
How do I handle streaming responses in Laravel for real-time chat apps?
Use the `stream()` method on responses, which returns an iterator. In Laravel, you can dispatch events or queue jobs for each chunk using `bus:dispatch` or `queue:listen`. Example: `foreach ($response->stream() as $chunk) { event(new ChatUpdate($chunk)); }`.
Does the SDK support Anthropic’s tool use feature (function calling)?
Yes. The SDK fully supports tool use, including server tools for executing functions (e.g., calling external APIs or database queries). Tools are defined as arrays in your message payload, and the SDK handles the `tool_use` response format automatically.
How do I test my Laravel app without hitting Anthropic’s API?
Use the `ClientFake` utility provided by the package. It mocks HTTP requests and responses, allowing you to test all features (messages, streaming, tools) locally. Example: `$client = new ClientFake(); $anthropic = new Anthropic($client);`.
Are there any known issues with rate limiting in production?
The SDK includes `$response->meta()` to access rate limit headers (e.g., `rate_limit_remaining`). For production, implement exponential backoff or queue retries using Laravel’s `queue:after` events to handle throttling gracefully.
What are the alternatives to **mozex/anthropic-php** for Laravel?
For Anthropic, this is the most feature-complete PHP SDK. Alternatives include writing a custom HTTP client or using a generic PSR-18 wrapper, but they lack Laravel-specific integrations (e.g., config, facade) or advanced features like tool use or streaming helpers.
How do I configure the Laravel wrapper to use a custom API key per environment?
Add your API key to `.env` as `ANTHROPIC_API_KEY`. The Laravel wrapper reads this automatically. For multi-environment setups, use Laravel’s config caching (`php artisan config:cache`) or environment-specific `.env` files.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
directorytree/privacy-filter-classifier
directorytree/privacy-filter
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata
splash/openapi
splash/scopes
splash/toolkit
testo/output-teamcity
testo/bridge-symfony
spatie/flare-daemon-runtime