Documentation Index
Fetch the complete documentation index at: https://docs.runanywhere.ai/llms.txt
Use this file to discover all available pages before exploring further.
Tool calling lets the LLM decide when and how to invoke your functions, then incorporates
the results into its response — all running on-device for maximum privacy.
Basic Usage
Setup
Defining Tools
Each tool is described by aToolDefinition that tells the LLM what the tool does and what arguments it accepts.
Registering & Clearing Tools
API Reference
RunAnywhere.registerTool()
Register a tool definition with its executor function.
| Parameter | Type | Description |
|---|---|---|
definition | ToolDefinition | The tool’s name, description, and parameters |
executor | (args: Record<string, unknown>) => Promise<Record<string, unknown>> | Async function invoked when the LLM calls this tool |
RunAnywhere.clearTools()
Remove all registered tools.
RunAnywhere.generateWithTools()
Run a full tool-calling loop: generate → parse → execute → re-generate until the LLM produces a final text response or the call limit is reached.
| Parameter | Type | Description |
|---|---|---|
prompt | string | The user’s input prompt |
options | ToolCallingOptions? | Generation and tool options |
RunAnywhere.parseToolCall()
Manually parse raw LLM output to extract a tool call. Useful when you want full control over the tool-calling loop instead of using autoExecute.
| Parameter | Type | Description |
|---|---|---|
llmOutput | string | Raw text output from the LLM |
Types
ToolDefinition
ToolParameter
| Field | Type | Description |
|---|---|---|
name | string | Parameter name |
type | string | One of string, number, boolean, object, array |
description | string | Human-readable description for the LLM |
required | boolean? | Whether the parameter is required (default: false) |
defaultValue | string? | Default value when the parameter is omitted |
enum | string[]? | Allowed values — constrains the LLM’s choices |
ToolCallingOptions
| Field | Type | Default | Description |
|---|---|---|---|
tools | ToolDefinition[]? | — | Override registered tools for this call |
maxToolCalls | number? | 5 | Maximum tool invocations per generation |
autoExecute | boolean? | true | Automatically execute parsed tool calls |
temperature | number? | 0.7 | Sampling temperature (0.0–2.0) |
maxTokens | number? | 256 | Maximum tokens to generate |
ToolCallingResult
| Field | Type | Description |
|---|---|---|
text | string | Final text response from the LLM |
toolCalls | Array | All tool calls the LLM made during generation |
toolResults | Array | Execution results for each tool call |
ParsedToolCall
| Field | Type | Description |
|---|---|---|
toolCall | object? | Extracted tool call, if the LLM invoked one |
text | string | Remaining text after tool-call extraction |
Examples
Complete React Native Component
A full example with weather, calculator, and time tools wired into a chat-style UI.ToolCallingDemo.tsx
Manual Tool Call Parsing
UseparseToolCall() when you need to inspect or modify tool calls before execution.
Multi-Step Tool Chain
The LLM can chain multiple tool calls in a single generation whenmaxToolCalls > 1.
Error Handling
Common Error Scenarios
| Scenario | Cause | Resolution |
|---|---|---|
| Tool not found | Tool name in LLM output doesn’t match any registered tool | Verify ToolDefinition.name matches exactly |
| Argument type mismatch | LLM passes wrong type for a parameter | Cast defensively in the executor; provide clear description values |
| Max calls exceeded | LLM enters a tool-call loop | Lower maxToolCalls or refine tool descriptions |
| Executor timeout | External API call hangs | Add AbortController timeouts inside executors |
| No tool call parsed | Model doesn’t emit a tool-call token | Use a model that supports tool calling; check prompt clarity |
Platform Differences
The React Native SDK uses
RunAnywhere directly for tool calling — there is no separate
ToolCalling class like the Web SDK.| Feature | React Native (@runanywhere/core) | Web (@runanywhere/web) |
|---|---|---|
| Entry point | RunAnywhere.registerTool() | ToolCalling.registerTool() |
| Executor argument type | Record<string, unknown> | Record<string, ToolValue> |
| Manual parsing | RunAnywhere.parseToolCall() | Not available |
Parameter enum field | Supported | enumValues (different name) |
Parameter defaultValue | Supported | Not available |
Related
LLM Generation
Full text generation API
Streaming
Real-time token streaming
System Prompts
Control AI behavior
Error Handling
SDK error reference