Skip to main content

Node HTTP API Reference

Testnet

All example responses below show testnet values. Actual values will vary based on your node's activity and network state.

Every Trinity node exposes an HTTP API on port 8080 (configurable). The API is OpenAI-compatible for chat completions and provides additional endpoints for node management, storage, and DePIN operations.

Base URL​

http://localhost:8080

Endpoints Overview​

MethodEndpointDescription
GET/Server info and metrics
GET/healthHealth check
POST/v1/chat/completionsChat completion (OpenAI-compatible)
GET/v1/node/statsNode statistics and earnings
GET/v1/node/tierCurrent wallet tier info
POST/v1/node/claimClaim pending $TRI rewards
POST/v1/storage/putStore a data shard
GET/v1/storage/get/:hashRetrieve a data shard
GET/v1/storage/statusStorage layer status
GET/metricsPrometheus metrics (port 9090)
OPTIONS/v1/chat/completionsCORS preflight

GET /​

Returns server identification and runtime metrics.

Request:

curl http://localhost:8080/

Response:

{
"name": "TRINITY LLM",
"version": "1.4.0",
"endpoints": ["/v1/chat/completions", "/health", "/metrics"],
"metrics": {
"total_requests": 1523,
"active_requests": 2,
"total_tokens": 48210,
"throughput_tok_s": 14.72
}
}
FieldTypeDescription
namestringServer name
versionstringServer version
endpointsstring[]Available endpoints
metrics.total_requestsnumberTotal requests served since startup
metrics.active_requestsnumberCurrently processing requests
metrics.total_tokensnumberTotal tokens generated
metrics.throughput_tok_snumberCurrent throughput in tokens/second

GET /health​

Lightweight health check. Use this for load balancers and monitoring.

Request:

curl http://localhost:8080/health

Response:

{
"status": "ok",
"model": "loaded"
}
FieldTypeDescription
statusstring"ok" when healthy
modelstring"loaded" when model is ready for inference

Status Codes:

CodeMeaning
200Node is healthy
503Node is starting up or unhealthy

POST /v1/chat/completions​

OpenAI-compatible chat completion endpoint. Supports both standard and streaming responses.

Standard Request​

Request:

curl -X POST http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "trinity-llm",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "What is ternary computing?"}
],
"temperature": 0.7,
"max_tokens": 100
}'

Response:

{
"id": "chatcmpl-trinity",
"object": "chat.completion",
"created": 1700000000,
"model": "trinity-llm",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Ternary computing uses three-valued logic {-1, 0, +1} instead of binary {0, 1}..."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 24,
"completion_tokens": 50,
"total_tokens": 74
}
}

Streaming Request​

Set "stream": true to receive Server-Sent Events (SSE).

Request:

curl -X POST http://localhost:8080/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "trinity-llm",
"messages": [
{"role": "user", "content": "Explain VSA in one sentence."}
],
"stream": true
}'

Response (SSE):

data: {"choices":[{"delta":{"content":"Vector"},"index":0}]}

data: {"choices":[{"delta":{"content":" Symbolic"},"index":0}]}

data: {"choices":[{"delta":{"content":" Architecture"},"index":0}]}

data: [DONE]

Request Parameters​

ParameterTypeRequiredDefaultDescription
modelstringNo"trinity-llm"Model identifier
messagesarrayYes--Chat messages array
messages[].rolestringYes--"system", "user", or "assistant"
messages[].contentstringYes--Message content
temperaturenumberNo0.7Sampling temperature (0.0 = greedy)
top_pnumberNo0.9Nucleus sampling threshold
top_knumberNo40Top-k sampling
max_tokensnumberNo100Maximum tokens to generate
streambooleanNofalseEnable SSE streaming
repeat_penaltynumberNo1.1Repetition penalty

GET /v1/node/stats​

Returns current node statistics including earnings and operational metrics.

Request:

curl http://localhost:8080/v1/node/stats

Response:

{
"status": "earning",
"operations": 4521,
"earned_tri": 12.847,
"pending_tri": 0.093,
"uptime_hours": 168.3,
"wallet": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef12"
}
FieldTypeDescription
statusstringNode status: "offline", "syncing", "online", "earning"
operationsnumberTotal operations completed
earned_trinumberTotal $TRI earned (claimed + pending)
pending_trinumberUnclaimed $TRI rewards
uptime_hoursnumberTotal uptime in hours
walletstringNode wallet address (hex)

GET /v1/node/tier​

Returns the current tier information for the requesting wallet, based on staked $TRI amount.

Request:

curl -H "X-Wallet: 0x1a2b3c4d5e6f7890abcdef1234567890abcdef12" \
http://localhost:8080/v1/node/tier

Response:

{
"wallet": "0x1a2b3c4d5e6f7890abcdef1234567890abcdef12",
"tier": "staker",
"rate_limit": 60,
"reward_multiplier": 1.5,
"requests_remaining": 45,
"unlimited": false
}
FieldTypeDescription
walletstringWallet address (or "anonymous")
tierstring"free", "staker", "power", or "whale"
rate_limitnumberMax requests per minute for this tier
reward_multipliernumberEarnings multiplier for this tier
requests_remainingnumberRequests left in current rate window
unlimitedbooleantrue if tier has no rate limit (whale)

POST /v1/node/claim​

Claims all pending $TRI rewards and moves them to the wallet balance.

