Get Requests Usage
Get aggregated request statistics for your project, showing API usage patterns over time.
Query Parameters
Page number for pagination (default: 1)
Start date for usage data (ISO 8601 format, e.g., “2024-01-01”)
End date for usage data (ISO 8601 format, e.g., “2024-01-31”)
Response
Array of daily request statisticsShow Request Statistics Object
Date in YYYY-MM-DD format
Total number of API requests for that date
curl --location --request GET 'https://api.plaisolutions.com/usage/requests?date_from=2024-01-01&date_to=2024-01-31' \
--header 'Authorization: Bearer YOUR_TOKEN'
Get Threads Usage
Get conversation thread statistics showing how users interact with your agents over time.
Query Parameters
Start date for usage data (ISO 8601 format)
End date for usage data (ISO 8601 format)
Response
Array of daily thread statisticsShow Thread Statistics Object
Date in YYYY-MM-DD format
Number of new conversation threads created on that date
curl --location --request GET 'https://api.plaisolutions.com/usage/threads?date_from=2024-01-01&date_to=2024-01-31' \
--header 'Authorization: Bearer YOUR_TOKEN'
Get LLM Usage
Get detailed statistics about language model usage including token consumption and costs.
Query Parameters
Start date for usage data (ISO 8601 format)
End date for usage data (ISO 8601 format)
Response
Array of LLM usage statistics
The specific language model used (e.g., “gpt-4”, “claude-3-sonnet”)
Type of operation (e.g., “completion”, “chat”)
Token consumption aggregation
Total input tokens consumed
Total output tokens generated
curl --location --request GET 'https://api.plaisolutions.com/usage/llm?date_from=2024-01-01&date_to=2024-01-31' \
--header 'Authorization: Bearer YOUR_TOKEN'
Get Rerank Usage
Get statistics about vector reranking operations used to improve search result quality.
Query Parameters
Start date for usage data (ISO 8601 format)
End date for usage data (ISO 8601 format)
Response
Array of reranking usage statistics
The service provider (e.g., “cohere”, “openai”)
Total search units consumed for reranking operations
curl --location --request GET 'https://api.plaisolutions.com/usage/rerank?date_from=2024-01-01&date_to=2024-01-31' \
--header 'Authorization: Bearer YOUR_TOKEN'
Get Embeddings Usage
Get statistics about embedding generation for vector search and semantic operations.
Query Parameters
Start date for usage data (ISO 8601 format)
End date for usage data (ISO 8601 format)
Response
Array of embedding usage statisticsShow Embeddings Usage Object
The embedding model used (e.g., “text-embedding-3-small”, “text-embedding-ada-002”)
Type of embedding operation
Total tokens processed for embedding generation
curl --location --request GET 'https://api.plaisolutions.com/usage/embeddings?date_from=2024-01-01&date_to=2024-01-31' \
--header 'Authorization: Bearer YOUR_TOKEN'
Get Scraping Usage
Get statistics about web scraping operations performed for content extraction.
Query Parameters
Start date for usage data (ISO 8601 format)
End date for usage data (ISO 8601 format)
Response
Array of scraping usage statisticsShow Scraping Usage Object
The scraping service provider used
Type of scraping operation performed
Total scraping credits consumed
curl --location --request GET 'https://api.plaisolutions.com/usage/scraping?date_from=2024-01-01&date_to=2024-01-31' \
--header 'Authorization: Bearer YOUR_TOKEN'
Get Web Search Usage
Get statistics about web search operations performed through integrated search tools.
Query Parameters
Start date for usage data (ISO 8601 format)
End date for usage data (ISO 8601 format)
Response
Array of web search usage statisticsShow Web Search Usage Object
The search service provider (e.g., “perplexity”, “google”)
The search model or service tier used
Input tokens used for search queries
Output tokens generated from search results
Total number of search queries performed
curl --location --request GET 'https://api.plaisolutions.com/usage/web-search?date_from=2024-01-01&date_to=2024-01-31' \
--header 'Authorization: Bearer YOUR_TOKEN'
Get Speech-to-Text Usage
Get statistics about audio transcription operations performed using speech-to-text services.
Query Parameters
Start date for usage data (ISO 8601 format)
End date for usage data (ISO 8601 format)
Response
Array of speech-to-text usage statisticsShow Speech-to-Text Usage Object
The service provider used for transcription
The transcription model used (e.g., “whisper-1”)
Total audio bytes processed for transcription
curl --location --request GET 'https://api.plaisolutions.com/usage/speech-to-text?date_from=2024-01-01&date_to=2024-01-31' \
--header 'Authorization: Bearer YOUR_TOKEN'
Register Speech-to-Text Usage
Register speech-to-text usage in the system. This endpoint is typically used by internal services to track transcription usage.
This endpoint requires API key authentication with Users-Management-Key header and is intended for administrative use.
Request Body
The transcription model used (e.g., “OPENAI_WHISPER”)
The service provider used for transcription
Number of audio bytes processed
ID of the project to attribute the usage to
Response
Returns a confirmation of usage registration.
curl --location --request POST 'https://api.plaisolutions.com/usage/whisper' \
--header 'Users-Management-Key: YOUR_MANAGEMENT_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"llm_model": "OPENAI_WHISPER",
"llm_provider": "OPENAI",
"bytes": 1048576,
"project_id": "project_123"
}'
Usage Analytics Best Practices
Monitor Regularly
Check usage statistics regularly to track consumption patterns and optimize costs
Set Alerts
Implement usage monitoring and alerts to prevent unexpected cost overruns
Analyze Trends
Use time-based filtering to identify usage trends and plan capacity accordingly
Optimize Performance
Use detailed usage data to identify inefficient operations and optimize them
Budget Planning
Leverage historical usage data for accurate budget forecasting and planning
Understanding Usage Metrics
Token Consumption
Monitor prompt and completion tokens to understand LLM costs and optimize prompt engineering
Request Patterns
Analyze request timing and frequency to identify peak usage periods and scale accordingly
Service Distribution
Track usage across different services to identify your primary cost drivers
Thread Activity
Monitor conversation patterns to understand user engagement and agent effectiveness
Cost Optimization Tips
Token Management:
- Use shorter prompts when possible to reduce input token costs
- Implement response length limits to control completion token usage
- Consider using smaller models for simple tasks
Batch Processing:
- Use batch APIs for non-real-time operations to reduce costs by up to 50%
- Aggregate similar requests to minimize API overhead
Caching Strategy:
- Implement response caching for frequently asked questions
- Use embeddings caching to avoid re-generating vectors for existing content
Usage Reporting Dashboard
Create comprehensive usage dashboards using the analytics data:
// Example: Building a usage dashboard
async function fetchAllUsageData(dateFrom, dateTo) {
const endpoints = [
'requests',
'threads',
'llm',
'embeddings',
'scraping',
'web-search',
'speech-to-text'
];
const usageData = {};
for (const endpoint of endpoints) {
const response = await fetch(`/usage/${endpoint}?date_from=${dateFrom}&date_to=${dateTo}`, {
headers: { 'Authorization': 'Bearer YOUR_TOKEN' }
});
usageData[endpoint] = await response.json();
}
return usageData;
}
Billing Integration
Usage statistics directly correlate with billing charges:
- LLM Usage: Charged per token (input + output)
- Embeddings: Charged per token processed
- Scraping: Charged per credit consumed
- Web Search: Charged per query + token usage
- Speech-to-Text: Charged per audio minute/byte
- Reranking: Charged per search unit
Rate Limiting Considerations:
- High usage may trigger rate limiting
- Monitor request patterns to stay within limits
- Implement exponential backoff for retry logic
- Consider upgrading to higher tier plans for increased limits