Download the PHP package refinephp/laravel-ai-batch without Composer

On this page you can find all versions of the php package refinephp/laravel-ai-batch. 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 laravel-ai-batch

Laravel AI Batch

Provider-native asynchronous batch workflows for the Laravel AI SDK.

Laravel AI Batch lets an existing Laravel AI agent produce normal synchronous requests and OpenAI Batch API requests without defining its instructions, messages, tools, schema, model options, or provider options twice.

Run Laravel AI agents through provider-native batch APIs.

Requirements and compatibility

The bounded Laravel AI constraint is intentional. Laravel AI does not currently expose a public resolved-request API, so this package isolates and tests one protected integration point and verifies its signature at runtime. The upper bound is raised only after that surface is re-verified against a new minor. See Compatibility for the policy and risks.

Installation

The service provider and AiBatch facade are discovered automatically.

Configure the existing native OpenAI connection in config/ai.php:

Laravel AI Batch reads that connection. It does not define or persist a second API key.

Configuration

config/ai-batch.php controls:

The default limits match OpenAI: 50,000 requests and 200 MB. Lower them for application-specific safety; do not configure values above OpenAI's limits and expect them to work.

The Eloquent repository stores lifecycle metadata only. With AI_BATCH_REPOSITORY=null, submission and lifecycle operations work while the application retains each immutable ProviderBatch, but find(), polling commands, and durable recovery are unavailable.

Define a Laravel AI agent

This is a normal Laravel AI agent and can still be used synchronously:

Create a batch from the same agent

Laravel AI's real invocation input is a string prompt plus optional attachments and model. add() deliberately mirrors that contract; it does not invent an arbitrary context array.

Custom IDs must be non-empty and unique. Valid IDs are preserved byte-for-byte and are the only supported result-correlation key.

Every item is resolved before upload. If any prompt, attachment, model, provider option, schema, or generated line is invalid, submission stops before the remote input file is uploaded.

Attachments

Pass the same Laravel AI attachment objects that the synchronous agent accepts:

Local and storage-backed attachments are read during resolution and may be base64-expanded into JSONL. Application-configured byte limits apply after expansion.

Resolve and submit provider requests directly

Resolve an item explicitly when you need the provider-ready body or an individually constructed agent. Per-item constructor state belongs on that real agent, not in a second batch context format:

Resolution uses Laravel AI's normal first-request pipeline and makes no provider HTTP call. It preserves instructions, conversation messages, prompt and attachments, model selection, provider options, tools, structured output, tool choice, and supported middleware revisions.

Retrieve and refresh status

Snapshots are immutable. Reassign the refreshed value:

Important fields include status(), providerStatus(), requestCount(), completedCount(), failedCount(), inputFileId(), outputFileId(), errorFileId(), and lifecycle timestamps.

Poll with queues and the scheduler

Polling is opt-in. The command dispatches one idempotent queued job per pollable batch:

Add an application-owned schedule in routes/console.php:

Each lifecycle operation uses an atomic per-batch cache lock, re-reads the latest snapshot inside the lock, and skips terminal batches. Duplicate jobs and concurrent cancellation therefore converge safely. The configured cache store must support atomic locks.

Inspect locally persisted status without a provider call:

See Lifecycle for locking, retries, and transition behavior.

Retrieve results

OpenAI output order is not input order. The package parses both output and error files and yields correlated outcomes by custom_id:

Results are lazy and are not stored by the package. A malformed, duplicate, partial, or incomplete terminal result set throws a purpose-specific exception, possibly after earlier lazy records have been yielded; make application result processing idempotent.

Handle per-item and validation errors

BatchResult::error() represents an HTTP or provider execution failure for one custom ID. Batch-level input validation errors do not always identify a custom ID:

Avoid logging $error->message() unless the application's privacy policy permits provider-supplied text. Do not log complete response bodies.

Cancel a batch

Or use the lock-aware command:

Cancellation is asynchronous. OpenAI can report cancelling for up to ten minutes before cancelled, and partial results may remain available. Poll until terminal. If a cancellation response is lost, the package reconciles with a retrieval call and never blindly repeats the cancellation POST.

Jobs and events

Version one ships the retryable PollBatch queued job used by ai:batch:poll. It intentionally does not ship automatic result-handler jobs or package events with sensitive payloads. Applications should dispatch their own idempotent processing jobs while iterating AiBatch::results().

Testing an application

Normal package tests never contact OpenAI. In application tests, use Laravel HTTP fakes for lifecycle endpoints and prevent stray requests:

Do not call Laravel AI's Agent::fake() when testing request resolution: this package rejects active agent fakes because they bypass the native OpenAI request builder. Use a real test agent plus Http::preventStrayRequests() to prove resolution itself sends nothing.

Security and privacy

Report vulnerabilities according to SECURITY.md.

OpenAI limitations

Version one supports only native OpenAI Batch requests targeting POST /v1/responses with a 24h completion window. It does not claim support for chat completions, embeddings, legacy completions, moderation, images, or videos even though OpenAI Batch supports some of them.

One item is one initial provider request. Function, sub-agent, and MCP tool definitions can be serialized, but the package does not execute Laravel-side tool or approval continuations after asynchronous output. It also does not append completed turns to Laravel AI conversation storage.

Provider failover, streaming, real-time calls, custom OpenAI-compatible URLs, Azure OpenAI, dashboards, workflow engines, automatic schedules, and automatic prompt/result storage are outside version one.

Roadmap

Contributing

See CONTRIBUTING.md. Changes to compatibility adapters or public contracts must include research, parity tests, and documentation. Run:

License

Laravel AI Batch is open-source software licensed under the MIT license.


All versions of laravel-ai-batch with dependencies

PHP Build Version
Package Version
Requires php Version ^8.3
illuminate/cache Version ^12.0|^13.0
illuminate/console Version ^12.0|^13.0
illuminate/config Version ^12.0|^13.0
illuminate/container Version ^12.0|^13.0
illuminate/contracts Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
laravel/ai Version >=0.9.0 <1.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 refinephp/laravel-ai-batch contains the following files

Loading the files please wait ...