All notable changes to anthropic-php will be documented in this file.
Upload a document once and reference it by file_id on later Messages calls. Useful for repeated PDFs and images, and for reading outputs produced by the code execution tool and Skills.
Five methods on $client->files():
upload(array $parameters): multipart upload, returns aFileResponselist(array $parameters = []): cursor-paginated listingretrieveMetadata(string $fileId): fetch metadata for a single filedownload(string $fileId): raw bytes for files produced by code execution or Skills (user-uploaded files are not downloadable)delete(string $fileId): returns aDeletedFileResponse
$file = $client->files()->upload([
'file' => fopen('/path/to/doc.pdf', 'r'),
]);
$response = $client->messages()->create([
'model' => 'claude-opus-4-6',
'max_tokens' => 1024,
'betas' => ['files-api-2025-04-14'],
'messages' => [[
'role' => 'user',
'content' => [
['type' => 'text', 'text' => 'Summarise this.'],
['type' => 'document', 'source' => ['type' => 'file', 'file_id' => $file->id]],
],
]],
]);Anthropic currently flags the Files endpoints as beta. The SDK auto-injects the required anthropic-beta: files-api-2025-04-14 header on every $client->files() call, so you don't type the version string. When you reference a file_id inside a Messages call, pass 'betas' => ['files-api-2025-04-14'] on that call too; the Messages endpoint also needs the header when a file is referenced.
New Files usage guide covers upload, list, retrieve, download, delete, and Messages integration, including the per-call betas pattern for referencing uploaded files.
Every Files response DTO has a fake() method for use with ClientFake:
FileResponse::fake()FileListResponse::fake()DeletedFileResponse::fake()
- Add Files API resource by @mozex in #17
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.6.0...1.7.0
- Add
betasparameter for per-request beta feature opt-in by @mozex in #16
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.5.0...1.6.0
Models API
- Add
maxInputTokensandmaxTokensproperties toRetrieveResponse(and every item returned byListResponse) - Add typed
capabilitiestree on model responses:batch,citations,codeExecution,imageInput,pdfInput,structuredOutputs,thinking(withtypes.adaptiveandtypes.enabled), andeffort(withlow,medium,high,maxlevels) - Add
capabilities.contextManagementas a map keyed by the raw API strategy name (clear_thinking_20251015,clear_tool_uses_20250919,compact_20260112, and any future version), so new strategies Anthropic ships are captured automatically without a package update
Messages API
- Add
stop_detailsonCreateResponsewithtype,category, andexplanation— populated whenstop_reasonis'refusal' - Add
callerontool_useandserver_tool_usecontent blocks (typeandtool_id) so direct model calls can be distinguished from calls made inside a code execution sandbox - Add
container_uploadcontent block support withfile_id - Add
inferenceGeotoCreateResponseUsageandCreateStreamedResponseUsage, surfacing which region handled the request ('us','eu', ornull) - Document the new
pause_turnandrefusalstop reasons and the idiom for resuming paused turns
Meta information
- Add
priorityInputTokenLimitandpriorityOutputTokenLimitonMetaInformation, parsing the sixanthropic-priority-*headers into typed properties instead of dropping them into the genericcustombucket
Documentation
- Ship the full documentation site at mozex.dev/docs/anthropic-php/v1 with dedicated pages for every feature: introduction, configuration, messages, tool use, server tools, streaming, thinking, citations, batches, token counting, models, completions, meta information, testing, and error handling
- Every page now links back to the matching Anthropic reference on
platform.claude.com/docs/
tool_use/server_tool_usetoArray()output now includes thecallerobject when present, so response round-trips stay losslessMetaInformationrate-limit headers (including the new priority tier) round-trip cleanly throughtoArray()
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.4.0...1.5.0
- Add adaptive thinking support (
thinking.type: "adaptive") for Claude Opus 4.6 and Sonnet 4.6 - Add
displayoption on thinking config (summarized/omitted) to control thinking output in responses - Add
output_config.effortparameter for guiding thinking depth (max,high,medium,low) - Add
server_tool_usecontent block type for server-side tools (web search, web fetch, code execution, tool search) - Add
web_search_tool_resultcontent block type with search results array - Add
web_fetch_tool_resultcontent block type - Add
code_execution_tool_result,bash_code_execution_tool_result, andtext_editor_code_execution_tool_resultcontent block types - Add
tool_search_tool_resultcontent block type - Add
tool_use_idandcontentproperties onCreateResponseContentfor all server tool result blocks - Add
containerfield onCreateResponsefor code execution sandbox persistence - Add
citationsarray on text content blocks, supporting all 5 citation location types:char_location,page_location,content_block_location,web_search_result_location,search_result_location - Add
citations_deltastreaming support withcitationproperty onCreateStreamedResponseDelta - Add
webFetchRequests,codeExecutionRequests, andtoolSearchRequeststoCreateResponseUsageServerToolUse - Add streaming support for
server_tool_useand server tool result blocks inCreateStreamedResponseContentBlockStart
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.3.3...1.4.0
- updated model names for consistency
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.3.2...1.3.3
- add batch response return type to client fake
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.3.1...1.3.2
- Add dedicated
inputTokenLimitandoutputTokenLimitrate limit properties toMetaInformation - Add
cache_creationbreakdown to usage (CreateResponseUsageCacheCreationwithephemeral5mInputTokensandephemeral1hInputTokens) - Add
serviceTierfield to usage (standard, priority, or batch) - Add
serverToolUsefield to usage (CreateResponseUsageServerToolUsewithwebSearchRequests)
- Input/output token rate limit headers are now parsed as dedicated properties instead of falling into the generic
custombucket - Usage objects now capture all fields returned by the API instead of silently dropping extended fields
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.3.0...1.3.1
- Add Message Batches support — create, retrieve, list, cancel, delete, and stream results
- Add
BatchResponse,BatchListResponse,DeletedBatchResponse, andBatchResultResponseresponse DTOs - Add
BatchIndividualResponse,BatchResult, andBatchResultErrorfor parsing JSONL batch results - Add
BatchResponseRequestCountsfor tracking processing, succeeded, errored, canceled, and expired counts - Add
BatchResultResponse::fake()for consumer testing withClientFake - Add dedicated
inputTokenLimitandoutputTokenLimitrate limit properties toMetaInformation - Add
cache_creationbreakdown to usage (CreateResponseUsageCacheCreationwithephemeral5mInputTokensandephemeral1hInputTokens) - Add
serviceTierfield to usage (standard, priority, or batch) - Add
serverToolUsefield to usage (CreateResponseUsageServerToolUsewithwebSearchRequests)
- Input/output token rate limit headers are now parsed as dedicated properties instead of falling into the generic
custombucket - Usage objects now capture all fields returned by the API instead of silently dropping extended fields
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.2.3...1.3.0
- add count tokens support
- add models list and retrieve support
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.2.2...1.2.3
- added thinking support
- add anthropic-version header to the factory
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.2.1...1.2.2
- Add missing
cache_creation_input_tokensandcache_read_input_tokenstoCreateStreamedResponseUsage
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.2.0...1.2.1
- Add
RateLimitExceptionfor HTTP 429 responses (extendsErrorException— no breaking changes) - Add PSR-7 response access on
ErrorExceptionandUnserializableResponsevia$e->response - Add
MetaInformationCustomfor capturing non-standard response headers via$meta->custom - Add
OverrideStrategyenum for controllingfake()override merging behavior - Add
addHeader()method toTransporterContractfor runtime header injection
- Preserve API error message on rate limit responses instead of using a generic message
- Use
(string) $response->getBody()instead ofgetContents()for reliable stream reading - Add
JSON_UNESCAPED_UNICODEflag for proper Unicode handling in request payloads - Simplify
Fakeabletrait usingarray_replace_recursive - Fix namespace resolution in
Fakeablestr_replacecall - Parameterize
Streamabletrait methods for flexibility
See UPGRADING.md for details. All changes are backwards compatible.
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.1.0...1.2.0
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.0.3...1.1.0
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.0.2...1.0.3
- Bump dependencies
- Refactoring
Full Changelog: https://github.com/mozex/anthropic-php/compare/1.0.1...1.0.2
- fix client fake types
Initial Release