v3.0.2-1783968837
Examples
Hello World
A basic function that introduces the library.
basics
basic
string
Write a Type-Safe LLM Function
One schema drives the prompt, the runtime validation, and the inferred TypeScript return type.
basics
basic
json
schema
Yes/No Decisions
Ask the LLM a question and get back a real boolean you can branch on — no string checking.
structured-output
basic
boolean
Extract Structured Data
Pull typed fields like cities and dates out of natural language, enforced by a JSON schema.
structured-output
basic
json
schema
Validate Statements
Check a list of statements against context and conversation, returning a typed verdict for each.
structured-output
basic
json
Working With JSON
Techniques for getting reliable, schema-valid JSON out of LLM responses.
structured-output
basic
json
schema
Intent Classification
Identify the intent of a user’s most recent message, restricted to categories you define.
classification
basic
json
Conditional Logic and Branching
Use LLM outputs to control branching and route to specialized executors based on intent.
classification
simple
Replicating Amazon Lex
Rebuild a Lex-style bot with intent detection and slot filling using composable executors.
classification
simple
json
Combine Two Executors
A single function that wraps 2 executor functions
chains
simple
parser
Story Writing with Sequential Composition
Takes an idea through outline to story using chained LLM calls.
chains
simple
Basic Self-Refinement Loop
An orchestration function that retries generating an answer until it includes a required word and is concise.
chains
simple
Write Code from Spec
A function that generates code from a specification.
code-generation
simple
markdownCodeBlock
Write Tests from Code
A function that generates Jest tests for the code you give it.
code-generation
simple
markdownCodeBlock
ReAct: Search + Calculator
An agent loop that reasons step by step and calls tools like search and a calculator until it reaches an answer.
agents
simple
tools
dialogue
Loading Prompts Remotely
Load prompt templates from a remote source at runtime, keeping prompt content out of your codebase.
prompts
simple
Separate Prompts from Business Logic
Keep prompt templates out of application code, with typed variables and prompts you can test without an API call.
prompts
basic
templates
Retries and Timeouts
Make LLM calls production-safe with per-call timeouts, automatic retries with backoff, and typed error handling.
production
simple
hooks
errors
LLM Calls in Lambda and Cron Jobs
Run typed LLM calls in AWS Lambda or scheduled jobs, with warm-start reuse and timeouts that respect the function limit.
production
simple
serverless
Prompt Injection Screening
A fail-closed guardrail: classify untrusted input before your real executor sees it, with an exact-match parser that blocks on anything unexpected.
production
simple
security
stringExtract
