Anthropic PHP SDK

Installs: 78 776

Dependents: 2

Suggesters: 0

Security: 0

Stars: 92

Watchers: 2

Forks: 18

Open Issues: 7

pkg:composer/anthropic-ai/sdk

v0.6.0 2026-02-19 19:42 UTC

README

Packagist Version

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.