Anthropic Integration
Note: The
llmConfig
parameters correspond to the underlying LLM API you’re using. For detailed parameter information, check:
- Anthropic: Messages API Reference
Important: Make sure to handle streaming responses appropriately when implementing tool usage.
import Anthropic from "@anthropic-ai/sdk";
import { AnthropicAdapter } from "@reacter/openapitools";
// Initialize the AI client
const anthropic = new Anthropic({
apiKey: "your-anthropic-api-key",
});
// Initialize the adapter
const adapter = new AnthropicAdapter(
"your OpenAPI Tools Apikey - https://openapitools.com/dashboard/settings",
{
verbose: true,
}
);
// Create a chatbot with tools
const chatbot = await adapter.createAnthropicChatbot({
anthropicClient: anthropic,
llmConfig: {
model: "claude-3-7-sonnet-20250219",
temperature: 0.7,
max_tokens: 4096,
system: "You are a helpful assistant with access to tools.",
},
options: {
// Optional
toolNames: ["generate-otp", { name: "get-orders", version: "prod" }],
},
});
// Use the chatbot
const result = await chatbot.invoke("Can you generate an OTP for my number?");
console.log(result.text);
Last updated on