Download the PHP package aerobit/openai-agents without Composer
On this page you can find all versions of the php package aerobit/openai-agents. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package openai-agents
OpenAI Agents for Laravel
This package provides a lightweight integration of the OpenAI PHP client with Laravel 12, inspired by the OpenAI Agents Python SDK.
Installation
Publish the configuration file:
Set your OPENAI_API_KEY in the environment file or edit config/agents.php.
Usage
Send a message to the default agent:
You can control the number of turns or provide a system prompt using options:
You can also resolve the AgentManager service from the container to create agents programmatically.
The returned Agent instance retains the conversation history, allowing for multi-turn chats:
The agent can also convert text responses to speech:
You can optionally provide a system prompt when constructing the agent:
For more advanced scenarios you can use the Runner class which loops until the
agent returns a final response or a turn limit is reached. Tools and basic handoffs
can be registered on the runner:
The runner can request structured JSON output by providing an output schema:
Tools may also be defined with JSON schemas for OpenAI function calling:
If you need non-blocking execution you can run the runner inside a PHP Fiber:
You can also stream results as they're generated:
Voice pipeline
Use the VoicePipeline class to handle audio transcription and text-to-speech in one step:
Tracing
The package includes a simple tracing system that lets you observe each turn
of a Runner execution. Enable tracing in config/agents.php and register one
or more processors to handle trace records:
When enabled, each call to Runner::run() will emit start and end span events
as well as per-turn events containing the input and output.
Guardrails
Guardrails let you validate input and output during a run. They can transform the content or throw an exception to stop execution.
Configuration
The config/agents.php file allows you to customize the default model and parameters used when interacting with OpenAI. It also contains options to enable tracing and provide custom processors for handling trace data.
License
Released under the MIT license.
All versions of openai-agents with dependencies
illuminate/support Version ^12.0
openai-php/client Version ^0.6
symfony/http-client Version ^7.3
nyholm/psr7 Version ^1.8