Download the PHP package tracefast/laravel-ai-observability without Composer

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

Laravel AI Observability

Latest Version on Packagist Total Downloads PHP Version

OpenInference-compatible AI tracing over OpenTelemetry/OTLP for Laravel AI SDK applications.

This package listens to laravel/ai events and exports agent runs, model calls, tool calls, inputs, outputs, token usage, and errors — to your application logs, TraceFast, Phoenix, Langfuse, Braintrust, any OTLP-compatible collector, or your local database.

It's designed to be safe to drop into a project on day one. Out of the box it writes structured traces to your existing Laravel log, makes no network calls, and exports through Laravel's deferred callback lifecycle wherever possible. When you're ready for a dedicated collector, switch exporters with a single environment variable.


Table of Contents


Why this package

Requirements

Requirement Version
PHP 8.4+
Laravel 12 or 13
laravel/ai ^0.7

Installation

Install the package via Composer:

That's it — Observability is enabled by default and writes traces to your Laravel log.

To customize exporters or other settings, publish the config file:

Quick Start

The default exporter is log, which requires no further configuration:

Note: V1 captures full LLM input and output by default. See Content Capture to disable this.

For production deployments sending traces to a remote collector, keep the default defer export mode, or move exports to queue or background so trace delivery never blocks the request lifecycle. See Advanced Configuration.

Exporters

Set AI_OBSERVABILITY_EXPORTER to a single exporter:

Or send traces to multiple destinations at once:

TraceFast

The TraceFast endpoint defaults to https://collector.tracefast.dev/v1/traces. Override it only if TraceFast provides a custom collector URL:

TraceFast uses tracefast.platform to identify the integration or runtime family — not your application. This package sends laravel-ai by default, allowing TraceFast to group these traces separately from livekit, pipecat, generic OpenInference, and other sources. Your application name remains in service.name, which defaults to config('app.name').

For example, a chatbot running inside a Laravel app named Acme Support should keep tracefast.platform=laravel-ai and service.name=Acme Support. Don't put the chatbot, tenant, or product name in AI_OBSERVABILITY_PLATFORM — add that context with scoped attributes instead.

Phoenix

Langfuse

Braintrust

The Braintrust endpoint defaults to https://api.braintrust.dev/otel/v1/traces.

Log

Advanced log options:

Generic OTLP

For Laravel apps that run php artisan optimize or otherwise cache config, prefer the package-specific variables so the endpoint and headers are baked into Laravel's cached config:

The package also honors standard OTEL environment variables when they're available as real process environment variables. As of v1.1.1, these are also bridged through Laravel's config when present in .env during config caching:

OTLP payloads include OpenInference and versioned TraceFast metadata, such as openinference.schema.version, tracefast.ai.sdk.version, tracefast.ai.package.version, and OpenInference message attributes such as llm.input_messages.* and llm.output_messages.* where the Laravel AI SDK exposes the source data.

Database Exporter

The database exporter is opt-in and stores traces directly in your application's database.

Use a specific connection when needed:

The migration creates two tables: ai_observability_traces and ai_observability_spans.

Content Capture

By default, this package captures full input and output. This may include prompts, system messages, tool arguments, tool results, uploaded content, PII, secrets, and other sensitive business data.

To disable content capture:

The package uses OpenInference semantic conventions exclusively and does not emit OTel GenAI semantic convention attributes (gen_ai.*). LLM messages, model metadata, and token usage are represented once using OpenInference attributes such as llm.input_messages.*, llm.output_messages.*, llm.model_name, llm.provider, and llm.token_count.*.

Conversation Correlation

Use AiObservability::withSession() when your application has its own conversation ID:

Each turn remains its own trace, and every turn carries the same session.id. Scoped attributes are copied onto the agent, LLM, and tool spans created while the callback runs. Use them for app-specific business context such as tenant IDs, workflow names, plan names, feature flags, experiment IDs, or your existing conversation ID.

If you don't need the session.id or user.id helpers, use AiObservability::withAttributes() instead:

Keep scoped attributes separate from resource identity:

Advanced Configuration

AI_OBSERVABILITY_EXPORT_MODE accepts defer, sync, queue, or background:

Mode Behavior
defer (default) Exports after the response is sent, when Laravel can defer work. Also runs at command and queue job boundaries via Laravel's deferred callback lifecycle.
sync Exports immediately, in line with the request.
queue Hands off exports to a normal queue worker.
background Releases the current PHP worker quickly via a dedicated background queue connection.

Use queue when you want exports handled by a normal queue worker:

Use background when your Laravel app has a background queue connection and you want to release the current PHP worker quickly:

Production Transport Hardening

Custom Exporters

Implement the Exporter contract to send traces anywhere:

Register the driver from a service provider:

Then configure it:

Testing

Security

If you discover a security vulnerability, please report it responsibly rather than opening a public issue. See SECURITY.md for details.

Contributing

Contributions are welcome. Please see CONTRIBUTING.md for details on submitting issues and pull requests.

License

Laravel AI Observability is open-sourced software licensed under the MIT license.


All versions of laravel-ai-observability with dependencies

PHP Build Version
Package Version
Requires php Version ^8.4
illuminate/contracts Version ^12.0|^13.0
illuminate/database Version ^12.0|^13.0
illuminate/http Version ^12.0|^13.0
illuminate/log Version ^12.0|^13.0
illuminate/support Version ^12.0|^13.0
laravel/ai Version ^0.7
spatie/laravel-package-tools Version ^1.16
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 tracefast/laravel-ai-observability contains the following files

Loading the files please wait ...