Skip to main content

Go Examples & Task Cookbook

Use these runnable Go examples when you want to see how a task works in practice. Each guide connects the example to the related product documentation, so you can start with a small working path and then explore the relevant configuration.


Find a Guide by Task​

GoalGuide / Demo
Start buildingGo SDK Quickstart · Standalone Gateway Quickstart · Docker Compose
Connect Python/TS SDKs & Coding IDEsIntegrations Overview · OpenAI SDKs · Anthropic SDKs · Claude Code · Cursor & IDEs
Configure routing, fallbacks & cachingRouting & Load Balancing · Resiliency & Fallbacks · Exact-Match Cache
Enforce Virtual Keys, RBAC & GuardrailsVirtual Keys · RBAC & Vault · Guardrails · SSRF & Network Security
Track FinOps spend & rate limitsMicro-Dollar Ledger · Sliding-Window Rate Limits · Pre-Flight Tokenization
Monitor telemetry & troubleshootObservability & Health Probes · OpenTelemetry & Prometheus · Operator Web UI · Troubleshooting
Run MCP tool hubs & A2A agent networksMCP Overview · A2A Overview · Autonomous Tool Loop
Deploy to productionConfiguration · Deployment & Storage · Kubernetes & Kustomize · Production Checklist

Running Any Demo​

Run an example from the examples/ module after its Go dependencies are available:

cd examples
go run ./hello_gateway

Most examples enable the built-in mock provider when credentials are missing, so they can demonstrate the request flow without contacting a model provider. Examples that require a local service, such as Ollama or an HTTP server, still need that service running. To test a live provider, export the matching key before running its example:

export OPENAI_API_KEY="sk-proj-..."
export ANTHROPIC_API_KEY="sk-ant-..."
export GEMINI_API_KEY="AIzaSy... or AQ.Ab8..."

The examples module declares its Go toolchain version in examples/go.mod. See each example's source for the provider, local service, or environment variables it needs.


Examples by task​

Fundamentals​

Multi-Provider Integrations​

Tool Calling & Autonomous Agents​

Traffic Routing & Outage Resiliency​

Enterprise FinOps, Protocols & Microservices​