Skip to main content
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 a ToolDefinition that tells the LLM what the tool does and what arguments it accepts.

Registering & Clearing Tools

Always call RunAnywhere.clearTools() before re-registering tools to avoid duplicates — for example, when your component remounts.

API Reference

RunAnywhere.registerTool()

Register a tool definition with its executor function.

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.

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.

Types

ToolDefinition

ToolParameter

ToolCallingOptions

ToolCallingResult

ParsedToolCall

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

Use parseToolCall() 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 when maxToolCalls > 1.

Error Handling

Tool executors should always return a result object — never throw. If a tool fails, return an object with an error field so the LLM can recover gracefully.

Common Error Scenarios

Platform Differences

The React Native SDK uses RunAnywhere directly for tool calling — there is no separate ToolCalling class like the Web SDK.

LLM Generation

Full text generation API

Streaming

Real-time token streaming

System Prompts

Control AI behavior

Error Handling

SDK error reference