SuperAPIAI Directory

inferrail

github.com · AI developer platforms

Inferrail is a self-hosted OpenAI/Anthropic-compatible gateway whose core purpose is to set a USD budget for each AI agent run and enforce that budget before requests reach the model provider, while producing per-run cost records that contain no message payloads. The project also provides a hosted "external evidence" API (such as Web Read, package checks, and domain lookups) plus companion SDKs, MCP tools, and a Claude Code plugin. The self-hosted gateway requires Python 3.11+ and supports the OpenAI-compatible /v1/chat/completions and Anthropic-compatible /v1/messages endpoints, including streaming and tool calls; prices for OpenAI and Anthropic models are built in, while other providers require their own configured prices, otherwise costs are recorded as unknown. The hosted service is billed per call: Web Read costs 2 credits ($0.002) per delivery, hosted inference includes 250 qualifying runs per workspace per month free, then $0.001 per run.

Open website Alternatives
PricingOpen source开源项目(可免费自部署)
PlatformsAPI

About this tool

Purpose

Inferrail primarily addresses cost control in AI agent runs. It provides a self-hosted OpenAI/Anthropic-compatible gateway that gives each agent run a USD budget; the budget is checked and enforced before requests are forwarded to the model provider, and a cost record containing no message payload is written for each request.

In addition, the project provides a hosted "external evidence" API that lets agents retrieve public web pages, document text, and investigative data, with structured results and transparent per-result pricing.

Main capabilities

Self-hosted inference gateway

  • Compatible endpoints:POST /v1/chat/completions(OpenAI-compatible) and POST /v1/messages(Anthropic-compatible), supporting streaming and tool calls, plus GET /v1/models.
  • Budget control: Calls with the same work id share a budget, including parallel calls. At admission time, a conservative estimate is reserved before calling the provider; actual usage may exceed the estimate, the excess is recorded, and subsequent calls are rejected.
  • Cost records: Costs are recorded only when the provider reports usage and a price is present in the configuration; otherwise they are recorded as unknown, never guessed as $0.
  • Payload-agnostic: Receipts do not contain message content;inferrail verify-payload-free can print a live receipt mode, and a canary test checks that message bodies do not enter receipts.
  • Providers: OpenAI, Anthropic, and endpoints compatible with both. Built-in prices cover OpenAI and Anthropic models; other providers require prices in the configuration.
  • Not supported: OpenAI Responses API, embeddings, image generation, audio and Realtime, batch, and native Gemini or Bedrock APIs. Fields the gateway cannot account for are explicitly rejected with an error, never silently dropped.
  • Scope: Only calls through a running gateway are counted.

Hosted evidence API

  • Web Read: Retrieves raw public sources as clean Markdown, with title, source URL, retrieval timestamp, content hash, and payment receipt. Each delivery of a page or PDF costs 2 credits ($0.002).
  • Package Check:POST /pkg/credits/v1/check, returns known OSV vulnerability advisories and available fixes; it is not a security certification.
  • Domain Check:POST /domain/credits/v1/lookup, returns DNS, email policy, and available registration data; it is not a trust determination.
  • Finder:POST /find/v1/find, each delivered answer costs $0.002 and returns call details for up to five selected directory resources; no charge when no API matches.
  • Billing: wallet authorization is verified before extraction and settled after successful extraction; credits are frozen first, charged on success and released on failure. Structured rejections and upstream failures are not charged.
  • Recovery: within 10 minutes, the same URL, request_id and wallet/workspace can recover an already-paid result without being charged again.
  • Limits: public HTTP(S) only, robots.txt respected, HTML/text 2 MB, PDF 5 MB, first 50 pages of PDF; text-layer extraction only, no OCR, JavaScript, login or paywall bypass; at most three redirects, 15-second timeout per request.

