⚡ Zero-Proxy AI Observability · OpenAI · Anthropic · Workers AI · 80+ Models Priced ⚡
One npm install. Auto-captures every AI call — tokens, cost, latency, errors. No proxy, no wrapper per request, <1ms overhead. See it all right next to your application logs.
Total Cost
$11.67
Calls
847
Avg Latency
3.4s
<1ms
overhead per call
80+
models priced locally
0
proxy hops required
1 line
to instrument everything
Initialize the logger + enable AI instrumentation
The flarelogAI() call patches global fetch(). From this point, every request to an AI provider is intercepted.
import { flarelog } from "@flarelog/sdk";
import { flarelogAI } from "@flarelog/sdk/ai";
const logger = flarelog({
apiKey: process.env.FLARELOG_API_KEY!,
});
// One call. Every fetch() to OpenAI, Anthropic,
// Workers AI, and any OpenAI-compatible gateway
// is now captured — tokens, cost, latency, errors.
const ai = flarelogAI(logger);Use your AI SDK as usual
Nothing changes in your application code. OpenAI, Anthropic, Workers AI, Vercel AI SDK — all captured automatically. No base URL changes, no per-call wrappers.
// Just call your AI provider as usual.
// FlareLog captures it automatically.
// OpenAI
await fetch("https://api.openai.com/v1/chat/completions", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.OPENAI_API_KEY}` },
body: JSON.stringify({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello" }],
}),
});
// Anthropic
await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"x-api-key": process.env.ANTHROPIC_API_KEY!,
"anthropic-version": "2023-06-01",
},
body: JSON.stringify({
model: "claude-3-5-sonnet-20241022",
max_tokens: 1024,
messages: [{ role: "user", content: "Hello" }],
}),
});Auto-detects OpenAI, Anthropic, Google Gemini, Mistral, Cohere, DeepSeek, Together, and Groq. Add custom gateways with one config line.
import { wrapWorkersAI } from "@flarelog/sdk/ai";
export default {
async fetch(req, env, ctx) {
const ai = wrapWorkersAI(env.AI, logger);
const result = await ai.run("@cf/meta/llama-3.3-70b-instruct-fp8-fast", {
messages: [{ role: "user", content: "Hello" }],
});
return Response.json(result);
},
};Wraps env.AI.run() — the only library that instruments Cloudflare Workers AI natively.
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";
import { withFlarelog } from "@flarelog/sdk/ai";
const result = await withFlarelog(
generateText({
model: openai("gpt-4o"),
messages: [{ role: "user", content: "Hello" }],
}),
{ logger, tags: { route: "/chat" } }
);Works with generateText, streamText, and generateObject.
One function call intercepts every outbound AI request. No base URL changes, no per-call wrapping, no proxy server. Just add the SDK and your existing code is instrumented.
Local price table covering 80+ models across OpenAI, Anthropic, Gemini, Mistral, Cohere, DeepSeek, and more. Cost computed in-process — no server roundtrip. Override prices for negotiated rates.
See time-to-first-byte separately from total duration. Track tokens-per-second across streaming responses. Know if a slow call is cold start, network, or model throughput.
The AI call that cost $0.50 sits right next to the application error that triggered the retry storm. No separate dashboard, no context switching, no correlation by trace ID.
Workers AI uses a binding, not fetch. FlareLog wraps env.AI.run() directly — the only observability tool that instruments it natively.
Trace context injected on outbound AI calls. All span attributes follow OpenTelemetry GenAI semantic conventions. Compatible with Grafana, Honeycomb, Datadog, and Tempo.
Captures tokens, cost, latency, status, and model — never prompt or completion content. Enable captureSamples for truncated prompt previews when debugging.
Streaming responses are tee()'d once (zero-copy). SSE parsing runs in a background promise that never blocks the consumer.
shouldInstrument to filter URLs. sampleRate independent of logger. costMultiplier for internal billing. extraProviderHosts for custom gateways.
flarelogAI() patches the global fetch() function. When an outgoing request matches a known AI provider hostname (api.openai.com, api.anthropic.com, etc.), FlareLog clones the request body, creates an OTel span, and parses the response — all without modifying your original request or adding latency.
No. The interceptor adds <1ms per AI call. The hot path is: URL parse (~0.05ms), body peek (~0.3ms), span creation (~0.1ms), response parsing (~0.2ms). For streaming responses, the body is tee()'d once and SSE parsing runs in a background promise.
No. FlareLog intercepts fetch() locally in your runtime. Your AI requests go directly to the provider. This eliminates a network hop, reduces latency, and removes a single point of failure.
Add it as an OpenAI-compatible host: flarelogAI(logger, { extraProviderHosts: [{ pattern: "api.your-gateway.com", provider: "openai" }] }). Or build a custom ProviderMatcher for non-standard APIs.
No, by default. Only metadata is captured: token counts, cost, latency, model name, status code. You can opt in to truncated prompt/completion samples (first 500 chars) with captureSamples: true for debugging.
The bundled price table covers 80+ models from public pricing pages. Prices drift — always use priceOverrides for billing-grade accuracy. You can also apply a costMultiplier for internal cost allocation.
Yes. That's the core differentiator. Every AI call is emitted as a structured log entry with flarelog.kind: "ai_call". It appears in the same dashboard, same search, same retention as your application logs. The retry loop that spiked costs sits right next to the error that caused it.
Workers AI uses a binding (env.AI.run()), so fetch interception doesn't apply. Use wrapWorkersAI(env.AI, logger) — it wraps the binding directly and captures the same metrics.
One npm install. One function call. Full visibility into every AI call — costs, tokens, latency, errors. No proxy, no credit card, no changes to your application code.