
Anthropic SDK for PHP
https://github.com/anthropics/anthropic-sdk-php- Category
- AI Tools
- Rank
- No. 400Tools index
- Pricing
- Open Source
- Type
- TOOL
- Builder
- anthropics
- GitHub
- 177 stars
- Latest release
- v0.47.0
- Date
About
Official PHP client library for the Anthropic Claude API.
What it does
It gives PHP applications typed access to Claude messages and related API resources. Beyond ordinary requests, it handles server-sent event streams, structured outputs mapped to PHP classes, paginated results, file uploads, retries, typed errors, middleware, and custom endpoints or parameters.
Why it's ranked here
This is a capable integration layer, not a thin request wrapper. Automatic pagination, configurable retries, stream accumulation, typed structured output, and per-attempt middleware address real production concerns. Its prerelease status and reliance on a separately installed HTTP client temper that breadth.
What's good
Streaming support includes an accumulator that joins text, assembles chunked tool inputs, merges usage totals, and exposes partial snapshots. Structured output converts PHP classes into JSON schemas and parses results back into typed objects. Middleware can log, alter headers, cache responses, or issue follow-up requests.
Tradeoffs
The package requires PHP 8.1 or newer and a compatible PSR-18 HTTP client implementation. Some clients buffer complete responses, so streaming may require a separate capable transport. The package remains below version one, and its documentation warns that APIs may change at any time.
How to use it well
Choose it for PHP services that need Claude requests, streaming, uploads, structured responses, pagination, or transport customization. Configure retry behavior deliberately and verify that your HTTP client truly streams. It does not supply the underlying HTTP client, and optional Bedrock, Vertex, and MCP integrations require additional packages.
Technical notes+
README.md documents SSE streaming through a separate streamingTransporter, accumulation through Anthropic\Lib\Streaming\MessageAccumulator, typed structured output, pagination, retries, uploads, custom requests, and middleware. composer.json publishes anthropic-ai/sdk, requires PHP ^8.1, PSR HTTP interfaces and implementations, and suggests optional AWS, Google, and MCP packages. CONTRIBUTING.md says most SDK code is generated and that most tests require an OpenAPI-backed mock server. phpunit.xml.dist targets tests, while phpstan.dist.neon analyzes src and tests at maximum level. .stats.yml records 130 configured endpoints.
Observed
- License
- MIT
- Primary language
- PHP
- Packaging
- Composer package anthropic-ai/sdk with PSR-4 autoloading
- Install surface
- Library installed through Composer
- Interface
- PHP client library for the Claude API
- Runtime requirement
- PHP 8.1 or newer and a PSR-18 HTTP client implementation
- Transport support
- Standard requests and Server-Sent Events streaming
- Repository structure
- Source and test directories are configured for PHPUnit, PHPStan, and PHP CS Fixer
Read from README.md, composer.json, LICENSE, .stats.yml, SECURITY.md, CHANGELOG.md, .phpactor.json, CONTRIBUTING.md, phpunit.xml.dist, phpstan.dist.neon, .php-cs-fixer.dist.php, release-please-config.json, .release-please-manifest.json, scripts/lint, scripts/mock.
What it can do
Send text prompts to Claude AI
Text prompts and conversation messages → AI-generated text responses
Generate code from natural language descriptions
Natural language descriptions of programming tasks → Generated code in specified programming languages
Analyze and summarize documents
Document text content → Document summaries and analysis
Answer questions based on provided context
Context text and questions → Contextual answers and explanations
Translate text between languages
Text in source language and target language specification → Translated text in target language
Process conversational interactions
Multi-turn conversation history and new messages → Contextual conversation responses
Configure API authentication and settings
API keys and configuration parameters → Authenticated API client instance
Tags
Tech Stack
Comments (0)
No comments yet
Editorially curated, with community endorsements as a secondary signal. Corrections welcome.