Skip to Content
Example Gallery

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.

LanguageFile
Pythonopenai_example.py
TypeScriptopenai.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.

LanguageFile
Pythonclaude_sdk_example.py

LangChain Integration

Plug the gateway into LangChain as a custom LLM endpoint. All chains, agents, and tools get governed automatically.

LanguageFile
Pythonlangchain_example.py
TypeScriptlangchain.ts

Streaming Responses

Stream chat completions through the gateway. Tokens arrive as they are generated, and governance headers are included in the initial response.

LanguageFile
Pythonstreaming.py
TypeScriptstreaming.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.

LanguageFile
Pythonerror_handling.py
TypeScripterror-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.

LanguageFile
Pythoncost_budget.py
TypeScriptcost_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.

LanguageFile
Pythonrunner_quickstart.py
TypeScriptrunner_quickstart.ts

Multi-Model Routing

Route different requests to different providers based on task complexity, cost, or latency requirements. Shows provider fallback chains.

LanguageFile
Pythonmulti_model.py
TypeScriptmulti_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 key

See the Quick Start guide for key provisioning.