Skip to main content

Examples Guide

Chronos ships with 25+ runnable examples covering every major feature. Most require no API keys and run entirely with mock providers and SQLite. They are grouped by type so you can jump straight to what you need:

CategoryWhat it covers
FundamentalsAgent builder, tools, guardrails, graph patterns, memory, streaming — all no-key
LLM AgentsLive-LLM workflows: StateGraph reasoning, MCP tools, coding agent, multi-agent teams
Providers & ModelsAzure OpenAI, Vertex AI, Bedrock, multi-provider comparison, failover
Durability & SandboxingDurable queue, human-in-the-loop resume, process sandboxing
Enterprise & Multi-TenancyOIDC/JWKS SSO, data residency, per-tenant memory isolation
Observability & CLIMetrics/cost/cache/retry hooks, CLI-driven agents and ops
YAML Agent ExamplesProgressive YAML applications: single agents, routers, pipelines, advanced teams, and governed deployments

Running Examples

# Clone the repo
git clone https://github.com/spawn08/chronos.git
cd chronos

# Run any example
go run ./examples/<name>/

Choosing a provider

Every example that talks to a real LLM (graph_with_llm, mcp_agent, coding_agent, team_deploy, multi_agent, multi_provider) resolves its provider through a shared helper — examples/internal/providers.Pick() — which reads the environment and returns the first configured provider. You never edit the example to switch clouds; you just export a different set of environment variables.

ProviderEnvironment variables
OpenAIOPENAI_API_KEY
AnthropicANTHROPIC_API_KEY
Google Gemini (AI Studio)GEMINI_API_KEY
Azure OpenAIAZURE_OPENAI_API_KEY + AZURE_OPENAI_ENDPOINT + AZURE_OPENAI_DEPLOYMENT (+ optional AZURE_OPENAI_API_VERSION)
Google Cloud Vertex AIGOOGLE_CLOUD_PROJECT + GOOGLE_ACCESS_TOKEN (+ optional GOOGLE_CLOUD_LOCATION, VERTEX_MODEL)
AWS BedrockAWS_REGION + AWS_ACCESS_KEY_ID + AWS_SECRET_ACCESS_KEY (+ optional BEDROCK_MODEL_ID)
MistralMISTRAL_API_KEY
Ollama (local)OLLAMA_HOST (+ optional OLLAMA_MODEL)
Any OpenAI-compatibleOPENAI_COMPATIBLE_BASE_URL + OPENAI_COMPATIBLE_MODEL (+ optional _API_KEY, _NAME) — Together, Groq, DeepSeek, OpenRouter, Fireworks, Perplexity, Anyscale, vLLM, LiteLLM

The four common cloud setups look like this — pick one, then run any real-LLM example:

# OpenAI
export OPENAI_API_KEY=sk-...

# Azure OpenAI
export AZURE_OPENAI_API_KEY=...
export AZURE_OPENAI_ENDPOINT=https://your-resource.openai.azure.com
export AZURE_OPENAI_DEPLOYMENT=gpt-4o # your deployment name
export AZURE_OPENAI_API_VERSION=2024-12-01-preview

# Google Cloud Vertex AI (OpenAI-compatible endpoint + gcloud token)
export GOOGLE_CLOUD_PROJECT=my-gcp-project
export GOOGLE_CLOUD_LOCATION=us-central1
export VERTEX_MODEL=google/gemini-2.5-pro
export GOOGLE_ACCESS_TOKEN=$(gcloud auth print-access-token)

# AWS Bedrock
export AWS_REGION=us-east-1
export AWS_ACCESS_KEY_ID=...
export AWS_SECRET_ACCESS_KEY=...
export BEDROCK_MODEL_ID=anthropic.claude-3-5-sonnet-20241022-v2:0
tip

Precedence is fixed (OpenAI → Anthropic → Gemini → Azure → Vertex → Bedrock → Mistral → Ollama → compatible). To force a specific cloud when several key sets are present, unset the higher-precedence ones in that shell.

Full Index

Fundamentals — no API key

ExampleFeature area
quickstartAgent builder, SQLite, StateGraph
chat_with_toolsTool calling loop
tools_and_guardrailsPermissions, guardrails
graph_patternsConditional edges, interrupts, streaming
memory_and_sessionsShort/long-term memory, sessions
streaming_sseEvent broker, SSE

LLM Agents — API key (mock fallback)

ExampleFeature area
graph_with_llmStateGraph + live LLM
mcp_agentModel Context Protocol tools
coding_agentAutonomous coding agent + RAG
multi_agent4 team strategies, bus delegation
team_deployYAML teams + sandbox deploy

Providers & Models

ExampleFeature area
multi_providerMultiple providers side by side
azureAzure OpenAI (chat + streaming)
vertexGoogle Cloud Vertex AI
fallback_providerProvider failover

Durability & Sandboxing — no API key

ExampleFeature area
durable_queueLeased workers, sleep, park/signal HITL, orphan recovery
durable_hitlHuman-in-the-loop approval with checkpoint + resume
sandbox_executionProcess sandbox with timeouts and I/O capture

Enterprise & Multi-Tenancy

ExampleFeature area
enterprise_ssoChronosOS behind OIDC/JWKS SSO
data_residencyPer-tenant storage routing (EU vs US)
multitenant_memoryPer-tenant long-term memory isolation on one agent

Observability & CLI

ExampleFeature area
hooks_observabilityMetrics, cost, cache, retry, rate limit
cli_agentBuild, inspect, run an agent from YAML via the CLI
cli_opsOperate Chronos from the CLI (serve, monitor, db, sessions, pipe, deploy)