Monitoring complements tracing by providing aggregate insights into the usage of LLM workflows.
Limits
LangDB enforces limits to ensure fair usage and cost management while allowing users to configure these limits as needed. Limits are categorized into:
Daily Limits: Maximum usage per day, e.g., $10 in the Starter Tier.
Monthly Limits: Total usage allowed in a month, e.g., $100.
Total Limits: Cumulative limit over the project’s duration, e.g., $500.
Best Practices
Monitor usage regularly to avoid overages.
Plan limits based on project needs and anticipated workloads.
Upgrade tiers if usage consistently approaches limits.
Setting limits not only helps you stay within budget but also provides the flexibility to scale your usage as needed, ensuring your projects run smoothly and efficiently.
Usage APIs
Retrieves the total usage statistics for your project for a timeframe.
Copy curl --location 'https://api.us-east-1.langdb.ai/usage/total' \
--header 'x-project-id: langdbProjectID' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer langDBAPIKey' \
--data '{"start_time_us": 1693062345678,
"end_time_us": 1695092345678}'
Example Response:
Copy {
"total": {
"total_input_tokens": 4181386,
"total_output_tokens": 206547,
"total_cost": 11.890438685999994
},
"period_start": 1737504000000000,
"period_end": 1740131013885000
}
Fetches timeseries usage statistics per model, allowing users to analyze the distribution of LLM usage.
Copy curl --location 'https://api.us-east-1.langdb.ai/usage/models' \
--header 'x-project-id: langdbProjectID' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer langDBAPIKey' \
--data '{"start_time_us": 1693062345678, "end_time_us": 1695092345678,
"min_unit": "hour"} '
Example Response:
Copy {
"models": [
{
"hour": "2025-02-14 08:00:00",
"provider": "openai",
"model_name": "gpt-4o-mini",
"total_input_tokens": 13408,
"total_output_tokens": 2169,
"total_cost": 0.0039751199999999995
},
{
"hour": "2025-02-13 08:00:00",
"provider": "openai",
"model_name": "gpt-4o-mini",
"total_input_tokens": 55612,
"total_output_tokens": 786,
"total_cost": 0.01057608
}
],
"period_start": 1737504000000000,
"period_end": 1740130915098000
}
Filtering By Users
As discussed in User Tracking, we can use filters to retrieve insights based on id
, name
, or tags
.
Available Filters:
user_id
: Filter data for a specific user by their unique ID.
user_name
: Retrieve usage based on the user’s name.
user_tags
: Filter by tags associated with a user (e.g., "websearch", "support").
Copy curl -L \
--request POST \
--url 'https://api.us-east-1.langdb.ai/usage/models' \
--header 'Authorization: Bearer langDBAPIKey' \
--header 'X-Project-Id: langDBProjectID' \
--header 'Content-Type: application/json' \
--data '{
"user_id": "123",
"user_name": "mrunmay",
"user_tags": ["websearch", "testings"]
}'
Example response:
Copy {
"models": [
{
"day": "2025-02-21 10:00:00",
"provider": "openai",
"model_name": "gpt-4o-mini",
"total_input_tokens": 1112,
"total_output_tokens": 130,
"total_cost": 0.00029376
},
{
"day": "2025-02-21 14:00:00",
"provider": "openai",
"model_name": "gpt-4o-mini",
"total_input_tokens": 3317,
"total_output_tokens": 328,
"total_cost": 0.00083322
}
],
"period_start": 1737556513673410,
"period_end": 1740148513673410
}