RelayForge AI
Unified AI Gateway
FeaturesArchitectureDocsStatus
Get Started
RelayForge AI
Unified AI Gateway
FeaturesArchitectureDocsStatus
Get Started
Developer documentation

RelayForge API and contracts

This documentation describes the real Worker API layer: chat, stream, status, logs and usage. No fictional SDK promises, only the current project contracts.

Open playgroundProvider status

API surface

Five core endpoints backing the interface.

5 routes
POST
/api/v1/chat
Normalized JSON response with provider metadata.
POST
/api/v1/stream
SSE-compatible streaming endpoint for tokens and meta events.
GET
/api/v1/providers/status
Provider health snapshot and routing order.
GET
/api/v1/logs
Recent request history with fallback metadata.
GET
/api/v1/usage
Usage aggregates, latency and provider distribution.

Unified contract

Frontend and Worker share request, response and error types through the shared package.

Streaming transport

Streaming runs through POST + text/event-stream while the UI receives token, meta, error and done events.

Fallback logic

Auto mode starts with Groq, then promotes to SambaNova, Cerebras, Gemini, OpenRouter and finally the mock provider when needed.

Error model

The UI receives readable codes and messages without leaking raw stack traces into the interface.

Endpoint reference

What the frontend actually calls

These routes form the real API surface between the Next.js interface and the Worker.

POST
/api/v1/chat
Normalized JSON response with provider metadata.
POST
/api/v1/stream
SSE-compatible streaming endpoint for tokens and meta events.
GET
/api/v1/providers/status
Provider health snapshot and routing order.
GET
/api/v1/logs
Recent request history with fallback metadata.
GET
/api/v1/usage
Usage aggregates, latency and provider distribution.

Request example

A typed payload shared by frontend and Worker.

{
  "prompt": "Explain the fallback strategy in RelayForge",
  "options": {
    "strategy": "auto",
    "stream": true,
    "maxTokens": 512,
    "temperature": 0.35
  },
  "metadata": {
    "source": "relayforge-web"
  }
}

Successful response example

Every successful response returns normalized provider metadata.

{
  "success": true,
  "data": {
    "text": "RelayForge first tries Groq...",
    "meta": {
      "strategy": "auto",
      "attemptedProvider": "groq",
      "finalProvider": "openrouter",
      "fallbackActivated": true,
      "degradedMode": true,
      "demoMode": false,
      "latencyMs": 842,
      "model": "meta-llama/llama-3.2-3b-instruct:free",
      "timestamp": "2025-01-01T12:00:00.000Z"
    }
  }
}

Streaming notes

How the streaming transport layer behaves.

Events
Supported event types are token, meta, error and done.
Metadata
The interface receives strategy, attempted provider, final provider, fallback state, mode, latency and model.
Failure behavior
If the stream cannot start cleanly, the Worker promotes the request to the next priority tier.

Normalized error shape

A readable error for the UI with technical details for diagnostics.

{
  "success": false,
  "error": {
    "code": "provider_rate_limited",
    "message": "Groq Free returned a rate-limit response.",
    "technicalDetails": "HTTP 429 from upstream provider",
    "provider": "groq",
    "fallbackActivated": true,
    "timestamp": "2025-01-01T12:00:00.000Z"
  }
}
Errors stay consistent across chat and stream so the UI does not fragment across providers.
Next step

Move from the landing page into the working workspace

The interface is already connected to the Worker, so you can send requests and inspect provider status, usage and fallback history live.

Open workspaceAPI documentation
RelayForge AI
Unified AI Gateway

A unified AI gateway with streaming, fallback orchestration and real observability on top of the Worker API.

SSE
Worker-held secrets

Product

FeaturesArchitectureDocumentationWorkspace

Runtime

Next.js App Router
Cloudflare Worker
TanStack Query
@relayforge/shared

System boundaries

Public env only for the API base URL
Logs and usage are in-memory in the current build
The mock provider preserves a working demo path
© 2026 RelayForge AI
The design is now bound to the live product layer: routing, streaming, status, logs and usage.