Routeway supports the OpenAI tool calling format. Any code that works with OpenAI function calling works with Routeway unchanged — just swap the
base_url.How It Works
- Define your tools in the request as JSON schemas.
- The model returns a
tool_callsarray when it wants to call a function. - Your app executes the function and sends back a
role: "tool"message. - The model generates its final answer using the result.
Basic Example
- Python
- Node.js
- cURL
Controlling Tool Use
Usetool_choice to control how the model selects tools.
Parallel Tool Calls
Models may request multiple tools simultaneously. Iterate overmessage.tool_calls, execute each in parallel, and send all results back before requesting the final answer.
Designing Good Tool Schemas
Use explicit, stable names
Use explicit, stable names
Tool names should clearly describe the action. The model uses the name and description to decide when to call the tool.
Write clear descriptions
Write clear descriptions
Descriptions directly influence the model’s decision to call a tool. Be specific about what the tool does and when to use it.
Keep schemas narrow
Keep schemas narrow
Avoid free-form string fields when enums or typed fields work. Tight schemas reduce parsing errors and improve reliability.
Return structured results
Return structured results
Return JSON objects from your functions instead of plain strings. The model can reason over structured data more reliably.
Common Mistakes
- Forgetting to replay the assistant message — the
messagesarray must include the assistant turn containingtool_callsbefore anyrole: "tool"messages. - Parsing arguments before the stream ends — when streaming, accumulate
delta.tool_callsfragments before callingJSON.parse. - Assuming a final text response always follows — on the first turn, the model may return only tool calls with no
content. Handle both cases.