anthropic-ai / sdk
Anthropic PHP SDK
v0.6.0
2026-02-19 19:42 UTC
Requires
- php: ^8.1
- php-http/discovery: ^1
- psr/http-client: ^1
- psr/http-client-implementation: ^1
- psr/http-factory-implementation: ^1
- psr/http-message: ^1|^2
Requires (Dev)
- aws/aws-sdk-php: ^3.368
- friendsofphp/php-cs-fixer: ^3
- google/auth: ^1.49
- nyholm/psr7: ^1
- pestphp/pest: ^3
- php-http/mock-client: ^1
- phpstan/extension-installer: ^1
- phpstan/phpstan: ^2
- phpstan/phpstan-phpunit: ^2
- phpunit/phpunit: ^11
- symfony/http-client: ^7
Suggests
- aws/aws-sdk-php: Allows using the AWS Bedrock SDK
- google/auth: Allows using the Google Vertex SDK
This package is not auto-updated.
Last update: 2026-03-05 20:29:27 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"
Getting started
<?php
use Anthropic\Client;
$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: 'claude-opus-4-6',
);
var_dump($message->content);
Requirements
PHP 8.1.0+
Contributing
See CONTRIBUTING.md.
License
This project is licensed under the MIT License. See the LICENSE file for details.