Configure your CDN providers once through the API. V100 handles routing, failover, and cost optimization automatically. Query routing stats to monitor CDN utilization and cost.
// npm install v100-sdk
import { V100 } from 'v100-sdk';
const v100 = new V100('YOUR_API_KEY');
// Configure CDN providers
await v100.cdn.configure_cdns({
providers: [
{
name: 'cloudfront',
distribution_id: 'E1ABCDEF',
priority: 1,
regions: ['us', 'eu'], // Preferred for these regions
cost_per_gb: 0.085
},
{
name: 'cloudflare',
zone_id: 'abc123',
priority: 2,
regions: ['*'], // Fallback for all regions
cost_per_gb: 0.050
},
{
name: 'akamai',
cp_code: '123456',
priority: 1,
regions: ['ap', 'af'], // Best for APAC and Africa
cost_per_gb: 0.110
}
],
optimization: 'cost', // 'cost' | 'performance' | 'balanced'
quality_threshold: {
max_latency_ms: 50,
max_error_rate: 0.001
}
});
// Get routing statistics
const stats = await v100.cdn.get_routing_stats();
// { cloudfront: { traffic_pct: 45, avg_latency_ms: 22, cost: "$850" },
// cloudflare: { traffic_pct: 35, avg_latency_ms: 28, cost: "$420" },
// akamai: { traffic_pct: 20, avg_latency_ms: 31, cost: "$310" },
// total_savings_vs_single_cdn: "$580" }
curl -X POST https://api.v100.ai/v1/cdn/configure \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"providers": [
{ "name": "cloudfront", "distribution_id": "E1ABCDEF",
"priority": 1, "regions": ["us", "eu"] },
{ "name": "cloudflare", "zone_id": "abc123",
"priority": 2, "regions": ["*"] }
],
"optimization": "balanced"
}'