Download the PHP package alle-ai/anthropic-api-php without Composer
On this page you can find all versions of the php package alle-ai/anthropic-api-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alle-ai/anthropic-api-php
More information about alle-ai/anthropic-api-php
Files in alle-ai/anthropic-api-php
Package anthropic-api-php
Short Description The go-to PHP library for the Anthropic API — Messages, streaming, tool use, vision, prompt caching, extended thinking, MCP, Files, Batches. Maintained by Alle-AI.
License MIT
Homepage https://github.com/Alle-AI/anthropic-api-php
Informations about the package anthropic-api-php
anthropic-api-php
The go-to PHP library for the Anthropic API. Maintained by Alle-AI.
A first-class PHP client for the Anthropic Messages API. Built for Claude 4 and beyond — Messages, streaming, tool use, vision, prompt caching, extended thinking, MCP connector, Files, Batches. Works with the direct API, AWS Bedrock, and Google Vertex AI.
Looking for the v1.x docs? See the
1.xbranch. The v1 surface (Alle_AI\Anthropic\AnthropicAPI) is preserved as a deprecation shim through the v2.x line and removed in v3.0. See UPGRADING.md.
Features
- Messages API — typed requests and responses for
POST /v1/messages - Streaming — Generator-based SSE iterator with
->toMessage()aggregator - Tool use — closure tools, class-based tools with reflection-driven JSON Schema, automatic tool-loop helper
- Vision —
ImageBlock::fromFile()/fromUrl()/fromBase64() - Prompt caching —
cache_controlon any block;Usage::$cacheReadInputTokensin the response - Extended thinking —
ThinkingConfig::enabled(budgetTokens: 10_000)for reasoning models - MCP connector — call any remote MCP server via Anthropic's hosted connector
- Files API —
Resources\Files::upload()/get()/list()/delete()/downloadTo() - Batches API —
Resources\Batcheswith JSONL results streaming and apollUntilDone()helper - Models listing —
$client->models()->list()paginated catalog - PSR-18 / PSR-17 — bring any HTTP client (Guzzle, Symfony HttpClient, Buzz, …)
- Retries — exponential backoff with jitter, honors
Retry-After, idempotency keys auto-attached - PSR-3 logging — opt-in
LoggingMiddlewarewith correlation ids, latency, and request-id - Pluggable auth — API key, Bearer token, AWS Bedrock (SigV4), Google Vertex AI (ADC + OAuth)
Installation
Requires PHP 8.2 or newer.
You'll also need a PSR-18 HTTP client and PSR-17 factories. The most popular choice:
Quick start
From environment
Builder for advanced configuration
Streaming
Tool use
Vision
Prompt caching
Extended thinking
Error handling
Alternative deployments
Same client, different backend.
AWS Bedrock
BedrockAuth::fromEnvironment() uses the AWS default credentials chain (env vars, ~/.aws/credentials, IAM roles, etc.). The auth provider rewrites the URL to bedrock-runtime.{region}.amazonaws.com, transforms the body to Bedrock's expected shape, and signs with SigV4.
Google Vertex AI
VertexAuth::fromEnvironment() uses Google ADC for tokens. Pass projectId explicitly or set GOOGLE_CLOUD_PROJECT; same for region with GOOGLE_CLOUD_REGION.
Custom HTTP client
The SDK auto-discovers a PSR-18 client via php-http/discovery. Inject your own to gain full control:
Roadmap
| Tag | Status | Adds |
|---|---|---|
v2.0.0 |
shipped | Messages create + stream, tool use, vision, prompt caching, extended thinking, citations, Files, Batches, MCP connector, Models listing, PSR-3 logging, Bedrock + Vertex auth, server-side tools (web search / computer use / bash / text editor), Messages::createMany() concurrent fan-out, 14 examples, 186 tests, PHPStan level 9, weekly mutation testing, deprecation shim |
v2.x |
rolling | Bug fixes, new Anthropic features as they ship, additional examples |
v2.x |
future | Alle-AI sister client (AlleAI\AlleAI\Client) for multi-model fan-out |
v3.0.0 |
future | Remove Alle_AI\Anthropic\AnthropicAPI deprecation shim |
Migration from v1.x
The single-class v1 surface (Alle_AI\Anthropic\AnthropicAPI::generateText()) is preserved as a deprecation shim. Existing code keeps working — every call emits an E_USER_DEPRECATED notice. Set ALLE_AI_ANTHROPIC_FAIL_ON_DEPRECATED=1 to convert notices into exceptions during migration.
See UPGRADING.md for the full v1 → v2 guide.
About Alle-AI
This library is built and maintained by Alle-AI — Your All-In-One AI Platform. Alle-AI gives you a single interface to compare and combine outputs from frontier models (Claude, GPT, Gemini, Llama, and more). If you build on Anthropic and want to evaluate alternatives in the same workflow, check out the platform.
Support
- Bugs / feature requests: GitHub Issues
- Discussion: GitHub Discussions
- Email: [email protected]
- Security disclosures: see SECURITY.md
License
MIT © 2023–present Alle-AI. See LICENSE.
All versions of anthropic-api-php with dependencies
ext-curl Version *
ext-json Version *
psr/http-client Version ^1.0
psr/http-factory Version ^1.0
psr/http-message Version ^1.1 || ^2.0
psr/log Version ^2.0 || ^3.0
php-http/discovery Version ^1.19
ramsey/uuid Version ^4.7