Tools

Self-contained function tools stored on a version — a name and a JSON Schema — and how compile hands them back for you to wire into your provider's tool-calling loop.

tools is an array of tool references a version carries. There are two kinds: function tools, which are self-contained and covered here, and mcp_tool references to connected MCP servers, covered on the MCP servers page. In the dashboard, tools are edited as raw JSON.

Function tools

A function tool is fully self-contained: a name and an input_schema that is a JSON Schema with type: "object". Nothing is resolved at run time — the whole definition lives on the version.

tools
[
  {
    "kind": "function",
    "name": "get_order_status",
    "input_schema": {
      "type": "object",
      "properties": {
        "order_id": { "type": "string", "description": "The order to look up" }
      },
      "required": ["order_id"]
    }
  }
]

What compile returns

compile() returns the tool references on the tools field — it doesn't execute anything. You take those references, register them with your provider's tool-calling API, and run the loop yourself.

const { messages, model, tools } = prompt.compile({ question: 'refund status?' });

// Map the function tools into your provider's tool format, then run the loop.
const openaiTools = tools
  .filter((t) => t.kind === 'function')
  .map((t) => ({ type: 'function', function: { name: t.name, parameters: t.input_schema } }));

const answer = await openai.chat.completions.create({
  model: model.model ?? 'gpt-4o',
  messages,
  tools: openaiTools,
});
compiled = prompt.compile(question="refund status?")

openai_tools = [
    {"type": "function", "function": {"name": t["name"], "parameters": t["input_schema"]}}
    for t in compiled.tools
    if t["kind"] == "function"
]

answer = openai.chat.completions.create(
    model=compiled.model.get("model", "gpt-4o"),
    messages=compiled.messages,
    tools=openai_tools,
)

compile() tells you which tools the prompt wants and leaves execution to you — you wire them into your provider and run the tool-calling loop. For server-backed tools whose schemas resolve live, see MCP servers.

On this page