Drop-in tool definitions for OpenAI chat.completions, Assistants v2, and the Responses API. Returns native function objects with JSON Schema parameters.
npm install agent402-openai-tools
import { agent402Tools } from "agent402-openai-tools";
import OpenAI from "openai";
const openai = new OpenAI();
const { tools, execute } = await agent402Tools();
const res = await openai.chat.completions.create({
model: "gpt-4o",
messages: [{ role: "user", content: "Hash 'hello world' with SHA-256" }],
tools,
});
// When the model returns a tool_call, run it:
const call = res.choices[0].message.tool_calls[0];
const result = await execute(call.function.name, JSON.parse(call.function.arguments));
console.log(result);
| Option | Type | Description |
|---|---|---|
categories |
string[] |
Filter tools by category. |
slugs |
string[] |
Load only specific tools by slug. |
baseUrl |
string |
Point to a self-hosted Agent402 instance. |
agentKey |
string |
Private key for wallet-only (paid) tools. |
// Filter tools by category.
agent402Tools({ categories: ["search", "crypto"] })
// Load only specific tools by slug.
agent402Tools({ slugs: ["hash", "geocode"] })
// Point to a self-hosted Agent402 instance.
agent402Tools({ baseUrl: "https://my-agent402.example.com" })
// Private key for wallet-only (paid) tools.
agent402Tools({ agentKey: process.env.AGENT_KEY })