API documentation
Huru is an OpenAI-compatible REST API powered by 0G decentralized compute. Every response is TEE-verified. Billing is prepaid credits — charge your project, or pass costs to your end-users with one header.
Quickstart
Grab your API key from the dashboard and make your first call.
curl https://huruai.xyz/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "huru/chat-1",
"messages": [
{ "role": "user", "content": "Hello from Huru" }
]
}'{
"id": "chatcmpl-abc123",
"object": "chat.completion",
"choices": [{
"message": { "role": "assistant", "content": "Hello! ..." },
"finish_reason": "stop"
}],
"huru": {
"request_id": "req_8f3a2b1c4d5e6f",
"credits_used": 1,
"verified": true,
"verification_mode": "tee",
"provider": "0g"
}
}huru object with your request ID, credits consumed, and TEE verification status.Authentication
Every request requires a project API key as a Bearer token. Keys start with sk_test_ (test) or sk_live_ (live).
Models
| Model | Type | Description |
|---|---|---|
| huru/chat-1 | Chat | General-purpose chat completions |
| huru/stt-1 | Speech-to-text | Audio transcription via multipart upload |
Huru routes to the best available 0G provider automatically with up to 3 failover attempts.
Credits
API requests cost credits. Credits are reserved before the request and settled after. Failed requests refund automatically. ~1 credit per 1,000 tokens (chat) or ~1 per 500 KB audio.
Consumer billing
Let your end-users pay for their own compute. Add one header and Huru handles identity, credit accounts, metering, and payment. You spend $0.
Headers
X-Consumer-EmailstringrequiredX-Consumer-Namestringcurl https://huruai.xyz/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "X-Consumer-Email: jane@example.com" \
-H "X-Consumer-Name: Jane Doe" \
-H "Content-Type: application/json" \
-d '{
"model": "huru/chat-1",
"messages": [{ "role": "user", "content": "Hello" }]
}'When a consumer runs out of credits, you get a 402 with a checkout link:
{
"error": {
"type": "billing_error",
"code": "insufficient_credits",
"message": "Consumer does not have enough credits.",
"checkout_url": "https://paystack.com/pay/..."
}
}API reference
All endpoints live under https://huruai.xyz.
/v1/chat/completionsGenerate a chat completion. OpenAI-compatible. Supports streaming.
modelstringrequiredhuru/chat-1.messagesarrayrequired{ role, content } objects.streambooleantrue for SSE streaming. Default false.curl https://huruai.xyz/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "huru/chat-1",
"messages": [
{ "role": "system", "content": "You are helpful." },
{ "role": "user", "content": "Explain TEE in one sentence." }
]
}'/v1/audio/transcriptionsTranscribe audio to text. Accepts multipart form data.
fileFilerequiredmodelstringrequiredhuru/stt-1.curl https://huruai.xyz/v1/audio/transcriptions \ -H "Authorization: Bearer YOUR_API_KEY" \ -F file=@recording.mp3 \ -F model=huru/stt-1
/v1/consumersList all consumers under the authenticated project with balances.
{
"object": "list",
"data": [
{
"id": "con_abc123",
"email": "jane@example.com",
"name": "Jane Doe",
"credits_balance": 42,
"created_at": "2026-04-27T15:30:00Z"
}
]
}/v1/consumers/:consumerIdGet a single consumer's detail and credit balance.
/v1/consumers/:consumerId/checkoutCreate a Paystack checkout pre-filled with the consumer's email.
pack_idstringrequiredcredits_10, credits_25, credits_100.curl -X POST https://huruai.xyz/v1/consumers/con_abc123/checkout \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Content-Type: application/json" \
-d '{ "pack_id": "credits_10" }'{
"object": "checkout.session",
"provider": "paystack",
"reference": "huru_topup_a1b2c3d4e5f6",
"authorization_url": "https://paystack.com/pay/...",
"credits_awarded": 100,
"status": "pending"
}/v1/usageUsage totals and daily breakdown. Optional from and to query params (ISO 8601).
curl "https://huruai.xyz/v1/usage?from=2026-04-01&to=2026-04-27" \ -H "Authorization: Bearer YOUR_API_KEY"
/v1/requests/:idRetrieve a request record with status, usage, and errors.
/v1/requests/:id/verificationGet the TEE attestation report for a request. Includes report ID, quote hash, and verification timestamp.
{
"verified": true,
"verification_mode": "tee",
"provider": "0g",
"report_id": "att_...",
"quote_hash": "0xabc123...",
"verified_at": "2026-04-27T15:30:00Z"
}/v1/billing/checkoutStart a Paystack checkout for project-level credits. For consumer top-ups use /v1/consumers/:id/checkout.
pack_idstringrequiredsuccess_urlstringcancel_urlstring/v1/projectsCreate a project and get your API key + starter credits.
namestringrequiredslugstringenvironmentstringtest or live. Default: test.Idempotency
Pass an Idempotency-Key header to safely retry requests without double-charging.
curl https://huruai.xyz/v1/chat/completions \
-H "Authorization: Bearer YOUR_API_KEY" \
-H "Idempotency-Key: unique-key-123" \
-H "Content-Type: application/json" \
-d '{ "model": "huru/chat-1", "messages": [...] }'Completed — returns cached response with idempotent_replay: true.
Processing — returns 409. Wait and retry.
Failed — allows a new attempt.
Streaming
Set stream: true on chat completions for server-sent events. The stream opens and closes with Huru metadata events.
data: {"huru":{"request_id":"req_abc123"}}
data: {"choices":[{"delta":{"content":"Hello"}}]}
data: {"choices":[{"delta":{"content":" world"}}]}
data: {"huru":{"request_id":"req_abc123","credits_used":1,"verified":true}}
data: [DONE]Rate limits
Token-bucket rate limiter per project.
| Window | Limit | Header |
|---|---|---|
| Per minute | 60 | X-RateLimit-Limit-Minute |
| Per day | 1000 | X-RateLimit-Limit-Day |
When limited, you get 429 with X-RateLimit-* headers showing remaining quota and reset time.
Errors
All errors return a consistent shape. Consumer billing errors include checkout_url.
| Status | Code | Description |
|---|---|---|
| 400 | invalid_request | Bad body, missing field, or unsupported model. |
| 401 | authentication_error | Missing or invalid API key. |
| 402 | insufficient_credits | Not enough credits. Consumer 402s include checkout_url. |
| 409 | request_in_progress | Idempotent request already processing. |
| 429 | rate_limit_exceeded | Rate limit hit. Check X-RateLimit-* headers. |
| 503 | provider_unavailable | 0G provider temporarily down. |
{
"error": {
"type": "billing_error",
"code": "insufficient_credits",
"message": "Consumer does not have enough credits.",
"checkout_url": "https://paystack.com/pay/..."
}
}