How does BitLLM work from inside an agent?

Answer

BitLLM is one binary that turns your machine into a client of a peer-to-peer inference network. A local gateway on 127.0.0.1:7778 speaks both the OpenAI and Anthropic wire shapes. A libp2p node finds peers sharing vLLM, llama.cpp, MLX or Ollama models. Countersigned receipts attribute every answer to the peer that served it.

  1. Any OpenAI-compatible tool works with no code change: point it at the local port and use any string as the API key.1
  2. Peers announce their models every ten seconds, the gateway picks a host, and the answer names it in X-Bitllm-Peer.1
  3. By default the serving peer reads your prompt and sees your IP; a tee/ model seals the text to an attested enclave, while tool names and arguments stay visible.1
  4. Nothing is filtered or logged in the middle: the middle is relays, hole punching and receipts.

Applies toBitLLM 0.8.4 on one laptopinvite-only beta, uninvited nodes served on spare capacity

1

What runs on the machine?

One binary, two APIs, no middle server
Diagram structure
  • Agent tools and SDKs tools
  • Local gateway :7778 gateway
  • P2P node :4001 node
  • Seed nodes seeds
  • Relays and hole punching relays
  • Receipt ledger ledger
  • tools → gateway · POST /v1/chat/completions
  • gateway → node · place request
  • node → seeds · bootstrap, sync receipts
  • node → relays · dial peers
  • relays → node · relay circuits
  • node → ledger · countersign

The same binary is both halves. The gateway binds loopback only, so requests written on the machine are never filtered. The node binds every interface, joins the DHT through the seeds, and announces the models this machine serves every ten seconds.

2

What happens to one prompt?

The life of one prompt
Diagram structure
  • Agent tool tool
  • Local gateway gw
  • Serving peer peer
  • Inference server inf
  • Receipt ledger led
  • tool → gw · POST /v1/chat/completions
  • gw → peer · dial and forward fields
  • peer → inf · local model call
  • inf → peer · answer
  • peer → led · countersign receipt
  • peer → gw · answer + X-Bitllm-Peer
  • gw → tool · 200 with usage
  1. Agent tool

    Posts the model name, messages and tool schemas to the local gateway.

  2. Local gateway

    Picks a host from the announcements and dials it, directly or through a relay.

  3. Inference server

    Runs the model and returns the answer to the peer.

  4. Receipt ledger

    The host countersigns: peer id, address, token counts, never the text.

  5. Agent tool

    The answer streams back with X-Bitllm-Peer naming the peer that served it.

3

Who can read the prompt?

QuestionDefault modeltee/ model
Prompt and answer textplain textThe serving peer reads itend to endSealed to an attested enclave
Your IP addressVisible to the peerVisible unless you use a VPN
Tool names and argumentsVisibleeven sealedVisible
Failed attestationNot checked502, nothing sent

The host forwards only the fields it knows: the standard OpenAI and Anthropic fields, data: images, and one prompt per /completions call. Unknown fields are dropped, not rejected.

4

How does a new node join?

Joining the network
Diagram structure
  • Gateway up on loopback gw
  • Resolve _dnsaddr TXT txt
  • Seeds found? ok
  • Pin with --bootstrap pin
  • conns fill, receipts sync conns
  • /v1/models lists models models
  • conns → models · announcements
  • gw → txt
  • ok → conns · yes
  • ok → pin · resolver said no
  • pin → conns
  • txt → ok

The seed list is a DNS TXT record at _dnsaddr.bootstrap.bitllm.org. When a resolver answers NXDOMAIN for it, the gateway still comes up but the network stays empty; pinning the seed addresses with --bootstrap fixes it, as measured on this machine.

5

What breaks, and how does it say so?

SymptomWhat it meansWhat to do
Empty /v1/modelsResolver failed the TXT record, or no peers yetPin seeds with --bootstrap, then wait
502 naming multiaddrsThe one serving peer could not be dialedRetry, or pick another model
NO_RESERVATIONStale relay reservationRetry the request
429 after 60 sServer busy; normal for uninvited nodesBack off and retry

Most models show nodes: 1, so there is no fallback host. An unreachable peer empties its models from the menu until it returns.

6

How do you check it on your machine?

Opening diagram…

↑ Archify 3.3.4 availableNotes