PHPackages                             sk-wang/hao-code - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [CLI &amp; Console](/categories/cli)
4. /
5. sk-wang/hao-code

ActiveLibrary[CLI &amp; Console](/categories/cli)

sk-wang/hao-code
================

PHP agent SDK for Anthropic, OpenAI Responses, and OpenAI Chat Completions APIs.

v1.18.60(2w ago)102146↑140%9MITPHPPHP ^8.1CI passing

Since Apr 4Pushed 2w ago7 watchersCompare

[ Source](https://github.com/skvdhshuk-blip/hao-code)[ Packagist](https://packagist.org/packages/sk-wang/hao-code)[ Docs](https://github.com/skvdhshuk-blip/hao-code)[ RSS](/packages/sk-wang-hao-code/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (61)Versions (115)Used By (0)

hao-code
========

[](#hao-code)

A framework-free PHP Agent SDK for Anthropic, OpenAI Responses, and OpenAI Chat Completions-compatible APIs.

`hao-code` lets PHP applications embed an AI coding agent with tools, skills, streaming output, multi-turn sessions, structured JSON results, durable human approval, agent teams, cost tracking, abort control, credential pools, and isolated runtime storage.

For the complete SDK reference, see [docs/SDK.md](docs/SDK.md).

Looking for a ready-to-use desktop application powered by HaoCode? See [Hao Work](https://github.com/skvdhshuk-blip/hao-work).

Requirements
------------

[](#requirements)

- PHP `^8.1`
- Composer; Symfony `^6.4`, `^7.0`, or `^8.0` components are installed as package dependencies
- Optional `pcntl` and `posix` extensions for background agents and agent teams
- macOS `/usr/bin/sandbox-exec` or Linux `bubblewrap` when using the native local sandbox
- Optional `zstd` and `tar` when installing the Tokimo guest kernel/rootfs
- Optional Linux `bubblewrap`, or KVM plus `cloud-hypervisor` and `virtiofsd`, for the Tokimo backend
- Optional Windows Virtual Machine Platform plus its one-time SYSTEM service for the Tokimo backend

Install
-------

[](#install)

```
composer require sk-wang/hao-code
```

This installs the PHP SDK only. It does not download Tokimo or any native sandbox binaries.

### Optional Tokimo sandbox

[](#optional-tokimo-sandbox)

Install the optional cross-platform sandbox now or at any later time:

```
# Runner only; use this when you already have a compatible baseRootfs:
vendor/bin/hao-code-sandbox install

# Recommended first-time setup; also downloads the guest kernel/rootfs:
vendor/bin/hao-code-sandbox install --with-runtime

# Show the currently installed runner:
vendor/bin/hao-code-sandbox status
```

Composer has no dependency-specific `require` flag for this, and dependency package scripts are not executed automatically. For a one-line initial setup, run:

```
composer require sk-wang/hao-code && vendor/bin/hao-code-sandbox install --with-runtime
```

You do not need to install Tokimo separately. The installer downloads the verified runner and, with `--with-runtime`, the guest kernel/rootfs artifacts for the current OS/CPU into the user cache. On macOS and Linux, full runtime setup may ask for `sudo` while extracting the rootfs so its Linux uid/gid ownership is preserved. From a hao-code source checkout, replace `vendor/bin/hao-code-sandbox` with `bin/hao-code-sandbox`.

Quick Start
-----------

[](#quick-start)

Set the API key in the process environment:

```
export ANTHROPIC_API_KEY=your-api-key
```

Then create `example.php`:

```
