API reference
API reference
Base URL https://gw.leashgate.com. Authenticate with your API key as a Bearer token.
POST /v1/chat/completions
OpenAI-compatible. Accepts the same body as OpenAI's Chat Completions API and returns the provider's answer, with blocked or held tool calls removed and explained in the message content.
Request
curl https://gw.leashgate.com/v1/chat/completions \
-H "Authorization: Bearer lg_your_key" \
-H "x-leash-agent: refunds-bot" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-4o-mini","messages":[{"role":"user","content":"Refund order A-1042"}],"tools":[...]}'Optional headers
x-leash-agent | Agent name. Letters, digits, dot, dash, underscore. |
x-upstream-base | Override the provider base URL for this call. |
x-upstream-key | Override the provider key for this call. |
Streaming responses (
stream: true) are forwarded as they arrive, so their tool calls are not inspected. Use non-streaming calls, or action checks, for actions that matter.POST /v1/actions/check
Ask Leashgate before running any action. No model involved.
Request
curl https://gw.leashgate.com/v1/actions/check \
-H "Authorization: Bearer lg_your_key" \
-H "Content-Type: application/json" \
-d '{"agent":"billing","action":"refund","params":{"amount":4800,"order":"A-1042"}}'Response
{
"decision": "approval_required", // allow | approval_required | block | quarantine
"reason": "amount $4,800 is above $1,000",
"observed": false, // true in observe mode: would have been stopped
"rule": "P-03",
"reason": "Payment above threshold",
"approval_id": "apr_k3x9q2mf"
}Retry the same call after approval: it returns "decision": "allow" once, within one hour.
Errors
| Status | Code | Meaning |
|---|---|---|
| 401 | invalid_key | Missing or unknown API key. |
| 400 | upstream_missing | No AI provider configured. |
| 403 | agent_quarantined | The agent is in quarantine. |
| 403 | loop_detected | The agent was just quarantined for looping. |
| 429 | budget_exceeded | The agent's daily budget is reached. |
Errors from /v1/chat/completions use OpenAI's error format, so your SDK raises them as usual.