Download the PHP package agentphp/sdk without Composer

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

AgentPHP SDK

CI Latest Stable Version Total Downloads License PHP Version

A comprehensive PHP SDK for building AI conversational agents with support for multiple LLM providers (OpenAI, Anthropic, Google), tools, streaming, and human-in-the-loop workflows.

Features

Requirements

Installation

Quick Start

Table of Contents


Standalone Usage (Legacy PHP)

Basic Chat

Conversation Memory

Configuration Options

Complete Standalone Example


Laravel Integration

Installation

The service provider is auto-discovered. For manual registration:

Publish Configuration

Configuration

Environment Variables

Using the Facade

Using Dependency Injection

Using AgentBuilder in Laravel

Registering Tools in Laravel

You can register tools directly on the Agent instance:

Or register a single tool:

Alternatively, you can register tools globally in the ServiceProvider (less recommended):

Laravel Streaming Response


Symfony Integration

Installation

Enable the Bundle

Configuration

Environment Variables

Using in Controllers

Symfony Streaming Response

Using AgentBuilder in Symfony

Registering Tools as Services


Providers

OpenAI

Anthropic (Claude)

Google (Gemini)

Custom Provider

Provider Factory


System Prompts

System prompts define the behavior and personality of your agent.

Basic System Prompt

Detailed System Prompt

Dynamic System Prompts

Multi-Language Support

Role-Based System Prompts


Tools

Tools allow your agent to perform actions and access external data.

Creating a Tool

Extend AbstractTool and implement the handle() method:

The AbstractTool base class:

Registering Tools

Tool Schema Builder

Tool with Approval Required

For sensitive operations, set $requiresApproval = true:

Using Tools with Agent

Tool Registry

Manual Tool Execution


Streaming

Streaming allows you to receive tokens in real-time as they are generated. All providers (OpenAI, Anthropic, Google) support streaming.

How Streaming Works

When you call $agent->chatStream(), it returns a StreamInterface object. This object provides methods to iterate over chunks of text as they arrive from the LLM provider, instead of waiting for the complete response.

Legacy PHP - Terminal/CLI Streaming

Complete example for running in terminal:

Run it:

Legacy PHP - Web Browser SSE Streaming

Complete example for streaming to a web browser using Server-Sent Events (SSE):

Backend (stream.php):

Frontend (index.html):

Legacy PHP - AJAX POST Streaming

For POST requests with the Fetch API:

Backend (api_stream.php):

Frontend JavaScript (Fetch API):

StreamChunk Methods

Each chunk in the stream provides these methods:

Getting the Complete Response After Streaming

Streaming with Different Providers

All providers use the same streaming interface:

Error Handling in Streams

Nginx Configuration for SSE

If using nginx, add this to your location block:

Apache Configuration for SSE

For Apache with mod_php, streaming should work out of the box. If using PHP-FPM:


Middleware

Middleware allows you to intercept and modify requests/responses.

Built-in Middleware

Logging Middleware

Retry Middleware

Rate Limit Middleware

Timeout Middleware

Combining Middleware

Custom Middleware

Authentication Middleware

Content Filter Middleware


Human-in-the-Loop

Enable approval workflows for sensitive operations.

Basic Setup

Custom Approval Handler

Auto-Approval for Development


Error Handling


Development

Setup

Testing

Contributing

Contributions are welcome! Please read our Contributing Guide for details.

License

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

Security

If you discover any security-related issues, please email [email protected] instead of using the issue tracker.


All versions of sdk with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
guzzlehttp/guzzle Version ^7.0
psr/http-client Version ^1.0
psr/log Version ^1.1 || ^2.0 || ^3.0
psr/simple-cache Version ^3.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 agentphp/sdk contains the following files

Loading the files please wait ...