# 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 usage 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. MetricAI meters the full stream including first-token latency. - [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, LangChain chat models, Tavily, 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. Call import metricai and metricai.init(...) before creating the OpenAI client. - [Anthropic](https://metricai.co.in/docs#anthropic): Claude Messages API with optional web search tools. Import metricai and init before Anthropic(). - [Gemini](https://metricai.co.in/docs#gemini): Native google.genai.Client - generateContent, Interactions API (text, streaming, multi-turn, tools). - [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) and the Search API. - [AWS Bedrock](https://metricai.co.in/docs#bedrock): Route Bedrock through MetricAI with the OpenAI SDK (chat.completions), native boto3 Converse APIs, or LangChain ChatBedrock / ChatBedrockConverse. Pass AWS credentials via llm_keys for BYOK. - [Mistral](https://metricai.co.in/docs#mistral): Use LangChain ChatMistralAI with metricai.init(auto_instrument=True). - [Vertex AI](https://metricai.co.in/docs#vertex): Vertex AI is separate from Gemini AI Studio. Pass service-account JSON plus GCP project and location via llm_keys, then use google.genai.Client. - [Azure Foundry](https://metricai.co.in/docs#azure): Pass Azure credentials in llm_keys, then use the OpenAI SDK as usual. - [Tavily](https://metricai.co.in/docs#tavily): Tavily is metered per call (tool provider, not tokens). Auto-wrapped when llm_keys includes tavily. Supports search, extract, crawl, map, qna_search, and research. - [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. For realtime agent sessions (e.g. LiveKit), attribute STT/LLM/TTS under one MetricAISession - see Sessions. - [LangChain & LangGraph](https://metricai.co.in/docs#langchain): Call import metricai and metricai.init(auto_instrument=True) first. Native LangChain chat models are instrumented automatically. MetricAI meters llm.stream(...) the same as invoke. - [CrewAI](https://metricai.co.in/docs#crewai): Install metricai[llamaindex]. Use alongside metricai.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 metricai.init(auto_instrument=True) so the underlying provider client routes through the proxy. - [Web middleware](https://metricai.co.in/docs#web-middleware): MetricAI meters the full stream including first-token latency and chunk count. Use stream=True or the provider's native stream helper. Each provider page leads with a streaming example. - [Streaming](https://metricai.co.in/docs#streaming): MetricAI meters the full stream including first-token latency and chunk count. Use stream=True or the provider's native stream helper. Each provider page leads with a streaming example. - [Sessions and telemetry](https://metricai.co.in/docs#sessions): Group multi-agent, multi-provider workflows under one session_id. Pass a distinct agent_id per sub-agent so the dashboard breaks down cost by agent. Pass user_id for the end-user (your app's customer) and optional user_info for display in Invoices and Sessions. - [Invoice payments — Route](https://metricai.co.in/docs#invoice-payments-route): Recommended default. MetricAI hosts checkout, splits each payment, and transfers your share to the bank you connected in the dashboard. You do not give MetricAI Razorpay API keys. - [Invoice payments — BYOR hosted](https://metricai.co.in/docs#invoice-payments-byor): You collect on your own Razorpay account. MetricAI still hosts pay.metricai.co.in and creates the Razorpay order with the keys you stored in the dashboard (encrypted at rest). After the customer pays, a platform fee accrues for you to settle. - [Invoice payments — BYOR self-collect](https://metricai.co.in/docs#invoice-payments-self-collect): You render the invoice and run Razorpay Checkout on your own site with keys in your .env. MetricAI never sees the customer's card. After a successful payment you report it so platform fees can accrue. - [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)