Skip to content

About

Runnable Inferit examples: LangChain, Vercel AI SDK, LiteLLM, CrewAI, OpenCode. API key or x402. Testnet demo.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

Inferit

inferit-examples

Runnable examples for Inferit, a peer-to-peer market for AI inference: LangChain, the Vercel AI SDK, LiteLLM, CrewAI and OpenCode, against one OpenAI-compatible API.

Pay with an API key, or per request with x402 and no account.

Website Docs API key X CI License Status

Status: Testnet demo on Whitechain Sepolia. Prices settle in Inferit Test Credit (ITC), a test token with no monetary value. The contracts are not audited.


The examples

Folder Framework Runs on Pays with Last live run
langchain-python/ LangChain (langchain-openai) Python 3.10+ API key 2026-10-13
langchain-js/ LangChain (@langchain/openai) Node.js 20+ API key; x402 2026-10-13
vercel-ai-sdk/ Vercel AI SDK (ai, @ai-sdk/openai-compatible) Node.js 20+ API key; x402 2026-10-13
litellm/ LiteLLM, the SDK and the proxy Python 3.10+ API key 2026-10-13
crewai/ CrewAI Python 3.10 to 3.13 API key 2026-10-13
opencode/ OpenCode (opencode.json) Node.js 20+ (npx) API key 2026-10-13
pick-model.sh Picks the model a smoke test sends bash, curl, python3 – 2026-10-13

OpenCode's own agents need more context than the live sellers served on 2026-10-13, so its smoke test uses a minimal agent: see opencode/.

Each folder runs on its own. It has its own package.json or requirements.txt, a README with its last live result, and a smoke.sh that installs the packages inside that folder and sends one small request. Copy a folder out of this repository and it still runs.

An agent that pays with x402 and nothing else, in TypeScript: InferitAI/inferit-agent-example.

Two ways to pay

API key x402
Setup A wallet, test ITC, a deposit with a ceiling, then a key An EVM private key. No account, no API key
Each request carries Authorization: Bearer ik_... A signed payment for the API's 402 quote (PAYMENT-SIGNATURE, x402 v2)
What it costs The request's metered cost, from your prepaid balance The quote (at least 10 000 µ, 0.01 ITC) goes into the agent's own escrow balance; the request is charged its metered cost and the rest stays the agent's
Here Every example langchain-js/chat-x402.mjs, vercel-ai-sdk/chat-x402.mjs

Prices are per token, charged per request, in µ (micro-dollars, a millionth of a dollar each; on the testnet, a millionth of an ITC).

Get an API key

  1. Open the Buy workspace, https://inferit.app/buy, and connect a browser wallet such as MetaMask or Rabby.
  2. Top up. The workspace gives you free test ITC and walks you through the deposit and your ceiling: the most that can ever be settled from you, with an expiry. The deposit is a transaction, so it needs a little test WBT for gas, from the Whitechain faucet: https://faucet.testnet.whitechain.io
  3. Create a key. Keys start with ik_, can carry a spend limit, and are shown once.

The same path by hand, with the API or contract call behind each step: https://inferit.cc/docs/quickstart

Run one

export INFERIT_API_KEY='ik_...'
bash langchain-python/smoke.sh              # Python 3.10+: PYTHON=python3.12 picks the interpreter
bash vercel-ai-sdk/smoke.sh
SMOKE_X402=1 bash vercel-ai-sdk/smoke.sh     # also pays one request with x402

The API underneath is plain OpenAI-compatible chat completions, streaming included:

curl https://api-production-c74b9.up.railway.app/v1/chat/completions \
  -H "Authorization: Bearer $INFERIT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"model": "qwen/qwen-2.5-14b-instruct", "max_tokens": 16,
       "messages": [{"role": "user", "content": "Say hello in five words."}]}'

Model auto, or a named model

Name a model and Inferit sends the request to the cheapest healthy seller of that model. GET /v1/models lists the catalog; models with a live seller have a best_price.

Send "model": "auto" and Inferit also picks the model: the best value on a published quality ranking (the Artificial Analysis Intelligence Index, read 2026-10-06) for that request's price, among models with a healthy seller that fit the request. It does not read the prompt. The response names the model that served it (model, and the x-inferit-model header). Ranking and method: https://inferit.cc/docs/routing

Auto needs a ranked model with a live seller. GET /v1/routing lists those in candidates_now; while that list is empty, a request with auto answers 503 no_eligible_model, and naming a model still works.

The code in every folder defaults to auto. The smoke scripts choose with pick-model.sh: auto when candidates_now is not empty, else a catalog model with a live seller. Set INFERIT_MODEL to override both.

Environment

Variable Default Used by
INFERIT_API_KEY required Every API-key example
INFERIT_BASE_URL https://api-production-c74b9.up.railway.app/v1, the hosted testnet API All but opencode/ and the LiteLLM proxy, whose base URL is in their config
INFERIT_MODEL auto in the code; pick-model.sh in smoke.sh All
AGENT_KEY A fresh key per run The x402 variants: the payer's private key, 0x + 64 hex
PYTHON python3 The Python smoke scripts

Keys stay in your environment: nothing here reads a .env file, and .gitignore keeps one out of git.

CI

ci.yml installs each example's packages, typechecks the JavaScript (tsc --checkJs), compiles the Python and checks its imports, and lints with ruff and ShellCheck. It holds no secrets and sends no request to the API. The live runs are the smoke.sh scripts, run by hand: each folder's README records its last result.

More from Inferit

License

Apache-2.0.

About

Runnable Inferit examples: LangChain, Vercel AI SDK, LiteLLM, CrewAI, OpenCode. API key or x402. Testnet demo.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages