Backstop
Explanation

Why In-Process vs. Proxies

The latency, compliance, and egress argument for Backstop's in-process transport design.

Backstop intercepts AI provider calls inside your application process by replacing the SDK's internal httpx transport. It does not sit between your app and the provider as a network proxy. This page explains the trade-offs.

The comparison

ApproachLatencyComplexityIn-processPrivacy
Hope the agent stops0 msnonen/an/a
Proxy gateway (LiteLLM, etc.)+network hophigh✗payloads cross trust boundary
Backstop0.07 ms p50one wrap call✓payloads stay local

The 0.07 ms is the cost of Backstop's control-path checks — budget reservation, circuit state, admission gate — measured against a bare httpx.MockTransport. It is not provider latency. Your actual requests still go directly to the provider, so you pay zero additional network hop.

Read the conditions with the number. It comes from the one snapshot the repository commits (docs/benchmark-results-2026-07-20.md): 1,000 requests, a local mock transport, no network, seed 0x00C0FFEE, dated 2026-07-20, and the same 0.07 ms at p50, p95 and p99. The snapshot does not record the host CPU, the OS, the Python version or the SDK version, so it is one recorded run and not a guarantee. Re-measure on your own host with backstop benchmark. An earlier README claimed ~0.09 ms p50 on a named configuration that no artifact recorded; upstream deleted that claim rather than restate it, and so should you.

One number this table does not cover: the opt-in spend ledger is not this cheap. With the ledger on, a request roughly doubles in cost — roughly +130 to +147 µs p50 against +3–5 µs with it off — and that figure is published too.

Why in-process?

1. Latency

A proxy gateway adds a network round-trip to every request, on top of the provider's response time. Backstop's in-process overhead is tens of microseconds because it runs in the same process as your application, with no network hop. The specific gateway figures this site shows elsewhere are labelled as a model of one remote hop rather than a measurement, because that is what they are.

Your app → provider:            ~300 ms  (network + provider)
Your app → Backstop → provider: ~300.07 ms  (same, +0.07 ms control path)
Your app → proxy → provider:    ~300 ms + a whole network hop

The 300 ms figures are illustrative — a typical agentic call, not a Backstop measurement. The +0.07 ms is the committed snapshot described above.

2. Compliance

Backstop never sees your provider API keys. It sits inside the same process as your application — the same process that holds the keys. The keys are used exactly as they were before wrapping. No third-party proxy ever has access to them.

For compliance-sensitive workloads (HIPAA, SOC 2, PCI), this means you don't have to trust a third-party proxy with your credentials.

3. Prompt privacy

Prompt and response payloads never leave your application process. They are not sent to a Backstop-hosted service, not logged by a proxy, and not stored in an intermediary. Backstop's metrics describe control-plane behavior (budget usage, circuit state, queue depth) — not raw content.

4. Egress

With a proxy, your outbound traffic goes to the proxy first, then to the provider. This means:

  • Additional egress charges (you pay for both hops).
  • Additional failure surface (the proxy itself can fail).
  • Additional infrastructure to monitor and maintain.

With Backstop, traffic goes directly to the provider — same as before. No new egress paths, no new failure modes.

What it does NOT do

Backstop is deliberately narrow in scope. These are not Backstop's job:

  • Not a proxy. No network traffic passes through Backstop; requests go directly to the provider. No new egress paths, no additional network hop.
  • Not a control plane. No central server, no key management, no multi-tenant routing. Backstop does not store or see your API keys.
  • Not a multi-provider router. Use LiteLLM or similar if you need fallback across providers (e.g. OpenAI → Anthropic on error). Backstop's fallback chain operates at the transport level within a single provider family.
  • Not observability storage. Backstop emits metrics; you send them to your own backend (Prometheus, OpenTelemetry, etc.).
  • Not LangGraph/CrewAI-native. Works with those frameworks only at the SDK level — at the httpx transport layer — not via framework-specific hooks.

Request flow

Application code
  → official OpenAI or Anthropic SDK client
  → Backstop transport (budget, circuit, admission, retry, cache, metrics)
  → provider SDK HTTP transport
  → provider API

No monkey-patching, no import hooks, no wrapper classes around the SDK client. The SDK's own retry and auth logic runs above the transport, so Backstop errors propagate correctly to your existing error handlers.

Local vs. shared mode

Backstop runs in one of two modes:

  • Local mode (default) — Budget, circuit, cache, and AIMD state live in the application process. Best for single-process apps, development, CI, and teams that want prompt privacy without extra infrastructure.
  • Shared mode — Budget state is stored in Redis so multiple replicas share one cap. Use when running multiple containers or serverless functions behind a load balancer.

See Shared Budgets Across Replicas for shared-mode setup.


— Edit this page on GitHub

On this page