Table of Contents

๐Ÿ‘‰ 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: OpenApiImporter turns 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_path keeps only the part of the answer the model needs.
  • Egress control: an optional WebEgressPolicy limits 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 Authorization value, including its scheme (Bearer or Basic ).
  • 404 answers: your system uses other paths; edit the tool's url in the recipe file.
  • The model never calls a tool: make the tool's description say when to use it.

๐Ÿš€ Extend the Demo

  • Import a whole API with OpenApiImporter.Import(document) and register the operations you choose.
  • Add a WebEgressPolicy restricted to your API's host.
  • Run the same recipes in LM-Kit One: Admin > Build > Custom tools > Integration recipes.

๐Ÿ“š Additional Resources

Share