# MetricAI > Precision AI usage metering, LLM cost attribution, agent billing, budget enforcement, and BYOK AI gateway infrastructure. MetricAI sits in the request path between your application and AI providers. It meters usage in real time, attributes cost to customers and agents, enforces spend controls, and powers usage-based billing for AI SaaS - including OpenAI, Anthropic, Gemini, Deepgram, ElevenLabs, and LiveKit. ## Product pages - [Home - AI usage metering & billing](https://metricai.co.in/): Meter AI calls, attribute LLM cost, enforce budgets, bill customers - [Use cases](https://metricai.co.in/use-cases): AI SaaS billing, agent cost controls, voice AI billing, multi-provider attribution - [Integrations](https://metricai.co.in/integrations): OpenAI, Anthropic, Gemini, voice, and agent framework metering - [Compare](https://metricai.co.in/compare): MetricAI vs DIY metering, gateways, and observability tools - [Pricing](https://metricai.co.in/pricing): Usage-based pricing for AI infrastructure - [Security](https://metricai.co.in/security): BYOK key handling and data controls - [Documentation](https://metricai.co.in/docs): SDK install, providers, streaming, budgets, API reference - [Contact](https://metricai.co.in/contact): Talk to an AI billing architect ## Search intents we answer - AI usage metering - LLM cost attribution - AI agent billing - OpenAI / Anthropic / Gemini metering - Voice AI billing with Deepgram, ElevenLabs, LiveKit - BYOK AI gateway - AI spend controls and budget enforcement - Usage-based billing for AI SaaS ## Docs - [Overview](https://metricai.co.in/docs#intro): MetricAI is financial rails for your AI agents. Route your LLM, voice, and tool calls through the MetricAI proxy. Meter token, usage, and outcome cost in INR and emit telemetry - without changing your provider code. - [Quickstart](https://metricai.co.in/docs#quickstart): The fastest path - init(..., auto_instrument=True) monkey-patches official provider SDKs so your existing OpenAI(), Anthropic(), etc. calls route through MetricAI automatically. - [Installation](https://metricai.co.in/docs#install): Provider SDKs and framework adapters ship as extras. The base install already bundles common provider SDKs and framework integrations - for most setups pip install metricai is enough. - [Auto-instrument](https://metricai.co.in/docs#pattern-instrument): Auto-instrument patches constructors of openai.OpenAI, anthropic.Anthropic, google.genai.Client, groq.Groq, xai_sdk.Client, perplexity.Perplexity, and voice SDKs. Idempotent - patches each provider once. - [Client factory](https://metricai.co.in/docs#pattern-factory): Build a provider SDK client pointed at the proxy with attribution pre-set - no global patching. - [Configuration](https://metricai.co.in/docs#configuration): Call metricai.init(...) once at process startup. Retrieve the global client with metricai.get_metricai(). - [OpenAI](https://metricai.co.in/docs#openai): Supports Chat Completions, the Responses API, web search tools, and streaming. - [Anthropic](https://metricai.co.in/docs#anthropic): Native google.genai.Client - generateContent, streamGenerateContent, Interactions API (text, streaming, TTS). - [Gemini](https://metricai.co.in/docs#gemini): Native google.genai.Client - generateContent, streamGenerateContent, Interactions API (text, streaming, TTS). - [Grok](https://metricai.co.in/docs#grok): Grok uses xAI's gRPC SDK. By default routes through the MetricAI proxy. Set METRICAI_GROK_DIRECT=1 to call xAI gRPC directly. - [Groq](https://metricai.co.in/docs#groq): OpenAI-compatible chat completions (no native web search). - [Perplexity](https://metricai.co.in/docs#perplexity): Sonar chat (built-in web search), Search API, and Responses API. - [AWS Bedrock](https://metricai.co.in/docs#bedrock): Meters invoke_model, invoke_model_with_response_stream, converse, and converse_stream. - [Tavily](https://metricai.co.in/docs#tavily): Tavily is metered per call (tool provider, not tokens). Auto-wrapped when the tavily provider is active. - [Voice](https://metricai.co.in/docs#voice): Deepgram, ElevenLabs, and Sarvam voice SDKs via client factories. Also auto-instrumented when keys are in llm_keys. - [LangChain](https://metricai.co.in/docs#langchain): Install metricai[llamaindex]. Use alongside init(auto_instrument=True) so the underlying provider client routes through the proxy. - [CrewAI](https://metricai.co.in/docs#crewai): Install metricai[llamaindex]. Use alongside init(auto_instrument=True) so the underlying provider client routes through the proxy. - [LlamaIndex](https://metricai.co.in/docs#llamaindex): Install metricai[llamaindex]. Use alongside init(auto_instrument=True) so the underlying provider client routes through the proxy. - [Web middleware](https://metricai.co.in/docs#web-middleware): Set stream=True or use native streaming helpers. MetricAI meters the full stream including first-token latency and chunk count. - [Streaming](https://metricai.co.in/docs#streaming): Set stream=True or use native streaming helpers. MetricAI meters the full stream including first-token latency and chunk count. - [Sessions and telemetry](https://metricai.co.in/docs#sessions): Charge per successful business outcome. Simulate first, then bill live. - [Outcome billing](https://metricai.co.in/docs#billing): Charge per successful business outcome. Simulate first, then bill live. - [Local mode](https://metricai.co.in/docs#local): Run MetricAI entirely offline against a local SQLite ledger - perfect for development, evals, and air-gapped environments. - [Wallet and usage](https://metricai.co.in/docs#wallet): Default host: https://proxy.metricai.co.in. Override with METRICAI_PROXY_URL. - [Proxy reference](https://metricai.co.in/docs#proxy-reference): Default host: https://proxy.metricai.co.in. Override with METRICAI_PROXY_URL. - [Error handling](https://metricai.co.in/docs#errors) - [API cheat sheet](https://metricai.co.in/docs#api-reference) ## Full text - [llms-full.txt](https://metricai.co.in/llms-full.txt)