Skip to main content

Creating Route

Creating Route

Routes in Javelin define how incoming requests are processed and which providers handle them. This guide shows you how to create and configure routes to control request routing, apply security policies, and manage fallback behaviors. You'll learn to set up routes with safety configurations, data loss prevention (DLP), content filtering, and other security settings.

curl -X POST \
-H "Content-Type: application/json" \
-H "x-javelin-apikey: $JAVELIN_API_KEY" \
-d '{
"name": "test_route_1",
"type": "chat",
"enabled": true,
"models": [
{
"name": "gpt-3.5-turbo",
"provider": "openai",
"suffix": "/chat/completions"
}
],
"config": {
"rate_limit": 3,
"retries": 3,
"archive": true,
"retention": 7,
"dlp": {
"enabled": false
}
}
}' \
"https://your-api-domain.com/v1/admin/routes/test_route_1"

Configuration Options

Basic Settings

{
"archive": true,
"retention": 7,
"rate_limit": 0,
"retries": 5
}

DLP (Data Loss Prevention)

Data Loss Prevention configuration helps protect sensitive information:

"dlp": {
"enabled": true,
"strategy": "promptfoo_dlp"
}

Content Filter (Trust & Safety)

Content filtering allows you to reject requests based on content types:

"content_filter": {
"enabled": true,
"error_code": 200,
"content_types": [
{
"operator": "greater_than",
"restriction": "sexual",
"probability_threshold": 0.25 // Threshold can be set to 0.25, 0.5, 0.75 or 1
}
],
"reject_prompt": "Unable to complete request, trust & safety violation detected"
}

Available content restrictions:

  • sexual
  • violence
  • hate_speech
  • profanity
  • crime

Prompt Safety

Prompt safety helps prevent prompt injection and jailbreak attempts:

"prompt_safety": {
"enabled": true,
"error_code": 200,
"content_types": [
{
"operator": "greater_than",
"restriction": "prompt_injection",
"probability_threshold": 0.25 // Threshold can be set to 0.25, 0.5, 0.75 or 1
},
{
"operator": "greater_than",
"restriction": "jailbreak",
"probability_threshold": 0.25 // Threshold can be set to 0.25, 0.5, 0.75 or 1
}
],
"reject_prompt": "Rejected from prompt safety policy."
}

Security Filters

Additional security filters can be enabled:

"security_filters": {
"enabled": true,
"content_types": []
}

All safety features support an inspect mode configuration that enables detection of various content types including language patterns, code/markdown syntax, and non-ASCII characters. The SecurityFilters Processor tracks and provides metrics for these security filter matches to help monitor and analyze potential security concerns.