{"openapi":"3.1.0","info":{"title":"Inferrail","version":"1","description":"Paid services for AI agents over x402 on Base and MPP on Tempo. Inferrail Web Read: one public web page as clean markdown, $0.002 per delivered page, refusals and target-site errors never charged, a retry never pays twice. Inferrail Hosted: one dollar budget shared by every agent and process that uses a workspace key, reserved before each OpenAI or Anthropic call, so parallel agents can't overspend a run. Create a workspace free with POST https://inferrail-cost-gateway.onrender.com/hosted/v1/workspaces; 250 governed runs a month are free. Send calls to https://inferrail-cost-gateway.onrender.com/hosted/v1/chat/completions (OpenAI shape) or https://inferrail-cost-gateway.onrender.com/hosted/v1/messages (Anthropic shape) with your own provider key, a work id and a ceiling. More runs: USDC over x402 at POST https://inferrail-cost-gateway.onrender.com/hosted/v1/credits/x402.","x-guidance":"Web Read: POST https://inferrail-cost-gateway.onrender.com/read/v1/page with {\"url\": ...}; pay the x402 or MPP challenge; HTTP 200 is the page. Send a request_id and retry with it if the response is lost (no second charge). Guide: https://inferrail-cost-gateway.onrender.com/read/llms.txt. Hosted: create a workspace (POST https://inferrail-cost-gateway.onrender.com/hosted/v1/workspaces), then call https://inferrail-cost-gateway.onrender.com/hosted/v1/chat/completions or https://inferrail-cost-gateway.onrender.com/hosted/v1/messages with the workspace key, your own provider key, a work id and a ceiling; full guide at https://inferrail-cost-gateway.onrender.com/hosted/llms.txt.","contact":{"name":"Inferrail","url":"https://github.com/domondi1/inferrail"}},"servers":[{"url":"https://inferrail-cost-gateway.onrender.com"}],"x-agentcash-guidance":{"llmsTxtUrl":"https://inferrail-cost-gateway.onrender.com/hosted/llms.txt"},"components":{"securitySchemes":{"WorkspaceKey":{"type":"apiKey","in":"header","name":"x-api-key","description":"Workspace key from POST https://inferrail-cost-gateway.onrender.com/hosted/v1/workspaces. 'Authorization: Bearer <key>' also works."}}},"paths":{"/hosted/v1/workspaces":{"post":{"summary":"Create an Inferrail Hosted workspace (free)","description":"Returns a workspace key, shown once. Every client using the key shares one dollar budget, reserved before each provider call. 250 governed runs a month are free.","security":[],"responses":{"201":{"description":"Workspace created","content":{"application/json":{"schema":{"type":"object","properties":{"workspace_id":{"type":"string"},"api_key":{"type":"string"},"base_url":{"type":"string"}},"required":["workspace_id","api_key","base_url"]}}}},"429":{"description":"Too many workspaces from this address"},"503":{"description":"Workspace creation paused or at capacity"}}}},"/hosted/v1/chat/completions":{"post":{"summary":"Governed OpenAI-shaped chat completion (shared run budget)","description":"Reserves the call's worst-case cost against the run's shared ceiling before it is sent to the provider; a call that would exceed it is refused and never reaches the provider. Provider spend is billed to your own key.","security":[{"WorkspaceKey":[]}],"parameters":[{"name":"X-Provider-Api-Key","in":"header","required":true,"schema":{"type":"string"},"description":"Your own OpenAI or Anthropic key. Sent per call, never stored."},{"name":"X-Inferrail-Attribute-Work-Id","in":"header","required":false,"schema":{"type":"string"},"description":"Run id. Every agent and process using the same id shares one budget."},{"name":"X-Inferrail-Budget-Usd","in":"header","required":false,"schema":{"type":"string","example":"0.50"},"description":"Ceiling for the run in USD (max 100). The first value given for a work id is kept."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","messages"],"properties":{"model":{},"messages":{}}}}}},"responses":{"200":{"description":"The provider's response, unchanged"},"401":{"description":"Missing or invalid workspace key"},"402":{"description":"Refused before the provider: the run's ceiling, or the workspace's free runs and credits, would be exceeded. Not an x402 payment request."}}}},"/hosted/v1/messages":{"post":{"summary":"Governed Anthropic-shaped message (shared run budget)","description":"Reserves the call's worst-case cost against the run's shared ceiling before it is sent to the provider; a call that would exceed it is refused and never reaches the provider. Provider spend is billed to your own key.","security":[{"WorkspaceKey":[]}],"parameters":[{"name":"X-Provider-Api-Key","in":"header","required":true,"schema":{"type":"string"},"description":"Your own OpenAI or Anthropic key. Sent per call, never stored."},{"name":"X-Inferrail-Attribute-Work-Id","in":"header","required":false,"schema":{"type":"string"},"description":"Run id. Every agent and process using the same id shares one budget."},{"name":"X-Inferrail-Budget-Usd","in":"header","required":false,"schema":{"type":"string","example":"0.50"},"description":"Ceiling for the run in USD (max 100). The first value given for a work id is kept."}],"requestBody":{"required":true,"content":{"application/json":{"schema":{"type":"object","required":["model","max_tokens","messages"],"properties":{"model":{},"max_tokens":{},"messages":{}}}}}},"responses":{"200":{"description":"The provider's response, unchanged"},"401":{"description":"Missing or invalid workspace key"},"402":{"description":"Refused before the provider: the run's ceiling, or the workspace's free runs and credits, would be exceeded. Not an x402 payment request."}}}},"/hosted/v1/workspace":{"get":{"summary":"Workspace usage: governed runs this month, free runs and credits left","security":[{"WorkspaceKey":[]}],"responses":{"200":{"description":"Usage"},"401":{"description":"Bad key"}}}},"/hosted/v1/work/{work_id}":{"get":{"summary":"One run's calls, cost and receipts","security":[{"WorkspaceKey":[]}],"parameters":[{"name":"work_id","in":"path","required":true,"schema":{"type":"string"}}],"responses":{"200":{"description":"The run"},"401":{"description":"Bad key"}}}},"/hosted/v1/credits/x402":{"post":{"summary":"Buy 1,000 governed runs of Inferrail Hosted","description":"Pay with USDC over x402. The 402 challenge needs no key; the paid request must carry the workspace key the runs are credited to. Each workspace gets 250 governed runs a month free, so buy only once they are used up (GET /hosted/v1/workspace shows what is left). Using the runs requires your own OpenAI or Anthropic key, sent per call and never stored.","security":[{"WorkspaceKey":[]}],"x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"1.00"},"protocols":[{"x402":{}}]},"requestBody":{"required":false,"content":{"application/json":{"schema":{"type":"object","properties":{}}}}},"responses":{"200":{"description":"Payment settled; runs credited","content":{"application/json":{"schema":{"type":"object","properties":{"workspace_id":{"type":"string"},"governed_runs":{"type":"integer"},"payment_ref":{"type":"string"},"status":{"type":"string","enum":["settled"]},"next":{"type":"string"}},"required":["workspace_id","governed_runs","status"]}}}},"401":{"description":"Missing or invalid workspace key"},"402":{"description":"Payment Required"}}}},"/read/v1/page":{"post":{"summary":"Read a public web page as clean markdown (pay per delivered page)","description":"Read one public web page as clean markdown (title, main text, headings, lists, links), with word count, a content hash and a receipt. Pay only for a delivered page: a blocked, missing or failing page (target-site 403, 404, 5xx, timeout) costs nothing, and neither do refusals (robots.txt, non-public address, non-text, >2 MB). A retry from the same wallet never pays twice.","security":[],"x-payment-info":{"price":{"mode":"fixed","currency":"USD","amount":"0.002"},"protocols":[{"x402":{}},{"mpp":{"method":"tempo","intent":"charge","currency":"0x20C000000000000000000000b9537d11c60E8b50"}}]},"requestBody":{"required":true,"content":{"application/json":{"schema":{"properties":{"url":{"description":"Public http(s) URL to read","maxLength":2048,"title":"Url","type":"string"},"request_id":{"default":null,"description":"Your id, echoed back. Retrying with the same url and request_id within the recovery window returns the paid page without a second charge.","maxLength":128,"title":"Request Id","type":"string"}},"required":["url"],"title":"PageRequest","type":"object"}}}},"responses":{"200":{"description":"The page, delivered and paid","content":{"application/json":{"schema":{"type":"object","properties":{"url":{"type":"string"},"final_url":{"type":"string"},"title":{"type":"string"},"content_markdown":{"type":"string"},"word_count":{"type":"integer"},"content_sha256":{"type":"string"},"fetched_at":{"type":"string"},"receipt":{"type":"object","properties":{"payment_ref":{"type":"string"},"price_usd":{"type":"string"},"request_id":{"type":"string"}}}},"required":["url","final_url","content_markdown","word_count","content_sha256"]}}}},"402":{"description":"Payment Required"},"422":{"description":"Not readable (see error); nothing charged"},"502":{"description":"Upstream failure; nothing charged"}}}}}}