Quick Start
automatic token tracking के साथ 2 मिनट में शुरुआत करें।
API Reference - Events Ingestion
usage events ingest करने के लिए पूरा API documentation।
API Reference - Meters
billing के लिए meters बनाने और configure करने का तरीका जानें।
Usage-Based Billing Guide
meters के साथ usage-based billing की व्यापक guide।
SaaS apps, AI chatbots, content generation tools और किसी भी ऐसे LLM-powered application के लिए उपयुक्त, जिसे usage-based billing की आवश्यकता हो।
त्वरित शुरुआत
सिर्फ 2 मिनट में automatic LLM token tracking शुरू करें:1
Install the SDK
Dodo Payments Ingestion Blueprints install करें:
2
Get Your API Keys
आपको दो API keys की आवश्यकता होगी:
- Dodo Payments API Key: इसे Dodo Payments Dashboard से प्राप्त करें
- LLM Provider API Key: AI SDK, OpenAI, Anthropic, Groq आदि से।
3
Create a Meter in Dodo Payments
Usage track करने से पहले, अपने Dodo Payments dashboard में एक meter बनाएँ:विस्तृत instructions के लिए Usage-Based Billing Guide देखें।
- Login करें Dodo Payments Dashboard में
- Products → Meters पर जाएँ
- “Create Meter” पर click करें
- अपने meter को configure करें:
- Meter Name: एक वर्णनात्मक नाम चुनें (जैसे, “LLM Token Usage”)
- Event Name: एक unique event identifier सेट करें (जैसे,
llm.chat_completion) - Aggregation Type: token counts को जोड़ने के लिए
sumचुनें - Over Property: track करने के लिए property चुनें:
inputTokens- input/prompt tokens track करेंoutputTokens- output/completion tokens track करें (जहाँ लागू हो, reasoning tokens भी शामिल हैं)totalTokens- संयुक्त input + output tokens track करें
यहाँ सेट किया गया Event Name, SDK में भेजे गए नाम से बिल्कुल match होना चाहिए (case-sensitive)।
4
Track Token Usage
अपने LLM client को wrap करें और automatic tracking शुरू करें:
बस इतना ही! अब हर API call automatically token usage track करती है और billing के लिए events को Dodo Payments पर भेजती है।
Configuration
Tracker Configuration
Application startup पर इन आवश्यक parameters के साथ एक tracker बनाएँ:string
आवश्यक
आपकी Dodo Payments API key। इसे API Keys page से प्राप्त करें।
string
आवश्यक
Tracker के लिए environment mode।
test_mode- development और testing के लिए उपयोग करेंlive_mode- production के लिए उपयोग करें
string
आवश्यक
वह event name जो आपके meter को trigger करता है। यह आपके Dodo Payments meter में configure किए गए नाम से बिल्कुल match होना चाहिए (case-sensitive)।
यह event name आपके tracked usage को billing calculations के लिए सही meter से link करता है।
Wrapper Configuration
अपने LLM client को wrap करते समय ये parameters दें:object
आवश्यक
आपका LLM client instance (OpenAI, Anthropic, Groq आदि)।
string
आवश्यक
Billing के लिए unique customer identifier। यह Dodo Payments में मौजूद आपके customer ID से match होना चाहिए।
object
Tracking event से attach करने के लिए optional additional data। Filtering और analysis के लिए उपयोगी।
Complete Configuration Example
Automatic Tracking: SDK response में बदलाव किए बिना background में token usage को automatically track करता है। आपका code साफ़ और original provider SDKs के उपयोग जैसा ही रहता है।
Supported Providers
LLM Blueprint सभी प्रमुख LLM providers और aggregators के साथ सहज रूप से काम करता है:AI SDK (Vercel)
AI SDK (Vercel)
Universal LLM support के लिए Vercel AI SDK के साथ usage track करें।Tracked Metrics:
inputTokens→inputTokensoutputTokens+reasoningTokens→outputTokenstotalTokens→totalTokens- Model name
AI SDK के माध्यम से reasoning-capable models का उपयोग करते समय (जैसे thinking mode वाला Google Gemini 2.5 Flash), accurate billing के लिए reasoning tokens automatically
outputTokens count में शामिल हो जाते हैं।OpenRouter
OpenRouter
OpenRouter की unified API के माध्यम से 200+ models में token usage track करें।Tracked Metrics:
prompt_tokens→inputTokenscompletion_tokens→outputTokenstotal_tokens→totalTokens- Model name
OpenAI
OpenAI
OpenAI के GPT models से token usage automatically track करें।Tracked Metrics:
prompt_tokens→inputTokenscompletion_tokens→outputTokenstotal_tokens→totalTokens- Model name
Anthropic Claude
Anthropic Claude
Anthropic के Claude models से token usage track करें।Tracked Metrics:
input_tokens→inputTokensoutput_tokens→outputTokens- Calculated
totalTokens - Model name
Groq
Groq
Groq के साथ ultra-fast LLM inference track करें।Tracked Metrics:
prompt_tokens→inputTokenscompletion_tokens→outputTokenstotal_tokens→totalTokens- Model name
Google Gemini
Google Gemini
Google GenAI SDK के माध्यम से Google के Gemini models से token usage track करें।Tracked Metrics:
promptTokenCount→inputTokenscandidatesTokenCount+thoughtsTokenCount→outputTokenstotalTokenCount→totalTokens- Model version
Gemini Thinking Mode: Thinking/reasoning capabilities वाले Gemini models (जैसे Gemini 2.5 Pro) का उपयोग करते समय, SDK accurate full computational cost दर्शाने के लिए
thoughtsTokenCount (reasoning tokens) को outputTokens में automatically शामिल करता है।Advanced Usage
Multiple Providers
अलग-अलग trackers के साथ विभिन्न LLM providers में usage track करें:Express.js API Integration
Express.js API में LLM tracking integrate करने का पूरा example:क्या Track होता है
हर LLM API call निम्न structure के साथ Dodo Payments को automatically एक usage event भेजती है:Event Fields
string
इस specific event के लिए unique identifier। SDK द्वारा automatically generate किया जाता है।Format:
llm_[timestamp]_[random]string
Client को wrap करते समय आपके द्वारा दिया गया customer ID। Billing के लिए उपयोग किया जाता है।
string
वह event name जो आपके meter को trigger करता है। आपकी tracker configuration से match करता है।
string
Event होने का ISO 8601 timestamp।
object
Token usage और additional tracking data:
inputTokens- उपयोग किए गए input/prompt tokens की संख्याoutputTokens- उपयोग किए गए output/completion tokens की संख्या (जहाँ लागू हो, reasoning tokens भी शामिल हैं)totalTokens- कुल tokens (input + output)model- उपयोग किया गया LLM model (जैसे, “gpt-4”)provider- LLM provider (यदि wrapper metadata में शामिल हो)- Client को wrap करते समय आपके द्वारा दिया गया कोई भी custom metadata
Reasoning Tokens: Reasoning capabilities वाले models के लिए,
outputTokens में completion tokens और reasoning tokens दोनों automatically शामिल होते हैं।आपका Dodo Payments meter usage और billing calculate करने के लिए
metadata fields (विशेष रूप से inputTokens, outputTokens या totalTokens) का उपयोग करता है।