llmmeter-fetch
v0.1.1
Published
Catch-all fetch() wrapper for llmmeter. Auto-detects OpenAI, Anthropic, Google, Mistral, Groq, OpenRouter, DeepSeek, xAI, Ollama URLs and records calls.
Downloads
31
Readme
llmmeter-fetch
Catch-all fetch() wrapper for llmmeter. Auto-detects requests to OpenAI, Anthropic, Google, Mistral, Groq, OpenRouter, DeepSeek, xAI, and Ollama URLs and records them. Calls to anything else pass through untouched.
import { meterFetch } from "llmmeter-fetch";
// Globally:
globalThis.fetch = meterFetch(globalThis.fetch);
// Or scoped:
const fetch = meterFetch(globalThis.fetch, { feature: "rag" });
await fetch("https://api.openai.com/v1/chat/completions", { ... });Supports both JSON responses and text/event-stream (SSE) streaming. The wrapper passes the original response through unchanged — your downstream code keeps streaming as normal while llmmeter records token counts and timing in the background.
For custom endpoints, pass a parsers: [...] array; see FetchParser in the source.
