# Create an upstream with weighted distribution
curl -X POST http://localhost:8080/api/v1/gateways/{gateway-id}/upstreams \
-H "Content-Type: application/json" \
-d '{
"name": "weighted-upstream",
"algorithm": "weighted-round-robin",
"targets": [
{
"host": "api.openai.com",
"port": 443,
"protocol": "https",
"weight": 60, # 60% of traffic
"priority": 1,
"default_model": "gpt-4o-mini",
"models": ["gpt-3.5-turbo", "gpt-4", "gpt-4o-mini"],
"credentials": {
"header_name": "Authorization",
"header_value": "Bearer your-openai-key"
}
},
{
"host": "api.anthropic.com",
"port": 443,
"protocol": "https",
"weight": 40, # 40% of traffic
"priority": 1,
"default_model": "claude-3-5-sonnet-20241022",
"models": ["claude-3-5-sonnet-20241022"],
"credentials": {
"header_name": "Authorization",
"header_value": "Bearer your-anthropic-key"
}
}
],
"health_checks": {
"passive": true,
"threshold": 3,
"interval": 60
}
}'