Download the PHP package mozex/anthropic-php without Composer

On this page you can find all versions of the php package mozex/anthropic-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package anthropic-php

Anthropic PHP

Latest Version on Packagist GitHub Checks Workflow Status Docs License Total Downloads

A community-maintained PHP SDK for the Anthropic API. Send messages, stream responses, call tools, use extended thinking, search the web, execute code, process batches, and more. Works with any PSR-18 HTTP client.

Read the full documentation at mozex.dev: searchable docs, version requirements, detailed changelog, and more.

Using Laravel? Check out Anthropic Laravel, which wraps this SDK with service container integration, config-based setup, and a facade.

Table of Contents

Support This Project

I maintain this package along with several other open-source PHP packages used by thousands of developers every day.

If my packages save you time or help your business, consider sponsoring my work on GitHub Sponsors. Your support lets me keep these packages updated, respond to issues quickly, and ship new features.

Business sponsors get logo placement in package READMEs. See sponsorship tiers →

Why This Package

Built-in test client. Swap Anthropic\Client with ClientFake in your tests, queue fake responses, and assert exactly which requests were sent. No HTTP mocking libraries needed, no test server to run. See the testing docs →

Forward-compatible. Parameters pass through to the API as-is. When Anthropic ships a new feature (a new tool type, a new thinking mode, a new parameter), it works in your code the same day. You don't wait for an SDK release.

Typed, immutable responses. Every response is a readonly PHP object with typed properties. Access $response->usage->inputTokens, not $response['usage']['input_tokens']. Full IDE autocompletion, no guessing.

Rate limits on every response. Call $response->meta() on any response (including streams and batch results) to get your current request limits, token limits, and reset times.

Any HTTP client. Built on PSR-18, so it works with Guzzle, Symfony HTTP Client, Buzz, or whatever your project already uses. No vendor lock-in.

Installation

Requires PHP 8.2+ - see all version requirements

The included php-http/discovery plugin finds and installs a compatible PSR-18 HTTP client automatically. If you want to use a specific one (like Guzzle or Symfony), see Configuration.

Quick Start

Create a client, send a message, read the response:

Streaming

Print text as it arrives:

Tool Use

Give Claude tools to call, execute them in your code, send results back:

Extended Thinking

Let Claude reason through complex problems before answering:

Configuration

For custom base URIs, timeouts, or HTTP clients, use the factory:

The full documentation covers every feature in detail: web search and code execution, document citations, token counting, batch processing, error handling, rate limits, and more.

Resources

Visit the documentation site for searchable docs auto-updated from this repository.

License

The MIT License (MIT). Please see License File for more information.


All versions of anthropic-php with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2.0
php-http/discovery Version ^1.20.0
php-http/multipart-stream-builder Version ^1.4.2
psr/http-client Version ^1.0.3
psr/http-client-implementation Version ^1.0.1
psr/http-factory-implementation Version *
psr/http-message Version ^1.1.0|^2.0.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package mozex/anthropic-php contains the following files

Loading the files please wait ...