Docs
Understanding Billing
Understanding Billing
ContentRetriever uses a transparent, pay-per-use billing model that ensures you only pay for the content you actually use in your applications.
Billing Basics
Cost Components
-
Query Costs
- Free source queries: $0.00
- Premium source queries: Varies by source
-
Document Access
- Free content: $0.00
- Copyrighted content: Price per document
-
API Usage
- Basic API calls: Included
- Advanced features: Optional add-ons
Cost Structure
Free Content
- Wikipedia
- Public domain documents
- Open access content
- Government documents
Cost: $0.00
Premium Content
Source Type | Cost per Document |
---|---|
Academic Papers | $0.10 |
News Articles | $0.05 |
Industry Reports | $0.25 |
Specialized Databases | Varies |
Usage Tracking
Monitoring Usage
from content_retriever import ContentRetriever
retriever = ContentRetriever(api_key="your-api-key")
# Get current usage
usage = retriever.get_usage_metrics()
print(usage)
{
"queries_count": 100,
"documents_retrieved": 450,
"cost_breakdown": {
"free_sources": 0.00,
"premium_sources": 12.50,
"total": 12.50
}
}
Cost Estimation
# Estimate cost before query
estimated_cost = retriever.estimate_cost(
"quantum computing advances",
max_results=5
)
print(f"Estimated cost: ${estimated_cost}")
Cost Control
Budget Limits
# Set maximum cost per query
retriever = ContentRetriever(
api_key="your-api-key",
budget_limit=5.0 # Maximum USD per query
)
# Set monthly budget
retriever.set_monthly_budget(1000.0)
Cost Optimization
# Prefer free content
retriever = ContentRetriever(
api_key="your-api-key",
prefer_free_content=True
)
# Set source weights for cost optimization
retriever.set_source_weights({
"wikipedia": 1.0, # Free
"academic_journals": 0.5 # Use less frequently
})
Billing Alerts
Setting Up Alerts
# Configure cost alerts
retriever.set_cost_alerts({
"warning_threshold": 800.0, # 80% of budget
"critical_threshold": 950.0 # 95% of budget
})
# Configure usage alerts
retriever.set_usage_alerts({
"queries_per_day": 1000,
"documents_per_day": 5000
})
Billing Reports
Generating Reports
# Get monthly report
report = retriever.get_billing_report(
timeframe="monthly",
include_breakdown=True
)
# Get detailed usage analytics
analytics = retriever.get_usage_analytics(
start_date="2024-01-01",
end_date="2024-01-31"
)
Cost Saving Strategies
-
Use Free Sources First
retriever.configure_source_priority( priority="cost", prefer_free=True )
-
Implement Caching
retriever.configure_cache( ttl=3600, # Cache for 1 hour max_size=1000 # Store up to 1000 results )
-
Optimize Query Patterns
# Batch queries for efficiency results = retriever.batch_retrieve( queries=["query1", "query2", "query3"], optimize_costs=True )
Billing FAQ
Common Questions
-
How often is billing calculated?
- Usage is calculated in real-time
- Bills are generated monthly
- Usage reports available anytime
-
What happens if I exceed my budget?
- Alerts are triggere