---
title: "onellm cookbook"
url: https://recursiveai.org/onellm/cookbook/
description: "Answers to common LLM tasks in C#: structured output, agents with tools, local models with Ollama, cost per call and tests without an API key. Each recipe…"
version: "1.0.0"
---

# onellm cookbook

Answers to common LLM tasks in C#: structured output, agents with tools, local models with Ollama, cost per call and tests without an API key. Each recipe is a complete program you can run without a key, with the output it really prints on OneLLM 1.0.0.

## Ask a model

- [Get LLM structured output into a C# record](https://recursiveai.org/onellm/cookbook/structured-output-to-a-csharp-record/index.md): LLM structured output in C#: OneLLM builds a JSON Schema from your record, sends it as native structured output and returns a typed value. Free, open source.
- [Call Ollama from C#](https://recursiveai.org/onellm/cookbook/call-ollama-from-csharp/index.md): Call Ollama from C#: OneLLM’s ollama preset talks to a local Ollama server with no key, streams, chats and reports usage at zero cost. Free, open source.

## Agents and tools

- [Build an AI agent with tool calling in C#](https://recursiveai.org/onellm/cookbook/ai-agent-with-tools-csharp/index.md): Build an AI agent with tool calling in C#: mark methods [Tool], list them in an agent file, and OneLLM runs the loop, with approvals and cost. Free, open source.

## Cost and testing

- [Track OpenAI API cost per call in C#](https://recursiveai.org/onellm/cookbook/track-llm-cost-per-call/index.md): Track OpenAI API cost per call in C#: OneLLM prices every call from its model catalog in decimal line items, with spend caps and JSONL logs. Free, open source.
- [Unit test LLM calls in C# without an API key](https://recursiveai.org/onellm/cookbook/test-llm-code-without-api-key/index.md): Unit test LLM calls in C# with no API key: OneLLM’s ScriptedProvider answers in place of OpenAI, records each request and prices it. Free, open source.
