GATEWAY // DEVELOPER REFERENCE
Documentation
Configure the proxy endpoint, integrate agent frameworks, and handle protection responses.
01. Quickstart
Create a protected key from the dashboard, then replace the client base URL and API key. The key shown below is a placeholder.
from openai import OpenAI
client = OpenAI(
base_url="https://circuit-breaker-api.onrender.com/v1",
api_key="cb_live_...",
)
response = client.chat.completions.create(
model="gpt-4o-mini",
messages=[{"role": "user", "content": "Hello"}],
)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://circuit-breaker-api.onrender.com/v1",
apiKey: "cb_live_...",
});
const response = await client.chat.completions.create({
model: "gpt-4o-mini",
messages: [{ role: "user", content: "Hello" }],
});02. Framework Integration
Set the framework's OpenAI-compatible endpoint to the gateway and provide a protected Circuit Breaker key.
import os
from crewai import LLM, Agent
llm = LLM(
model="openai/gpt-4o-mini",
base_url="https://circuit-breaker-api.onrender.com/v1",
api_key=os.environ["CIRCUIT_BREAKER_API_KEY"],
)
researcher = Agent(
role="Research analyst",
goal="Answer the assigned research question",
backstory="A careful technical researcher.",
llm=llm,
)import os
from langchain_openai import ChatOpenAI
llm = ChatOpenAI(
model="gpt-4o-mini",
base_url="https://circuit-breaker-api.onrender.com/v1",
api_key=os.environ["CIRCUIT_BREAKER_API_KEY"],
)
# Use llm.invoke(...) directly or bind it to a LangGraph node.import os
from autogen import AssistantAgent
config_list = [{
"model": "gpt-4o-mini",
"api_type": "openai",
"base_url": "https://circuit-breaker-api.onrender.com/v1",
"api_key": os.environ["CIRCUIT_BREAKER_API_KEY"],
}]
assistant = AssistantAgent(
name="assistant",
llm_config={"config_list": config_list},
)curl https://circuit-breaker-api.onrender.com/v1/chat/completions -H "Authorization: Bearer cb_live_..." -H "Content-Type: application/json" -d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Hello"}],"stream":false}'/v1/chat/completions. Include the protected key as a bearer token and send an OpenAI-compatible JSON body with at least a model and messages field. Do not embed upstream provider keys in client-side applications.03. Error Codes & Protocols
A blocked request includes a machine-readable code in its JSON error body.
| HTTP | Error code | Meaning |
|---|---|---|
| 400 | infinite_loop_killed | Prompt repetition threshold exceeded; the loop request was stopped. |
| 429 | budget_limit_breached | Hourly or daily dollar ceiling reached. |
| 502 | upstream_error | Upstream provider is unreachable or timed out. |
{
"error": {
"message": "Request blocked by Circuit Breaker",
"type": "circuit_breaker_loop_detected",
"code": "infinite_loop_killed"
}
}04. Encryption & Security
Upstream credentials
Encrypted at rest with AES-256 (Fernet) before database insertion.
Protected key lookup
SHA-256 key hashing is used for lookup; full protected secrets are shown once.
Prompt bodies
Used in memory for loop detection and not written to disk.
Request logs
Usage and operational metadata are recorded; prompt text is not part of the request log schema.
Do not send sensitive prompt data unless your organization's data handling requirements permit processing by the configured model provider.
05. Pricing & Limits
Free tier includes $15/mo monitored spend with hourly and daily caps. Pro is $29/mo and includes configurable production ceilings according to plan.
Review plans and limits →