API reference

Documentation

Send prompts to connected LLM workers on the P2PClouds compute network.

Base URL

https://distributed.p2pclouds.net/v1/api

Authentication

Pass your API key as a Bearer token on every request. Create a key from your API keys page.

Authorization: Bearer your_api_key
POST

/v1/api/query

Dispatch a prompt to a connected LLM worker.

Request body

FieldTypeRequiredDescription
promptstringYesQuery text
mode"high" | "medium" | "low"NoSelect worker by spec tier

Example

{
  "prompt": "what is ai in 1 line",
  "mode": "high"
}

Success response

{
  "model": "gemma3:4b",
  "prompt": "what is ai in 1 line",
  "response": "AI is the simulation of human intelligence by machines.",
  "tokens": {
    "prompt": 8,
    "response": 12,
    "total": 20
  }
}

Token counts are estimated from text. If the agent returns Ollama token fields (prompt_eval_count, eval_count), those are used instead.

Error responses

StatusBody
400{ "error": "prompt is required" }
400{ "error": "mode must be one of: high, medium, low" }
503{ "error": "No LLM workers available" }
503{ "error": "No LLM workers available for mode: high" }
503{ "error": "Worker is busy: ..." }
504{ "error": "Query timed out waiting for LLM worker response" }

Example request

curl -X POST "https://distributed.p2pclouds.net/v1/api/query" \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer your_api_key" \
  -d '{
    "prompt": "what is ai in 1 line",
    "mode": "high"
  }'