Request:

curl -X POST http://localhost:8080/v1/node/claim

Response:

{
"claimed": 0.093,
"new_balance": 12.940,
"nonce": 47,
"tx_hash": "0xabc123..."
}
FieldTypeDescription
claimednumberAmount of $TRI claimed
new_balancenumberUpdated wallet balance
noncenumberTransaction nonce
tx_hashstringOn-chain transaction hash

POST /v1/storage/put​

Store a data shard on the network. The shard is Reed-Solomon encoded and replicated.

Request:

curl -X POST http://localhost:8080/v1/storage/put \
-H "Content-Type: application/octet-stream" \
--data-binary @myfile.bin

Response:

{
"hash": "0xdeadbeef...",
"size_bytes": 4096,
"shards": 3,
"replicas": 3,
"ttl_hours": 720
}
FieldTypeDescription
hashstringContent hash (used for retrieval)
size_bytesnumberOriginal data size
shardsnumberNumber of erasure-coded shards
replicasnumberReplication factor
ttl_hoursnumberTime-to-live before expiry

GET /v1/storage/get/:hash​

Retrieve a stored data shard by its content hash.

Request:

curl http://localhost:8080/v1/storage/get/0xdeadbeef...

Response:

Binary data with Content-Type: application/octet-stream.

Status Codes:

CodeMeaning
200Shard found and returned
404Shard not found on this node
410Shard expired (TTL exceeded)

GET /v1/storage/status​

Returns storage layer statistics.

Request:

curl http://localhost:8080/v1/storage/status

Response:

{
"total_shards": 1247,
"total_size_mb": 512.3,
"lru_cache_size": 256,
"lru_hit_rate": 0.847,
"reed_solomon_overhead": 1.5
}
FieldTypeDescription
total_shardsnumberNumber of shards stored locally
total_size_mbnumberTotal storage used in MB
lru_cache_sizenumberLRU cache entries
lru_hit_ratenumberCache hit rate (0.0 -- 1.0)
reed_solomon_overheadnumberStorage overhead multiplier

GET /metrics (Port 9090)​

Prometheus-compatible metrics endpoint served on port 9090.

Request:

curl http://localhost:9090/metrics

Response (Prometheus format):

# HELP trinity_operations_total Total DePIN operations completed
# TYPE trinity_operations_total counter
trinity_operations_total{type="evolution"} 1200
trinity_operations_total{type="navigation"} 3400
trinity_operations_total{type="storage_hosting"} 800
trinity_operations_total{type="benchmark"} 120

# HELP trinity_earned_tri_total Total $TRI earned
# TYPE trinity_earned_tri_total counter
trinity_earned_tri_total 12.847

# HELP trinity_uptime_seconds Node uptime in seconds
# TYPE trinity_uptime_seconds gauge
trinity_uptime_seconds 605880

# HELP trinity_peers_connected Number of connected peers
# TYPE trinity_peers_connected gauge
trinity_peers_connected 7

# HELP trinity_inference_throughput_tokens_per_second Current inference throughput
# TYPE trinity_inference_throughput_tokens_per_second gauge
trinity_inference_throughput_tokens_per_second 14.72

OPTIONS /v1/chat/completions​

CORS preflight handler. Returns appropriate headers for cross-origin requests.

Response Headers:

Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST, GET, OPTIONS
Access-Control-Allow-Headers: Content-Type, Authorization

Error Codes​

All errors return JSON with an error field.

HTTP CodeErrorDescription
400Bad RequestMalformed JSON or missing required fields
404Not FoundEndpoint does not exist
405Method Not AllowedWrong HTTP method for endpoint
413Payload Too LargeRequest body exceeds 16 KB limit
429Too Many RequestsRate limit exceeded
500Internal Server ErrorUnexpected server error
503Service UnavailableModel not loaded or node is syncing

Error response format:

{
"error": "Not Found"
}

Stake-Based Access Control​

Trinity uses stake-based identity -- your wallet address is your API key, and your staked $TRI amount determines your tier.

How It Works​

  1. Include your wallet address in the X-Wallet HTTP header
  2. The node looks up your staked $TRI amount via the TokenStakingEngine
  3. Your tier is determined by how much $TRI you have staked
  4. Rate limits and endpoint access are enforced per tier

Tiers​

TierStaked $TRIRate LimitReward MultiplierAccess
Free0 (no stake)10 req/min1.0x/health, /node/status, /metrics, /rewards/rates, /node/tier
Staker100+ TRI60 req/min1.5xAll endpoints
Power1,000+ TRI300 req/min2.0xAll endpoints + priority jobs
Whale10,000+ TRIUnlimited3.0xAll endpoints + dedicated worker pool

Example Request with Wallet​

curl -H "X-Wallet: 0x1a2b3c4d5e6f7890abcdef1234567890abcdef12" \
http://localhost:8080/v1/node/stats

Without the X-Wallet header, requests are treated as Free tier.

Rate Limit Response (HTTP 429)​

When a rate limit is exceeded:

{
"error": "rate_limit_exceeded",
"tier": "free",
"limit": 10,
"window_seconds": 60
}

Tier-Gated Response (HTTP 403)​

When a Free tier wallet accesses a restricted endpoint:

{
"error": "tier_required",
"message": "This endpoint requires staking. Stake 100+ TRI to access.",
"min_stake": "100 TRI"
}

Next Steps​