๐ Try the demo: https://github.com/LM-Kit/lm-kit-net-samples/tree/main/console_net/ai-agents/tools-and-function-calling/http_api_recipes
HTTP API Recipes for C# .NET Applications
๐ฏ Purpose of the Demo
HTTP API Recipes shows how an agent built with LM-Kit.NET works through your own REST APIs
without writing a tool class per endpoint. Each operation is a JSON definition
(HttpApiToolDefinition)
run by HttpApiTool,
and every call that writes waits for your approval.
The sample shows how to:
- Load tool definitions from JSON and fill in the API address and credential.
- Give them to an agent with a
ToolPermissionPolicy, so writes ask first. - Approve or decline each write from
AgentExecutor.ToolApprovalRequired.
๐ฅ Who Should Use This Demo
- Developers connecting an agent to a helpdesk, a CRM or any internal REST API.
- Teams that need a person to approve every change an agent makes in a business system.
- Anyone with an OpenAPI document:
OpenApiImporterturns it into the same definitions.
๐ What Problem It Solves
Hand-writing a tool class for every endpoint is slow and drifts from the API. Declaring operations as data keeps them reviewable, lets the same definitions run in the SDK and in LM-Kit One (which installs these very recipes from its admin panel), and puts writes behind an approval by default.
๐ป Demo Application Overview
| Recipe | Tools | Writes that ask first |
|---|---|---|
| Helpdesk | helpdesk_get_ticket, helpdesk_create_ticket, helpdesk_add_note, helpdesk_escalate_ticket |
Create, add a note, escalate |
| CRM | crm_find_customer, crm_log_activity |
Log an activity |
โจ Key Features
- No code per endpoint: URL
{placeholders}, query, header and JSON body arguments from the schema. - Approval by default: POST, PUT, PATCH and DELETE ask; GET runs.
- Response shaping:
response_pathkeeps only the part of the answer the model needs. - Egress control: an optional
WebEgressPolicylimits the addresses the tools may reach.
Example Output
You: The customer dana@example.com says the printer jams again after the repair. Open a ticket.
helpdesk_create_ticket wants to run with {"subject":"Printer jams again after repair","requester_email":"dana@example.com","priority":"high", ...}
Approve? (y/n) y
Agent: I opened ticket T-9001 for the repeated printer jam, at high priority.
๐๏ธ Architecture
recipes/helpdesk.json โโโบ HttpApiToolDefinition โโโบ HttpApiTool โโโบ Agent
โ {{base_url}}, {{authorization}} โ
โโโ filled from your input โโ GET โโโบ runs
โโ POST โโโบ ToolApprovalRequired โโโบ you
โ๏ธ Getting Started
Prerequisites
- .NET 8.0 or later.
- About 7 GB of VRAM for the recommended model (Qwen 3.5 9B).
- A helpdesk or CRM REST API, or a stub that answers the same paths.
Download
git clone https://github.com/LM-Kit/lm-kit-net-samples
cd lm-kit-net-samples/console_net/ai-agents/tools-and-function-calling/http_api_recipes
Run
dotnet run
๐ง Troubleshooting
- 401 or 403 answers: check the
Authorizationvalue, including its scheme (BearerorBasic). - 404 answers: your system uses other paths; edit the tool's
urlin the recipe file. - The model never calls a tool: make the tool's
descriptionsay when to use it.
๐ Extend the Demo
- Import a whole API with
OpenApiImporter.Import(document)and register the operations you choose. - Add a
WebEgressPolicyrestricted to your API's host. - Run the same recipes in LM-Kit One: Admin > Build > Custom tools > Integration recipes.
๐ Additional Resources
- Tool Calling Assistant: tools written as classes.
- LM-Kit.NET API reference: LMKit.Agents.Tools.Http