Skip to content

Access to Anthropic's safety-first language model APIs in PHP

License

Notifications You must be signed in to change notification settings

anthropics/anthropic-sdk-php

Repository files navigation

Claude SDK for PHP

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.

About

Access to Anthropic's safety-first language model APIs in PHP

Resources

License

Contributing

Security policy

Stars

Watchers

Forks

Packages