LeashgateDocs
Get started

Integrations

Recipes for the frameworks and no-code tools your team already uses. Nothing to install.

Any framework that lets you set a base URL works with your own provider key: use the address from the Providers page. The recipes below use the other option, where Leashgate holds one OpenAI-compatible provider key (Settings → AI provider) and your code uses https://gw.leashgate.com/v1 with the Leashgate key.

from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="gpt-4o-mini",
    base_url="https://gw.leashgate.com/v1",
    api_key="lg_your_key",
    default_headers={"x-leash-agent": "support-bot"},
)
agent = create_react_agent(llm, tools)  # tool calls are now checked

MCP server: let your coding assistant set it up

Leashgate has an MCP server at https://gw.leashgate.com/mcp. Add it to Claude Code, Cursor or any MCP client, then ask in plain words: "put my support agent behind Leashgate". The assistant gets the exact address for your provider, makes the one change, and checks that the first call arrived.

Add the server
# Claude Code
claude mcp add --transport http leashgate https://gw.leashgate.com/mcp --header "Authorization: Bearer lg_your_key"

# Cursor and other clients (mcp.json)
{ "mcpServers": { "leashgate": { "url": "https://gw.leashgate.com/mcp", "headers": { "Authorization": "Bearer lg_your_key" } } } }

In the Claude apps (web, desktop, mobile), add a custom connector and paste this address, which carries your key: https://gw.leashgate.com/mcp/k/lg_your_key. Treat that address like a password.

Three tools: connect_guide (the address and the one change for a provider), check_action (ask before a refund, a deletion, a send) and workspace_status (verify the setup). The server uses your workspace API key and never sees your provider keys.

Notes per tool

  • OpenAI Agents SDK and Vercel AI SDK: with your own key and the provider address, the Responses API works as is. With https://gw.leashgate.com/v1, switch them to Chat Completions as shown.
  • n8n, Make, Zapier: add an HTTP step that calls /v1/actions/check before the risky step, then a filter that continues only when decision is allow.
  • MCP servers and custom tools: call /v1/actions/check at the start of the tool handler, or wrap the function with the guard shown above.
  • Give each agent its own name with /a/<name>/ in the address, the x-leash-agent header, or agent in an action check, to get per-agent budgets, history and a kill switch.

Leashgate key as the API key

When Leashgate holds the provider key, change two lines instead of one:

from openai import OpenAI

client = OpenAI(
    base_url="https://gw.leashgate.com/v1",
    api_key="lg_your_key",
)

# Your agent code stays the same.
reply = client.chat.completions.create(
    model="llama-3.3-70b-versatile",
    messages=[{"role": "user", "content": "Refund order A-1042"}],
    tools=tools,
)

Python SDK

Install it with pip install leashgate. It has no dependencies. lg.check(action, params) returns the decision; @lg.guard("refund") wraps a function so it only runs when your rules allow it; pass wait=900 to wait up to 15 minutes for a human decision. The source code is open (MIT) on GitHub, with runnable examples.

JavaScript and TypeScript

Install it with npm install leashgate (Node 18+, Deno, Bun and edge runtimes, no dependencies). new Leashgate({ agent: "cleanup-job" }) reads LEASHGATE_API_KEY; lg.guard("drop_table", fn) wraps a function so it only runs when your rules allow it, and throws ActionBlocked or ApprovalRequired otherwise.