Working with tools
Tools let your flows call APIs, run code, search the web, generate images, and connect to external services.
Tool types overview
Use the following tool types in a prompt step:
Add tools to a flow
Configure tools in the tools object of a prompt step. The following examples attach a saved tool to a prompt step.
Use the TypeScript SDK to attach a saved tool:
Use the Python SDK to attach the same saved tool:
Send the same flow definition with cURL:
Replace the placeholders in these examples with your values:
YOUR_TOOL_ID: The ID of the saved tool that you want to use.YOUR_API_KEY: Your Runtype API key.RUNTYPE_API_KEY: The environment variable that contains your Runtype API key.
Configure tool call strategy
Set toolCallStrategy to control how the model uses the available tools. The following table describes each strategy.
Use required only for one forced tool call, such as a structured-output or routing tool. Set maxToolCalls to 1 and omit an agent loop.
Don’t combine required with maxToolCalls greater than 1 or loopConfig.maxTurns greater than 1. The model is then forced to call a tool on each step and cannot finish with a text answer, so the output is empty.
For multi-step agents, set toolCallStrategy to auto.
Use external tools
External tools send HTTP requests to an API. Define the tool’s parameters with JSON Schema and configure the request:
Use {{city}} in the URL or headers to insert the matching tool-call parameter. Use {{secret:WEATHER_API_KEY}} to resolve the managed secret named WEATHER_API_KEY.
Create custom tools
Runtype runs custom tool code in a sandbox. The following tool calculates a discount and returns the original price, discounted price, and savings:
Use built-in tools
Built-in tools provide provider and platform capabilities. Use IDs that match the tool and the model in your prompt:
Use MCP server tools
Model Context Protocol (MCP) servers expose tools through a standard protocol. Configure an MCP server as a saved server or as a runtime server.
Use saved MCP servers
Save an MCP server in your account, then reference its tools by ID:
The tool ID format is mcp:SERVER_NAME:TOOL_NAME. Replace YOUR_SERVER_NAME with the saved server name and YOUR_TOOL_NAME with the MCP tool name.
Use runtime MCP servers
Pass an MCP server configuration inline when the server or its credentials vary by request:
Replace YOUR_MCP_SERVER_ID with the server ID for this request. Set MCP_TOKEN to the token that the MCP server accepts.
Use runtime tools
Define a tool inline without saving it to your account. The following example sends a request to an external API:
Runtime tools fit these use cases:
- Dynamic tool definitions.
- Testing a tool before saving it.
- User-provided tool configurations.
Combine tool types
Add saved tools, built-in tools, runtime tools, and runtime MCP servers to one prompt. The following example combines these tool sources:
Replace YOUR_TOOL_ID, YOUR_SERVER_NAME, YOUR_TOOL_NAME, and YOUR_MCP_SERVER_ID with your values. Set MCP_TOKEN to the runtime MCP server token.
Pass secrets
Keep API keys out of tool configuration. Store each credential on the Secrets page in Settings, then reference its managed name in the tool configuration:
Replace WEATHER_API_KEY with the name of the managed secret in your account. Hosted flow execution ignores the top-level secrets map. Use {{secret:NAME}}, where NAME is the managed secret name, for every flow credential. Managed secret values are encrypted at rest and are not logged or returned in responses.
Apply best practices
Use these practices when you configure tools:
Limit tool calls
Set maxToolCalls to limit tool-call rounds. Use a lower value for short tasks and a higher value for tasks that need more steps.
Write clear descriptions
Describe the tool’s inputs, outputs, and intended use. Clear descriptions provide the model with information for tool selection and calls.
Use the auto strategy
Set toolCallStrategy to auto for multi-step prompts and agents. The model chooses whether to
call a tool and returns text when it finishes. Use required only for one forced tool call with
maxToolCalls set to 1.
Handle errors
Plan for failed external API requests. Add flow logic that handles the response and continues or stops according to your use case.
Next steps
Use these guides to continue working with tools: