AI examples

Complete, runnable AI examples - the need, the code, the configuration and the failure behavior.

Each example is a complete scenario - the need it answers, the code, the configuration, the expected output and the failure behavior. The code runs as pasted - the only placeholders are names and keys of your own.

NeedUsesExample
A chat that remembers each user separatelychat, chat_id, max_history_turns, chat_expiry, a skillChat with memory
One service against hosted, self-hosted and gateway-proxied modelsLLM connections, the model catalog, enmasseSelf-hosted models
Reliable JSON out of a modelA skill, parsing, validation, a retry pathStructured output
Knowing what each call costs, per callerThe usage dictionary of every responseToken usage
A service that survives its providerTimeouts, exceptions with the provider's reason, the audit logProvider failures
Agents calling OAuth-secured enterprise APIsAn MCP gateway, outgoing REST with Bearer tokensSecured APIs as tools
Agents picking the right tool and getting arguments rightDocstrings, declared I/O, argument validationTool selection
Following one agent request end to endThe CID across the audit log, server log and LLM callsTracing one call
Several agents that cannot see or affect each otherCredentials, sessions, rate limits, separate gatewaysMulti-agent isolation
The whole AI setup in version controlOne enmasse YAML for security, gateways, connectionsEverything as code
Testing a service that calls an LLMStructural assertions, replays, the audit logEvaluating AI flows