GATEWAY // DEVELOPER REFERENCE

Documentation

Configure the proxy endpoint, integrate agent frameworks, and handle protection responses.

01. Quickstart

Create a Shunt key from the dashboard, then replace the client base URL and API key. For Zero-Trust Mode, send your provider credential as x-upstream-key; it is processed in memory and not stored.

OpenAI Python
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"}],
)
OpenAI TypeScript
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 Shunt and provide a Shunt API key.

CrewAI · Python
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["SHUNT_API_KEY"],
)

researcher = Agent(
    role="Research analyst",
    goal="Answer the assigned research question",
    backstory="A careful technical researcher.",
    llm=llm,
)
LangChain / LangGraph · Python
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["SHUNT_API_KEY"],
)

# Use llm.invoke(...) directly or bind it to a LangGraph node.
AutoGen · Python
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["SHUNT_API_KEY"],
}]

assistant = AssistantAgent(
    name="assistant",
    llm_config={"config_list": config_list},
)
cURL / REST API
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}'
Send requests to /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

Loop detection returns an OpenAI-compatible HTTP 200 completion with finish_reason: stop. Invalid keys return HTTP 400; budget breaches return HTTP 429.

HTTPError codeMeaning
200finish_reason: stopPrompt repetition threshold exceeded; a graceful completion stops the agent without an HTTP retry.
400missing_upstream_keyNo provider key was supplied in the request header or encrypted vault.
429budget_limit_breachedHourly or daily dollar ceiling reached.
502upstream_errorUpstream provider is unreachable or timed out.
Graceful loop-stop completion
{
  "object": "chat.completion",
  "choices": [{
    "message": { "role": "assistant", "content": "[SHUNT ALERT]: Execution halted." },
    "finish_reason": "stop"
  }],
  "circuit_breaker": { "triggered": true, "reason": "Repeated prompt." }
}

04. Encryption & Security

Zero-Trust credentials

Supplied with x-upstream-key and processed in request memory without storage.

Vault credentials

Optionally encrypted at rest with AES-256 (Fernet).

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 →