Gateway
Change one line, pay less on every call. A drop-in proxy for the OpenAI and Anthropic SDKs, self-hosted or hosted.
Self-hosted (recommended): your key never leaves your machine
Run agentready-cloud-gateway (MIT) next to your app. For each chat request it sends only the message text to AgentReady to be compressed, then calls OpenAI or Anthropic directly with your own key. Your provider key and the model's answers never reach AgentReady; if we are unreachable, the original messages go out unchanged.
AGENTREADY_API_KEY=ak_your_key npx -y agentready-cloud-gateway
# → http://127.0.0.1:8787 (env: AGENTREADY_LEVEL, AGENTREADY_OUTPUT, PORT, HOST, OPENAI_BASE_URL)from openai import OpenAI
client = OpenAI(base_url="http://127.0.0.1:8787/openai/v1") # OPENAI_API_KEY as usual
from anthropic import Anthropic
client = Anthropic(base_url="http://127.0.0.1:8787/anthropic") # ANTHROPIC_API_KEY as usualHosted: zero setup
from openai import OpenAI
client = OpenAI(base_url="https://agentready.cloud/v1/p/ak_your_key/openai")
from anthropic import Anthropic
client = Anthropic(base_url="https://agentready.cloud/v1/p/ak_your_key/anthropic")import OpenAI from "openai";
const client = new OpenAI({ baseURL: "https://agentready.cloud/v1/p/ak_your_key/openai" });
import Anthropic from "@anthropic-ai/sdk";
const claude = new Anthropic({ baseURL: "https://agentready.cloud/v1/p/ak_your_key/anthropic" });With the hosted gateway your provider key passes through AgentReady on its way to the provider. It is never stored or logged, and URLs that contain your AgentReady key are excluded from our access logs, but if that is not acceptable for you, use the self-hosted gateway above or the compress-only API below.
What changes, what doesn't
- Rewritten: system, developer, user and tool messages of chat requests (OpenAI
chat/completions, Anthropicv1/messages), when the text is at least 200 characters. - Never touched: assistant turns, tool calls, images and files, short messages, and every other endpoint (models, embeddings, …), which is forwarded as is.
- Streaming, tools and function calling work as before. Errors from the provider come back unchanged.
- Every response carries
X-AgentReady-Original-Tokens,X-AgentReady-Compressed-TokensandX-AgentReady-Tokens-Saved.
Optional headers
| Header | Default | Effect |
|---|---|---|
| X-AgentReady-Level | caveman | caveman · aggressive · standard · light · off. How hard prose is trimmed (greetings, hedges, filler). Code, URLs and numbers are never touched. |
| X-AgentReady-Json | toon | toon · off. Messages whose whole content is JSON become TOON when that is at least 10% smaller. |
| X-AgentReady-Output | off | off · lite · caveman · ultra. Adds a short system rule so the model answers tersely: this is where output tokens are saved. |
| X-AgentReady-Key | — | Your AgentReady key, if you use /v1/gateway/... instead of putting the key in the base_url. |
client = OpenAI(
base_url="https://agentready.cloud/v1/p/ak_your_key/openai",
default_headers={"X-AgentReady-Output": "caveman", "X-AgentReady-Level": "aggressive"},
)Prefer to keep your traffic direct?
Use /v1/compress: you send us only the messages, we send them back squeezed, and you call your provider yourself. Or install the MCP server in your assistant.