Web2 API Reference

Web2 RESTful API Reference

Status: WIP — Early Draft

This document provides a comprehensive reference for the RESTful API endpoints exposed by a Cortensor Router Node. These endpoints allow developers to interact with sessions, tasks, miners, and completions, enabling integration with AI inference workloads in Web2 applications.


Authentication

All endpoints require a Bearer token passed via the Authorization header:

Authorization: Bearer <api_key>

Default Dev Token: default-dev-token


Base URL

All requests are relative to the Router's base URL:

http://<router_host>:5010

For production, it is recommended to place the Router Node behind a reverse proxy (e.g. Nginx) for:

  • TLS termination

  • Rate limiting

  • Load balancing

  • Access control

  • Hiding internal ports


Reverse Proxy (Production Setup)

For production environments, it is strongly recommended to run the Router Node behind a reverse proxy like Nginx, Caddy, or HAProxy. This enhances security, scalability, and performance. The reverse proxy should forward requests to the Router's internal address (e.g., 127.0.0.1:5010).

Benefits:

  • TLS/SSL termination

  • Request rate limiting

  • Load balancing and retries

  • Fine-grained access control

  • IP whitelisting or firewall rules

  • Prevents exposing internal ports to the public


Endpoints

GET /api/v1/info

Returns basic metadata about the Router Node.


GET /api/v1/status

Returns current router status and health.


GET /api/v1/miners

Lists all currently connected miner nodes.


GET /api/v1/sessions

Lists all active sessions.


GET /api/v1/sessions/{sessionId}

Returns metadata about a specific session.

Path Param: sessionId — numeric session ID


GET /api/v1/tasks/{sessionId}

Lists all tasks under a given session.


GET /api/v1/tasks/{sessionId}/{taskId}

Returns a specific task from a session.


POST /api/v1/completions/{sessionId}

Submit an AI inference prompt using a session ID in the URL.

Request Body:


POST /api/v1/completions

Submit a prompt with session ID included in the body.

Request Body:


Streaming Completions

Setting stream: true in the request body returns real-time streamed responses using Server-Sent Events (SSE).


Error Codes

Code
Meaning

200

Success

400

Bad Request

401

Unauthorized

404

Not Found

500

Internal Server Error


Usage Notes

  • Compatible with OpenAI-style interfaces

  • Designed for Web2 integrations via REST

  • Supports private/local inference routing

Last updated