Example Gallery
Working code examples for integrating with the Curate-Me gateway. Each example is a standalone script you can run after setting your gateway URL and API key.
All source code is in examples/gateway-pilot/.
OpenAI SDK Integration
Use the standard OpenAI SDK with two lines changed: base_url and api_key. Every call gets automatic cost tracking, rate limiting, PII scanning, and audit logging.
| Language | File |
|---|---|
| Python | openai_example.py |
| TypeScript | openai.ts |
Claude / Anthropic SDK Integration
Route Anthropic SDK calls through the gateway for cost governance and observability. Works with the official anthropic Python and TypeScript SDKs.
| Language | File |
|---|---|
| Python | claude_sdk_example.py |
LangChain Integration
Plug the gateway into LangChain as a custom LLM endpoint. All chains, agents, and tools get governed automatically.
| Language | File |
|---|---|
| Python | langchain_example.py |
| TypeScript | langchain.ts |
Streaming Responses
Stream chat completions through the gateway. Tokens arrive as they are generated, and governance headers are included in the initial response.
| Language | File |
|---|---|
| Python | streaming.py |
| TypeScript | streaming.ts |
Error Handling Patterns
Graceful handling of rate limit responses, budget exhaustion, and governance denials. Shows how to read RateLimit-* headers and X-CM-Governance-Time-Ms.
| Language | File |
|---|---|
| Python | error_handling.py |
| TypeScript | error-handling.ts |
Cost and Budget Controls
Set per-request cost limits and daily budgets. The gateway blocks requests that would exceed the configured threshold and returns a clear error with remaining budget info.
| Language | File |
|---|---|
| Python | cost_budget.py |
| TypeScript | cost_budget.ts |
Runner Quickstart
Launch a managed OpenClaw runner, dispatch work to it, and retrieve results. Demonstrates the full container lifecycle: create, execute, and terminate.
| Language | File |
|---|---|
| Python | runner_quickstart.py |
| TypeScript | runner_quickstart.ts |
Multi-Model Routing
Route different requests to different providers based on task complexity, cost, or latency requirements. Shows provider fallback chains.
| Language | File |
|---|---|
| Python | multi_model.py |
| TypeScript | multi_model.ts |
Setup
All examples require three environment variables:
export CM_GATEWAY_URL=https://api.curate-me.ai # or http://localhost:8002
export CM_API_KEY=cm_sk_... # your gateway API key
export PROVIDER_KEY=sk-... # your upstream provider keySee the Quick Start guide for key provisioning.