Download the PHP package rkzack/akit without Composer

On this page you can find all versions of the php package rkzack/akit. 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 akit

akit — Anthropic Kit for PHP

Lightweight PHP 8.4 toolkit for building AI-powered applications with the Anthropic API.

Zero production dependencies. Uses only PHP's built-in curl and json extensions. Fully typed with PHP 8.4 features: readonly classes, enums, named arguments, and array_find.


Requirements

Installation

Copy .env.example to .env and add your key:

vendor/ is generated by Composer — keep it in .gitignore and never edit it directly. Commit composer.lock; teammates run composer install to get identical versions.


Quick Start


Usage

Single Prompt

System Prompt

Multi-turn Conversation

The Conversation class tracks message history automatically — no need to manage arrays.

Streaming

Chunks arrive as they are generated rather than waiting for the full response. Ideal for long outputs, CLI tools, or real-time web UIs.

Model Selection

Available models:

Enum constant Model ID
Model::OPUS_4_7 claude-opus-4-7
Model::SONNET_4_6 claude-sonnet-4-6 (default)
Model::HAIKU_4_5 claude-haiku-4-5-20251001

Environment-based Configuration

Manual Message Arrays (Advanced)


Global Helper Functions

Helper functions wrap the shared singleton client seeded from ANTHROPIC_API_KEY. They are the fastest way to add Claude to a script.

Function Description
akit_prompt(string $prompt, ...) Send a prompt, get back the text string
akit_stream(string $prompt, callable $onChunk, ...) Stream a response
akit_chat(array $messages, ...) Multi-message array → Response
akit_client(?string $apiKey, ?string $model) Get or create the shared Client

API Reference

Client

Method Signature Returns
prompt (string $prompt, ?string $system, ?string $model, ?int $maxTokens) Response
chat (Message[] $messages, ?string $system, ?string $model, ?int $maxTokens) Response
stream (string\|Message[] $prompt, callable $onChunk, ?string $system, ?string $model, ?int $maxTokens) void
conversation (?string $system) Conversation
config () Config

Response

Method Returns Description
text() string Primary text content
model() string Model that generated the response
stopReason() string end_turn, max_tokens, etc.
usage() array {input_tokens, output_tokens}
totalTokens() int Input + output tokens
id() string Anthropic message ID
content() array All raw content blocks
raw() array Full decoded API payload
asMessage() Message Convert to assistant Message
__toString() string Alias for text()

Conversation

Method Returns Description
say(string $message, ...) Response Send a turn, append history
messages() Message[] Full history so far
turns() int Number of user turns
reset() void Clear history (keeps system prompt)

Config

Property Type Default
apiKey string (required)
model string claude-sonnet-4-6
maxTokens int 1024
baseUrl string https://api.anthropic.com/v1
apiVersion string 2023-06-01
timeout int 30 (seconds)

Error Handling

All exceptions extend Akit\Exceptions\AkitException.

Exception HTTP Status Cause
AuthException 401 Invalid or missing API key
ApiException 4xx / 5xx Rate limit, overload, bad request, etc.

Running the Examples


Running Tests


Contributing

  1. Fork the repo and create a branch from main.
  2. Add tests for any new behaviour.
  3. Run ./vendor/bin/phpunit and ./vendor/bin/phpstan analyse before opening a PR.
  4. Keep it lightweight — no new production dependencies without strong justification.

License

MIT — see LICENSE.


All versions of akit with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
ext-curl Version *
ext-json Version *
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 rkzack/akit contains the following files

Loading the files please wait ...