Working with Tools
Tools extend AI capabilities beyond text generation, allowing your flows to call APIs, execute code, search the web, generate images, and integrate with external services.
Tool Types Overview
Runtype supports several types of tools:
Adding Tools to a Flow
Tools are configured in the tools object of a prompt step:
Tool Call Strategy
The toolCallStrategy controls how the model uses tools:
Use required only for a single forced tool call (maxToolCalls: 1, no agent loop) — for
example, forcing a structured-output or routing tool. Do not combine required with a
multi-step loop (maxToolCalls greater than 1, or an agent with loopConfig.maxTurns greater
than 1): the model is then forced to call a tool on every step and can never finish with a text
answer, so the response comes back empty. For multi-step agents, keep toolCallStrategy: "auto".
External Tools
External tools make HTTP requests to any API:
Variable substitution: Use {{paramName}} in URLs and headers. Access secrets via {{secrets.keyName}}.
Custom Tools (Code Execution)
Execute JavaScript in a secure sandbox:
Built-in Tools
Provider-specific tools that work with compatible models:
MCP Server Tools
MCP (Model Context Protocol) servers provide rich integrations. There are two ways to use them:
Saved MCP Servers
Configure once in your account, use anywhere by tool ID:
Tool ID format: mcp:<serverName>:<toolName>
Runtime MCP Servers
Pass server config inline for dynamic credentials:
See MCP Servers Guide for detailed MCP documentation.
Runtime Tools
Define tools inline without saving them:
Runtime tools are ideal for:
- Dynamic tool definitions
- Testing before saving
- User-provided tool configurations
See Runtime Tools Guide for more details.
Combining Tool Types
Mix different tool types in one prompt:
Passing Secrets
Never hardcode API keys. Use the secrets field:
Access in tool configs: {{secrets.weather_api_key}}
Security: Secrets are never logged, stored, or returned in responses.
Best Practices
Limit tool calls
Set maxToolCalls to prevent infinite loops. Start with 5-10 for simple tasks, increase for complex agents.
Write clear descriptions
Tool descriptions help the model understand when to use each tool. Be specific about inputs and outputs.
Default to the auto strategy
Keep toolCallStrategy: "auto" for almost every prompt and agent — the model calls tools when it
needs them (including to fetch external data) and answers with text when it’s done. Use required
only to force a single tool call (maxToolCalls: 1, no agent loop), such as a structured-output
or routing tool. Never pair required with a multi-step loop: the model is forced to call a tool
on every step and can never return a final answer, so the output comes back empty.
Handle errors gracefully
External APIs can fail. Consider error handling in your flow design or use the errorHandling config option.