Skip to Content
JavaScriptCreate AgentsCreate OpenAI Agents

OpenAI Integration

Note: The llmConfig parameters correspond to the underlying LLM API you’re using. For detailed parameter information, check:

Important: Make sure to handle streaming responses appropriately when implementing tool usage.

import OpenAI from "openai"; import { OpenAIAdapter } from "@reacter/openapitools"; // Initialize the AI client const openai = new OpenAI({ apiKey: "your-openai-api-key", }); // Initialize the adapter const adapter = new OpenAIAdapter( "your OpenAPI Tools Apikey - https://openapitools.com/dashboard/settings", { verbose: true, } ); // Initialize the adapter first await adapter.initialize(); // Create a chatbot with tools const chatbot = await adapter.createOpenAIChatbot({ openaiClient: openai, llmConfig: { model: "gpt-4o", 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 help me check the weather?"); console.log(result.text);
Last updated on