NeuroGrid API Documentation

Complete REST API reference for decentralized AI computing

RESTful API
Real-time WebSocket
Secure Authentication

🚀 Getting Started

Base URL

https://neurogrid.network/api

Quick Example

# Submit an AI task
curl -X POST https://neurogrid.network/api/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Explain quantum computing in simple terms",
    "model": "llama2:7b",
    "priority": "standard"
  }'

# Response
{
  "success": true,
  "task_id": "task_1698234567_abc123",
  "status": "queued",
  "estimated_time": "3s",
  "cost": {
    "estimated": "$0.001",
    "comparison": {
      "openai": "$0.060",
      "savings": "98.3%"
    }
  }
}

Fast Setup

Get started in under 5 minutes

Cost Effective

98.3% cheaper than OpenAI

Decentralized

Global GPU network

🔐 Authentication

Beta Phase

Currently in open beta - no authentication required for testing. Production API will require API keys.

Future Authentication (Coming Soon)

# API Key Authentication (MainNet)
curl -X POST https://neurogrid.network/api/tasks \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"prompt": "Hello world", "model": "llama2"}'

Rate Limits

User Type Rate Limit Burst
Beta User 100 requests/hour 10 concurrent
Premium 1000 requests/hour 50 concurrent

🤖 Tasks API

POST /api/tasks

Submit a new AI task for processing by the decentralized network.

Request Body

{
  "prompt": "string",           // Required: Task prompt/input
  "model": "string",            // Optional: llama2:7b (default), stable-diffusion, whisper
  "priority": "string"          // Optional: standard (default), high, critical
}

Example Request

curl -X POST https://neurogrid.network/api/tasks \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "Write a Python function to calculate Fibonacci numbers",
    "model": "llama2:7b",
    "priority": "standard"
  }'

Response

{
  "success": true,
  "task_id": "task_1698234567_abc123",
  "status": "queued",
  "estimated_time": "3s",
  "node": {
    "id": "node_de",
    "location": "Germany",
    "gpu": "RTX 4090"
  },
  "cost": {
    "estimated": "$0.001",
    "comparison": {
      "openai": "$0.060",
      "savings": "98.3%"
    }
  },
  "message": "Task queued for processing"
}
GET /api/tasks/{task_id}

Retrieve the status and result of a submitted task.

Example Request

curl https://neurogrid.network/api/tasks/task_1698234567_abc123

Response (Completed)

{
  "success": true,
  "task": {
    "id": "task_1698234567_abc123",
    "status": "completed",
    "result": "Here's a Python function to calculate Fibonacci numbers:\n\ndef fibonacci(n):\n    if n <= 1:\n        return n\n    return fibonacci(n-1) + fibonacci(n-2)",
    "created_at": "2024-10-25T15:30:00Z",
    "completed_at": "2024-10-25T15:30:03Z",
    "processing_time": 2.3,
    "cost": 0.001,
    "tokens_used": 156,
    "node": {
      "id": "node_de",
      "location": "Germany"
    }
  }
}

Supported AI Models

LLaMA 2 (7B)

Large Language Model for text generation

Cost: 0.1 NEURO/task
Speed: ~2-5 seconds

Stable Diffusion

Image generation from text prompts

Cost: 0.2 NEURO/task
Speed: ~5-10 seconds

Whisper

Speech-to-text transcription

Cost: 0.05 NEURO/task
Speed: ~1-3 seconds

🎯 Beta Program API

POST /api/beta/signup

Join the NeuroGrid beta program to get early access and bonuses.

Request Body

{
  "email": "string",            // Required: Valid email address
  "type": "string",             // Optional: developer, node-operator, researcher, startup
  "source": "string"           // Optional: website, product-hunt, reddit, etc.
}

Example Request

curl -X POST https://neurogrid.network/api/beta/signup \
  -H "Content-Type: application/json" \
  -d '{
    "email": "developer@example.com",
    "type": "developer",
    "source": "website"
  }'

Response

{
  "success": true,
  "message": "Successfully joined NeuroGrid Beta!",
  "signup_id": "beta_1698234567_abc123",
  "bonuses": {
    "free_tasks": 1000,
    "lifetime_discount": 15,
    "priority_support": true,
    "early_access": true
  },
  "next_steps": [
    "You will receive beta access email within 24 hours",
    "Follow us on social media for updates",
    "Join our Discord community for early discussions"
  ]
}

🌐 Network Status API

GET /api/network/status

Get real-time status of the NeuroGrid decentralized network.

Example Request

curl https://neurogrid.network/api/network/status

Response

{
  "success": true,
  "timestamp": "2024-10-25T15:30:00Z",
  "network": {
    "nodes_online": 3,
    "total_tasks": 15847,
    "completed_tasks": 15832,
    "queued_tasks": 15,
    "success_rate": 99,
    "avg_response_time": "2.3s",
    "cost_savings_vs_openai": "98.3%",
    "uptime": "99.9%"
  },
  "nodes": [
    {
      "id": "node_de",
      "location": "Germany",
      "status": "online",
      "gpu": "RTX 4090",
      "tasks_processed": 5234
    },
    {
      "id": "node_us",
      "location": "USA",
      "status": "online",
      "gpu": "RTX 3090",
      "tasks_processed": 4891
    }
  ],
  "stats": {
    "beta_signups": 127,
    "total_compute_time": "39618s",
    "total_savings": "$934.67"
  }
}

💚 System Health API

GET /health

Health check endpoint for monitoring system status.

Response

{
  "status": "OK",
  "service": "NeuroGrid",
  "version": "1.0.0",
  "environment": "production",
  "timestamp": "2024-10-25T15:30:00Z",
  "uptime": 86400,
  "uptime_human": "24h 0m",
  "memory": {
    "used": "42MB",
    "total": "128MB"
  },
  "network": {
    "nodes_online": 3,
    "total_tasks": 15847,
    "beta_signups": 127
  }
}

⚠️ Error Handling

HTTP Status Codes

Code Meaning Description
200 OK Request successful
400 Bad Request Invalid request parameters
404 Not Found Resource does not exist
429 Too Many Requests Rate limit exceeded
500 Internal Server Error Server error occurred

Error Response Format

{
  "success": false,
  "error": "Invalid request parameters",
  "details": "The 'prompt' field is required",
  "timestamp": "2024-10-25T15:30:00Z"
}

📚 SDKs & Libraries

Python SDK

pip install neurogrid-python
from neurogrid import NeuroGrid

client = NeuroGrid()
result = client.submit_task(
    prompt="Hello world",
    model="llama2"
)
print(result.get_response())

JavaScript SDK

npm install neurogrid-js
import { NeuroGrid } from 'neurogrid-js';

const client = new NeuroGrid();
const result = await client.submitTask({
  prompt: 'Hello world',
  model: 'llama2'
});
console.log(await result.getResponse());

Coming Soon

Additional SDKs for Go, Rust, Java, and more languages are in development.