anthropic-ai / sdk
Anthropic PHP SDK
Requires
- php: ^8.1
- open-telemetry/api: ^1.0
- php-http/discovery: ^1
- psr/http-client: ^1
- psr/http-client-implementation: ^1
- psr/http-factory-implementation: ^1
- psr/http-message: ^1|^2
- standard-webhooks/standard-webhooks: ^1
Requires (Dev)
- aws/aws-sdk-php: ^3.368
- friendsofphp/php-cs-fixer: ^3
- google/auth: ^1.49
- guzzlehttp/guzzle: ^7
- mcp/sdk: ^0.7.1
- nyholm/psr7: ^1
- open-telemetry/sdk: ^1.0
- pestphp/pest: ^3
- php-http/mock-client: ^1
- phpstan/extension-installer: ^1
- phpstan/phpstan: 2.2.13
- phpstan/phpstan-phpunit: ^2
- phpunit/phpunit: ^11
- symfony/http-client: ^7
Suggests
- aws/aws-sdk-php: Allows using the AWS Bedrock, AWS gateway, and Bedrock Mantle SDKs
- google/auth: Allows using the Google Vertex and Google Cloud gateway SDKs
- mcp/sdk: Required to use the BetaMcp helpers for integrating MCP servers with the Anthropic SDK
Provides
None
Conflicts
None
Replaces
None
- dev-main
- v1.4.0
- v1.3.0
- v1.2.0
- v1.1.0
- v1.0.0
- v0.61.0
- v0.60.0
- v0.59.0
- v0.58.0
- v0.57.0
- v0.56.0
- v0.55.0
- v0.54.0
- v0.53.0
- v0.52.0
- v0.51.0
- v0.50.0
- v0.49.0
- v0.48.0
- v0.47.0
- v0.46.0
- v0.45.0
- v0.44.0
- v0.43.0
- v0.42.0
- v0.41.0
- v0.40.0
- v0.39.0
- v0.38.0
- v0.37.1
- v0.37.0
- v0.36.0
- v0.35.1
- v0.35.0
- v0.34.0
- v0.33.0
- v0.32.0
- v0.31.0
- v0.30.0
- v0.29.2
- v0.29.1
- v0.29.0
- v0.28.0
- v0.27.0
- v0.26.0
- v0.25.0
- v0.24.0
- v0.23.0
- v0.22.0
- v0.21.0
- v0.20.0
- v0.19.0
- v0.18.0
- v0.17.1
- v0.17.0
- v0.16.0
- v0.15.0
- v0.14.0
- v0.13.0
- v0.12.0
- v0.11.0
- v0.10.0
- v0.9.0
- v0.8.0
- v0.7.0
- v0.6.0
- v0.5.0
- v0.4.0
- v0.3.0
- v0.2.0
- v0.1.0
- dev-meorphis-anthropic-patch-1
- dev-release-please--branches--main--changes--next
- dev-tomer/files-skills-changelog-details
- dev-generated
- dev-cameron/middleware
- dev-devsec/pin-actions
- dev-packy/remove-claude-code-review
- dev-fix/packagist-url
This package is auto-updated.
Last update: 2026-11-02 19:13:09 UTC
README
The Claude SDK for PHP provides access to the Claude API from PHP applications.
Documentation
Full documentation is available at platform.claude.com/docs/en/api/sdks/php.
Installation
composer require "anthropic-ai/sdk:^1.4.0"
The SDK needs a PSR-18 HTTP client. If you don't have one installed, add Guzzle:
composer require guzzlehttp/guzzle
Getting started
<?php use Anthropic\Client; use Anthropic\Messages\Model; $client = new Client( apiKey: getenv('ANTHROPIC_API_KEY') ?: 'my-anthropic-api-key' ); $message = $client->messages->create( maxTokens: 1024, messages: [['role' => 'user', 'content' => 'Hello, Claude']], model: Model::CLAUDE_OPUS_5_5, ); var_dump($message->content);
Requirements
PHP 8.1.0+
Autoloading note
This SDK includes class aliases for backwards compatibility, but these are not available when using authoritative classmaps in Composer.
If you use composer --classmap-authoritative and you rely on any of the following class names:
UnwrapWebhookEvent
Then update your code to use the true class name.
Contributing
See CONTRIBUTING.md.
License
This project is licensed under the Apache License, Version 2.0. See the LICENSE file for details. Versions released before the change from the MIT License, and third-party contributions merged before it, remain under the MIT License. See LICENSE-MIT.