Skip to Content

Interface OpenAITool

One tool as the OpenAI Chat Completions API takes it.

A definition only. Toolset.toOpenAI builds the array to pass as tools, and every tool_call that comes back goes to Toolset.call, whose text becomes the content of the { role: 'tool' } message you send in reply.

That API delivers tool_call.function.arguments as a JSON string rather than an object. Toolset.call takes it as it arrives — it parses a string and reports unparseable text the way it reports any other bad argument, so there is nothing to unwrap first.

const toolset = session.tools()
const tools: OpenAITool[] = toolset.toOpenAI()
// tools -> openai.chat.completions.create({ model, messages, tools })

// Each tool_call carries a name and its arguments as JSON text:
async function called(name: string, args: string) {
const text = await toolset.call(name, args)
// text -> the content of a { role: 'tool', tool_call_id } message
}
interface OpenAITool {
    type: "function";
    function: OpenAIFunction;
}
Index
type: "function"

Always function.

function: OpenAIFunction

The operation itself.