Examples
Long-Context Thread
Ensure all models in the fallback chain support long conversations:
curl -X POST https://api.travila.ai/api/v1/llm/gateway/create-thread \
-H "X-API-Key: $API_KEY" \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{
"title": "Long research thread",
"default_generation_config": {
"models": [
"google/gemini-3.6-flash:nitro",
"anthropic/claude-sonnet-4.6:nitro",
"anthropic/claude-sonnet-5"
],
"model_routing_filter": {
"min_context_length": 128000
}
}
}'
If any model in the models list has less than 128k context, it's silently removed. If all are removed, send-message returns an immediate error.
Cost-Capped Generation
Limit to cheap models for bulk/background tasks:
curl -X POST https://api.travila.ai/api/v1/llm/gateway/send-message \
-H "X-API-Key: $API_KEY" \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{
"conversation_key": "bulk-task-001",
"user_message": {
"role": "ROLE_USER",
"content": [{ "type": "CONTENT_PART_TYPE_TEXT", "content": "Summarize this" }]
},
"override_generation_config": {
"models": [
"google/gemini-3.6-flash:nitro",
"google/gemini-3.1-flash-lite",
"google/gemini-3-flash-preview"
],
"model_routing_filter": {
"max_prompt_cost": 0.000005,
"max_completion_cost": 0.00002
}
}
}'
Structured Output with Tool Support
Ensure the model supports both tools and response_format parameters:
curl -X POST https://api.travila.ai/api/v1/llm/gateway/send-message \
-H "X-API-Key: $API_KEY" \
-H "Authorization: Bearer $JWT" \
-H "Content-Type: application/json" \
-d '{
"conversation_key": "health-plan-001",
"user_message": {
"role": "ROLE_USER",
"content": [{ "type": "CONTENT_PART_TYPE_TEXT", "content": "Generate my health plan" }]
},
"override_generation_config": {
"models": [
"google/gemini-3.6-flash:nitro",
"anthropic/claude-sonnet-4.6:nitro"
],
"response_format": {
"json_schema": { "..." : "schema" },
"schema_name": "health_plan"
},
"model_routing_filter": {
"required_parameters": ["tools", "response_format"]
}
}
}'