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.
| Need | Uses | Example |
|---|---|---|
| A chat that remembers each user separately | chat, chat_id, max_history_turns, chat_expiry, a skill | Chat with memory |
| One service against hosted, self-hosted and gateway-proxied models | LLM connections, the model catalog, enmasse | Self-hosted models |
| Reliable JSON out of a model | A skill, parsing, validation, a retry path | Structured output |
| Knowing what each call costs, per caller | The usage dictionary of every response | Token usage |
| A service that survives its provider | Timeouts, exceptions with the provider's reason, the audit log | Provider failures |
| Agents calling OAuth-secured enterprise APIs | An MCP gateway, outgoing REST with Bearer tokens | Secured APIs as tools |
| Agents picking the right tool and getting arguments right | Docstrings, declared I/O, argument validation | Tool selection |
| Following one agent request end to end | The CID across the audit log, server log and LLM calls | Tracing one call |
| Several agents that cannot see or affect each other | Credentials, sessions, rate limits, separate gateways | Multi-agent isolation |
| The whole AI setup in version control | One enmasse YAML for security, gateways, connections | Everything as code |
| Testing a service that calls an LLM | Structural assertions, replays, the audit log | Evaluating AI flows |