Download the PHP package vielhuber/aihelper without Composer

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

build status GitHub Tag Code Style License Last Commit PHP Version Support Packagist Downloads

🤖 aihelper 🤖

aihelper provides a single, consistent php interface for multiple ai providers. it supports chat and vision use cases, session-aware conversations, robust retry logic, logging, simple cost tracking, and optional model context protocol (mcp) integration — all behind one method.

installation

usage

cli harnesses

the providers claudecode, codex and opencode drive the locally installed cli agent instead of a chat completion endpoint. they own their system prompt, tools and history, so only the newest user turn is handed over. install and log them in once:

by default every turn continues the newest thread of cli_workdir and opens a new one only when that directory has none yet. set cli_resume_latest: false for an explicitly fresh thread, then persist $ai->getCliSessionId() and pass it as cli_session_id on later calls to resume that exact native thread. an explicit cli_session_id always takes precedence. codex keeps injected config and skills isolated per aihelper session while storing its threads in the native ~/.codex state. to include threads originally started by aihelper's non-interactive codex exec, resume from an interactive terminal with codex resume --last --include-non-interactive.

pass cli_session_home to keep one harness session's native history, configuration and skills in a dedicated persistent directory. pass cli_auth_home separately to share one authenticated subscription across multiple session homes without sharing their histories or configuration. both options work for claude code, codex and opencode and can also be changed before the first request with setCliStorage().

set cli_native_memory: false when the caller supplies its own long-term memory. claude code then disables auto memory while retaining CLAUDE.md, plugins and skills; codex neither generates nor loads its native memories. opencode currently has no equivalent automatic semantic memory layer, so the option does not alter its sessions or instruction files.

set cli_ssh_host to run the agent on another machine instead of locally — the working directory, the login and the threads are then that machine's:

streaming

aihelper can stream model output to a browser using server‑sent events (see). in this mode the php backend connects to the model provider with http streaming and forwards chunks to the client as sse events in real time. see an example implementation at /tests/stream/index.html.

event: reasoning contains native model reasoning and a provider-independent, redacted process transcript for tool, shell, file, search, plan and skill activity. Large details are shortened only in this visible stream; getSessionContent() retains the complete structured tool history. if streaming stutters on apache2 with php‑fpm, be sure that gzip is disabled for the streaming route and also adjust your virtualhost so fastcgi forwards packets immediately (no buffering):

before

after

aborting a request

pass an abort_callback to stop a request that is already running. it is asked between chunks, so keep it cheap — a file check or a flag, never a database round trip. hand it over on create() or later with setAbortCallback(), which also accepts null to clear it again.

with a chat completion endpoint the http stream is cancelled mid-transfer. a cli harness receives SIGINT first so it can close its append-only session file the way ctrl+c would, and is terminated on the local and the remote side only afterwards; the interrupted turn stays in the native thread and is resumed by the next call. check $result['aborted'] to tell a stop apart from a failure — a stopped request has no answer, but nothing went wrong, and it is never retried. a callback that throws counts as "keep going", so an unreachable cancel signal cannot kill a healthy request.


All versions of aihelper with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
vielhuber/stringhelper Version ^7.3.4
fakerphp/faker Version ^1.24.1
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 vielhuber/aihelper contains the following files

Loading the files please wait ...