Generate Tools from Natural Language
You want an agent but you do not have an API spec or existing code. Describe what the tools should do in plain English, and Forge uses an LLM to propose a set of tools, lets you review them, then generates the Tool Spec and TypeScript capabilities. This walkthrough builds a Datadog monitoring agent from scratch.Prerequisites
- The Svantic CLI installed (
npm install -g @svantic/cli) - A Google Gemini API key (set
GOOGLE_API_KEYin your environment) — or a custom LLM provider
Step 1: Describe What You Want
Y to accept, n to cancel, or edit to modify the list interactively.
Step 2: Add Context with Documentation
Give the LLM reference documentation so it generates accurate parameter schemas and endpoint paths:--docs flag accepts URLs or local file paths. Forge fetches the content and includes it as context for the LLM. This dramatically improves the accuracy of generated parameter names, types, and API paths.
You can pass multiple --docs flags:
Step 3: The Propose, Review, Generate Flow
The generation process has three distinct phases:- Propose — The LLM reads your prompt (and optional docs) and proposes a list of tools with names, descriptions, and parameter outlines.
- Review — You review the proposed list. Edit tool names, remove tools you don’t need, or add missing ones.
- Generate — Forge takes the finalized list, generates the Tool Spec YAML, then materializes TypeScript capabilities.
| File | Contents |
|---|---|
datadog.tool-spec.yaml | The intermediate Tool Spec |
datadog.capabilities.ts | Runnable TypeScript tool implementations |
Step 4: Using Source Code as Context
If you have an existing service that interacts with the target API, point Forge at it for better results:--docs points to a local directory, Forge reads all .ts, .js, and .md files in it and includes them as LLM context. The LLM uses your existing code patterns, variable names, and error handling conventions to produce tools that match your codebase style.
Programmatic Usage
Propose then generate
One-shot generation (skip review)
Setting Up the LLM
Google Gemini (default)
Set theGOOGLE_API_KEY environment variable:
gemini-2.0-flash by default. Override the model with --model:
Custom LLM Providers
For providers other than Gemini, implement theLlmCallFn interface and pass it to the programmatic API:
LlmCallFn signature:
Tips for Better Results
- Be specific. “Create, read, update, and delete incidents in PagerDuty with severity and status fields” produces better tools than “PagerDuty stuff”.
- Provide docs. The
--docsflag is the single biggest lever for accuracy. Even a single API reference page helps. - Iterate. Use
editat the review step to rename tools, adjust descriptions, or add missing parameters before generation. - Combine with other paths. Generate a rough set from natural language, then refine by editing the Tool Spec YAML directly and regenerating with
svantic forge tool --spec.
