Skip to content

Quickstart

Your first request in five minutes

InferMesh is an OpenAI- and Anthropic-compatible gateway paid in credits. If your code already talks to either API, you change the base URL and the key — nothing else.

1. Get credits and a key

  1. Connect a Solana wallet (Phantom, Solflare, Backpack or any Wallet Standard wallet) and sign the one-time sign-in message. Your wallet is your account.
  2. Buy credits on Compute with USDC. Your first purchase creates an API key instantly. Stakers can instead claim earned credits on Mesh.
  3. Create more keys — with scopes, spend caps and rate limits — on Developers. Each key is shown once; only a salted hash is stored.

2. Point your client at InferMesh

OpenAI-compatible base URL

https://infermesh.dev/v1

Anthropic SDK base URL (the SDK adds /v1)

https://infermesh.dev

Authenticate with Authorization: Bearer sk-infer-YOUR_KEY. The x-api-key header used by Anthropic SDKs works too.

Environment
export OPENAI_BASE_URL="https://infermesh.dev/v1"
export OPENAI_API_KEY="sk-infer-YOUR_KEY"
export ANTHROPIC_BASE_URL="https://infermesh.dev"
export ANTHROPIC_API_KEY="sk-infer-YOUR_KEY"

3. Make a request

curl https://infermesh.dev/v1/chat/completions \
  -H "Authorization: Bearer sk-infer-YOUR_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "anthropic/claude-sonnet-5.5",
    "messages": [{ "role": "user", "content": "Explain proof of history in one sentence." }]
  }'

Model ids are lab/model (for example anthropic/claude-sonnet-5.5); each lab's native id is accepted as an alias. See Models & pricing.

Streaming

Set stream: true to receive server-sent events exactly as the OpenAI or Anthropic API sends them. To receive token usage in the final chunk of an OpenAI-style stream, set stream_options: { include_usage: true }. If your balance runs out mid-stream, the stream ends with an insufficient_credits error event; you are charged for the tokens delivered and never more than your balance.

Response headers

HeaderMeaning
x-request-idUnique id for the request — include it when asking about a charge.
x-infermesh-providerWhich upstream provider served the request (after any failover).
x-infermesh-cost-microsExact cost charged, in micro-credits (non-streaming responses).

Check your balance from code

curl https://infermesh.dev/v1/account/credits \
  -H "Authorization: Bearer sk-infer-YOUR_KEY"

1 credit = $1 of compute

Requests are metered at each lab's list price (or the upstream's reported cost, when higher) plus your tier's gateway fee, rounded up to the micro-credit. Staking the protocol token lowers the fee.