Skip to content

Examples

All examples are located in the /examples/ directory and can be run with:

Terminal window
npx tsx examples/01-basic-usage.ts
Example Description
01-basic-usage.ts Calculator gadget, three ways to run agents
02-custom-gadgets.ts Class-based vs functional gadgets, async, timeouts
03-hooks.ts Monitoring, custom observers, interceptors
04-human-in-loop.ts Interactive conversations with user input
05-streaming.ts Event handling, collecting results
Example Description
06-model-catalog.ts Model queries, cost estimation
07-logging.ts Verbose logging, debugging
08-hook-presets-advanced.ts Advanced preset patterns, cost tracking, analytics
09-filesystem-gadgets.ts Secure file system operations with path sandboxing
10-text-handling.ts Text response handling: textOnlyHandler, textWithGadgetsHandler
11-gadget-dependencies.ts Gadget dependencies (DAG execution)
12-error-handling.ts Error handling strategies and recovery patterns
Example Description
13-syntactic-sugar.ts Fluent API showcase
14-hints.ts LLM assistance hints (iteration progress, parallel gadgets)
15-trailing-messages.ts Ephemeral trailing messages injected per LLM request
Example Description
16-image-generation.ts Image generation with DALL-E and cost tracking
17-speech-generation.ts Text-to-speech generation with OpenAI TTS
18-multimodal-gadget.ts Gadgets returning media (images, audio) with cost reporting
19-multimodal-input.ts Vision and multimodal input support
Example Description
20-external-gadgets.ts External gadgets from npm packages and git URLs
21-browseweb-multi-call.ts Multi-step web browsing with external gadget
Example Description
22-format-timing.ts Response formatting and timing utilities
23-session-manager.ts Session management
24-huggingface-test.ts HuggingFace model testing with free open-source models
25-reasoning-models.ts Reasoning models with thinking/extended thinking
26-budget-limits.ts Budget and cost limiting configuration
27-skills.ts Agent Skills (SKILL.md) integration and usage
File Description
cli.example.toml CLI configuration file example

The /examples/gadgets/ directory contains production-ready gadgets you can use or learn from:

  • Calculator - Basic arithmetic operations
  • Strings - String manipulation utilities
  • Random - Random number and coin flip utilities
  • Filesystem - Secure file operations with sandboxing
  • Todo - Task planning system for agents
  • Web Search - Google search integration
const answer = await LLMist.createAgent()
.withModel('haiku')
.askAndCollect('Hello!');
const answer = await LLMist.createAgent()
.withModel('sonnet')
.withSystem('You are helpful')
.withGadgets(MyGadget)
.askAndCollect('Do something');
await LLMist.createAgent()
.withModel('flash')
.withGadgets(MyGadget)
.askWith('Do something', {
onText: (text) => console.log(text),
onGadgetResult: (r) => console.log(r.result),
});