TrailAI Documentation

See, control, and trust your AI applications

TrailAI is a centralized AI gateway, observability, and guardrail platform. Instrument your app with one function call, then trace every LLM and agent call, track cost to the token, block unsafe input, and manage prompts, models, and secrets from one place.

Get started in 10 minutes Browse the dashboard guide SDK reference

Start where you are

I'm setting TrailAI up

Sign up, create a project, generate an API key, instrument your app, and see your first trace land in the dashboard.

Platform Quickstart

I'm reading the dashboard

Analytics, traces, agent runs, exceptions, prompts, guardrails, and settings — every page explained, with worked debugging examples.

Dashboard Guide

I'm writing code

trail.init(), auto-instrumentation for 40+ libraries, manual spans, guardrails, prompts, and vault.

SDK Guide

I'm administering it

Organizations, projects, members, roles, API keys, and the model registry.

Organizations & Members

Install in 30 seconds

Python

pip install trailai
import trail

trail.init(
    application_name="support-bot",
    environment="production",
    url="https://your-trail-host/api/sdk/v1",
    public_key="pk-trail-…",
    secrect_key="sk-trail-…",
)

Every supported LLM library in your environment is now traced. That's the whole integration.

Python Quickstart

TypeScript

npm install trailai
import Trail from 'trailai';

Trail.init({
  applicationName: 'support-bot',
  environment: 'production',
  otlpHeaders: {
    'X-Public-Key': process.env.TRAIL_PUBLIC_KEY!,
    'X-Secret-Key': process.env.TRAIL_SECRET_KEY!,
  },
});

Covers OpenAI, Anthropic, Cohere, and Ollama.

TypeScript SDK

Any language

TrailAI ingests standard OpenTelemetry OTLP. Point any OTel SDK at it:

OTEL_EXPORTER_OTLP_ENDPOINT="https://your-trail-host/api/sdk/"
OTEL_EXPORTER_OTLP_HEADERS="X-Public-Key=pk-trail-…,X-Secret-Key=sk-trail-…"

Guardrails, prompts, and vault are plain POST endpoints.

REST API Reference

What TrailAI does

LLM Observability

Span-level visibility into every model call — prompt, completion, tokens, latency, and computed cost.

LLM Analytics

Agent Analytics

Agent runs, steps, and tool calls aggregated from gen_ai.* spans. Find the weak agent and the slow tool.

Agent Analytics

Distributed Tracing

A virtualized span tree and waterfall for every request, down to the exact prompt that produced a bad answer.

Tracing

Guardrails

Block prompt injection, sensitive topics, and off-scope requests. LLM-based or regex, with tunable thresholds — and fail-closed by design.

Guardrails

Prompt Management

Version prompts, promote them with labels, and roll back in seconds — without a deploy.

Prompt Management

OpenGround

Send one prompt to eight providers side by side and compare quality, latency, and cost.

OpenGround

Secret Vault

Encrypted, project-scoped storage for provider keys — fetched into your process at runtime.

Vault

Popular pages

Debug a bad answer

Trace list → filters → span tree → the prompt the model actually received.

Tracing

Work out why the bill doubled

Stat card → dimension chart → token chart → the responsible requests.

LLM Analytics

Trace your own agents and tools

@trail.trace(role="agent") and what each role unlocks.

Manual Tracing

Nothing is showing up

The SDK never crashes your app — which makes silence the failure mode.

SDK Troubleshooting


About the screenshots in these docs

Every guide reserves labelled slots for screenshots and GIFs, each with a capture brief telling you what must be in frame. Until a real capture is dropped in, the slot renders as an empty panel — that's intentional, not a broken page.

Capture guide and asset inventory