Guide to Route Requests to Agents
Routing requests to agents is a core function of the OpenSmartRoute platform. This guide explains how to route requests efficiently and accurately within your environment, using the platform's features.
Understanding Routing Requests
Routing requests involves directing user inputs or system prompts to the appropriate models, agents, skills, or tools based on predefined rules and signals. The platform's routing decision process considers various signals like complexity, domain, and reasoning need to determine the best target.
How the Routing Process Works
The routing process begins with a request, such as a user query, sent to the /api/v1/route endpoint. The platform evaluates the request against your configuration to select the most suitable target. The decision includes the target's identity, confidence level, and ranked alternatives.
Example of Routing a Request
curl -s "$OSR_URL/api/v1/route" \
-H "Authorization: Bearer $OSR_API_KEY" \
-H "Content-Type: application/json" \
-d '{"text": "Prove that sqrt(2) is irrational.", "top_k": 3}'
This command sends a mathematical query to the platform, which then routes it to the most appropriate model or agent based on the configuration.
Configuring Routing Targets
Routing targets include models, agents, skills, tools, and humans. They are configured in a YAML file that defines the rules and preferences for routing.
Sample YAML Configuration
targets:
- id: llm-frontier
kind: llm
name: Frontier model
provider: azure/gpt-4.1
model: openai/gpt-4.1
- id: agent-support
kind: agent
name: Support agent
endpoint: https://support-agent.example.com
This configuration specifies the possible targets for routing requests.
Running a Routing Scenario
To run a scenario, you prepare your request, configure your targets, and send the request to the /api/v1/route endpoint. The platform responds with a decision, including the chosen target and confidence.