SDK and MCP

  • npm package @inferrail/ai-sdk-tools@0.3.2 supports prepaid Web Read, Package Check, Domain Check, wallet tools and explicit credit batch failure reporting.
  • Wallet mode uses inferrailTools({ fetch: wrapFetchWithPayment(fetch, client) }), providing readPage、readPages、checkPackages、lookupDomain、findPaidApi.
  • Paid local MCP:npx -y @inferrail/ai-sdk-tools@0.3.2, using INFERRAIL_API_KEY(prepaid credits) or INFERRAIL_WALLET_KEY(USDC on Base).INFERRAIL_MAX_USD_PER_DAY defaults to $0.10 and only constrains that server's local daily spending record, not an account-level cap.
  • Read-only gateway MCP:inferrail mcp provides get_spend and get_health, and cannot purchase pages, execute paid tools or run inference.

Hosted inference budget

  • One workspace ledger shares an inference budget across multiple agents and machines. Create a key, send the provider key with each request, and use the same work ID and cap.
  • Each workspace gets 250 qualifying runs free per UTC month, after which each run costs $0.001 from prepaid credits. Billing occurs only when the provider answers the call. Model provider fees are separate.

Usage

Self-hosted gateway quick start

Requires Python 3.11+. Can be tried offline with no API key, network calls or provider fees: the demo sends scripted requests through the real engine to a fake provider with fictional prices and prints the per-customer cost.

Set a budget for a run inside a Python application, with no config file or second process: calls with the same work id share the budget, including parallel calls.inferrail work contract-review-42 can show the cost of that run.

It can also run as a shared gateway with a local dashboard, and provides framework snippets for LangChain, LangGraph, OpenAI Agents SDK, CrewAI, Haystack, LlamaIndex, Microsoft Agent Framework and others, as well as other clients such as the Anthropic SDK.

Hosted Web Read quick start

  1. Create and top up a key in the browser; the hosted page shows the key only once, then offers credit card checkout.
  2. A $10 package gives 10,000 credits, enough for 5,000 delivered reads. No subscription or auto top-up.
  3. Call Web Read with the key. Insufficient balance returns 402 insufficient_credits before the read.
  4. You can also top up via USDC: $1 for 1,000 credits.

Claude Code plugin

/plugin install inferrail --marketplace domondi1/inferrail. Use npx skills update to update, or first /plugin marketplace update inferrail then /plugin update inferrail@inferrail. Skill uses an authorized wallet; paid MCP is the prepaid Web Read path. Package checks in CI require a wallet and a spending cap.

Applicable scenarios

  • Development teams that need to set a hard USD budget for agent runs and audit the cost of each call.
  • Research, document ingestion, citation, and repeated document reading scenarios that need to bring public web pages and documents into the agent context as clean Markdown while preserving source, time, and receipts.
  • Automated workflows that need to check dependency package vulnerability advisories or query domain DNS/email policies in CI.
  • Projects using OpenAI- or Anthropic-compatible interfaces that want to add budget governance without changing application code.

Limitations

  • The self-hosted gateway only governs routed inference calls that pass through the running gateway; it does not cover requests made directly to providers.
  • It does not support the OpenAI Responses API, embeddings, image generation, audio, Realtime, batch, or native Gemini/Bedrock APIs.
  • Non-OpenAI/Anthropic models require manual price configuration; otherwise the cost is recorded as unknown.
  • Web Read performs text-layer extraction only, with no OCR, JavaScript rendering, login, or paywall bypass; JavaScript shell pages may be returned, so content must be checked rather than assumed complete.
  • The hosted evidence API is still in developer preview at the time of validation; commercial availability and maturity are subject to production contracts.
  • The 250 free runs of hosted inference are calculated per workspace per UTC month, and model provider fees are billed separately.
  • Some features (such as Job-Safe Search, joint model/purchase budgets, sub-agent allocation,@inferrail/x402-budgets, and the AWS payment channel) are experimental and do not claim general external spending control or production-grade commercial capability.
  • The license is Apache-2.0.
Up/Down to navigate · Enter to open · ESC to closeBrowse all tools