Using OpenAPI Tools in Local Mode
Local mode allows you to run your tools completely offline, without requiring an internet connection or API key. This offers enhanced privacy and control as all tools.
Prerequisites
- Python 3.8+ or Node.js 14+ installed on your machine
- Downloaded tools package from our platform
Downloading Your Tools
- Navigate to the Tools section in your dashboard - https://openapitools.com/dashboard/tools
- Click the “Download all tools” button
Setting Up Local Mode
Python Implementation
from reacter_openapitools import AnthropicAdapter
# Initialize the adapter in local mode by providing the folder path
adapter = AnthropicAdapter(
folder_path="./path/to/downloaded/openapitools",
verbose=True # Set to False in production
)
tools = adapter.get_anthropic_tools()
tool_handler = adapter.create_anthropic_tool_handler()
from anthropic import Anthropic
anthropic_client = Anthropic(api_key="your-anthropic-api-key")
chatbot = adapter.create_anthropic_chatbot(
anthropic_client=anthropic_client,
llm_config={
"model": "claude-3-7-sonnet-20250219",
"temperature": 0.7,
"max_tokens": 4096,
"system": "You are a helpful assistant with access to various tools."
}
)
response = chatbot["invoke"]("Can you generate an OTP for 123456789?")
print(response["text"])
JavaScript/TypeScript Implementation
import { AnthropicAdapter } from "@reacter/openapitools";
import Anthropic from "@anthropic-ai/sdk";
import path from "path";
import { fileURLToPath } from "url";
// Get the directory name of the current module
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
// Initialize the adapter in local mode
const adapter = new AnthropicAdapter({
folderPath: path.join(__dirname, "openapitools"), // Absolute path to the downloaded tools folder
verbose: true, // Set to false in production
});
const anthropic = new Anthropic({
apiKey: "your-anthropic-api-key",
});
const tools = await adapter.getAnthropicTools();
const toolHandler = adapter.createAnthropicToolHandler();
const chatbot = adapter.createAnthropicChatbot({
anthropicClient: anthropic,
llmConfig: {
model: "claude-3-7-sonnet-20250219",
temperature: 0.7,
maxTokens: 4096,
system: "You are a helpful assistant with access to various tools.",
},
});
const response = await chatbot.invoke("Can you generate an OTP for 123456789?");
console.log(response.text);
In js and ts, the folderPath
should be an absolute path to the downloaded tools folder. You can use path.join(__dirname, "openapitools")
to construct the absolute path.
Understanding the Local Mode Structure
When you download tools for local use, you’ll receive a ZIP file with the following structure:
openapitools/
├── tools.json # Tool definitions and metadata
├── ToolName-version.py # Python implementation of each tool
└── ToolName-version.sh # Bash implementation of each tool
The tools.json
file contains all the necessary information about your tools, including names, descriptions, input schemas, and which version is currently set as production.
Benefits of Local Mode
- Enhanced Privacy: Your data never leaves your environment
- Offline Access: No internet connection required for tool execution
- Complete Control: Full visibility into tool implementation
- No API Rate Limits: Execute tools as frequently as needed
- Lower Latency: Eliminates network overhead for tool execution
Local mode is particularly useful for scenarios involving sensitive data, offline deployments, or when you need guaranteed availability of your tools.
Troubleshooting
If you encounter issues with local mode:
- Ensure the folder path is correct and accessible
- Check that all required tool script files are present
- Verify you have the necessary permissions to execute the tool scripts
- Enable verbose mode (
verbose=True
) to see detailed logs - Inspect the console output for any error messages
For additional help, reach out to our support team at support@openapitools.com.