API Reference
toToolSpec
function toToolSpec(tool): ToolSpec;Defined in: tools/tools.ts:71
Convert a tool to the spec shape the model client advertises.
Parameters
| Parameter | Type | Description |
|---|---|---|
tool | Tool | The tool to advertise to the model. |
Returns
A ToolSpec carrying the tool's name, description, and JSON Schema parameters.
Remarks
The tool's Zod schema is converted to JSON Schema (via z.toJSONSchema),
which is the form function-calling models expect on the wire.
See
Example
import { toToolSpec } from "@open-agent-loops/core/tools/tools";
const spec = toToolSpec(addTool);
// spec.parameters is a JSON Schema object describing { a, b }
await modelClient.complete({ messages, tools: [spec] });