Python Quickstart
Using the Curate-Me Python SDK (Recommended)
The SDK configures the OpenAI client to route through the gateway automatically:
pip install curate-me openaifrom curate_me.gateway import CurateGateway
gw = CurateGateway(api_key="cm_sk_xxx")
# Get a pre-configured OpenAI client pointed at the gateway
client = gw.openai()
response = client.chat.completions.create(
model="anthropic/claude-haiku-4-5",
messages=[{"role": "user", "content": "Hello"}]
)
print(response.choices[0].message.content)You can also pass a provider key explicitly if you are not using stored secrets:
client = gw.openai(provider_key="sk-your-openai-key")Using the OpenAI SDK Directly
If you prefer not to use the Curate-Me SDK, just change the base URL and
point the OpenAI SDK at the gateway. Set api_key to your Curate-Me
gateway key (cm_sk_...) — the SDK forwards it as Authorization: Bearer cm_sk_..., which the gateway accepts, and your provider key is
resolved from your stored Provider Secret. Do not put a placeholder
string here: any non-cm_sk_ value is treated as an inline provider key
and forwarded upstream, which fails with a 401.
from openai import OpenAI
client = OpenAI(
base_url="https://api.curate-me.ai/v1/openrouter",
api_key="cm_sk_xxx", # your Curate-Me gateway key
default_headers={"X-CM-API-Key": "cm_sk_xxx"},
)
response = client.chat.completions.create(
model="anthropic/claude-haiku-4-5",
messages=[{"role": "user", "content": "Explain AI governance in one sentence."}],
)
print(response.choices[0].message.content)To send a provider key inline instead of storing it, add an
X-Provider-Key header rather than overloading api_key:
client = OpenAI(
base_url="https://api.curate-me.ai/v1/openrouter",
api_key="cm_sk_xxx",
default_headers={
"X-CM-API-Key": "cm_sk_xxx",
"X-Provider-Key": "sk-your-openrouter-key",
},
)Using Anthropic Models (Native SDK)
from curate_me.gateway import CurateGateway
gw = CurateGateway(api_key="cm_sk_xxx")
client = gw.anthropic()
message = client.messages.create(
model="claude-sonnet-4-5-20250929",
max_tokens=1024,
messages=[{"role": "user", "content": "Hello!"}],
)
print(message.content[0].text)Checking Usage
# Response headers include governance metadata
print(response.headers.get("X-CM-Cost"))
print(response.headers.get("X-CM-Request-Id"))
print(response.headers.get("RateLimit-Remaining"))
print(response.headers.get("X-CM-Governance-Time-Ms"))