AI Gateway Specification

Comprehensive specification for the primary authenticated inference route, designed to seamlessly proxy compute requests through the rNet network.

Architectural Overview

The rNet AI Gateway acts as a low-latency, transparent proxy. Applications transmit prompt and completion payloads to the gateway, which routes them to the upstream provider while synchronously computing and deducting micro-credits from the user's global wallet balance.

Direct Pass-Through

We do not mutate your payloads. What you send is exactly what the provider receives.

Supported Inference Engines

The network currently maintains stable routing to the following foundational models:

  • text-embedding-3-small (OpenAI)
  • gemini-2.5-flash-lite (Google)
  • gemini-3.1-flash-lite (Google)
  • gemini-2.5-flash (Google)
  • gemini-embedding-001 (Google)
  • gemma-4-26b-a4b-it (Google)
  • gemma-4-31b-it (Google)
  • llama-3.1-70b-versatile (Groq)
  • llama-3.1-8b-instant (Groq)
  • mixtral-8x7b-32768 (Groq)
  • gemma2-9b-it (Groq)

For real-time model availability and specific capability matrices, consult the Supported Models Registry.

POST /ai

Execute a standard, non-streaming inference pipeline. Within the Enterprise SDKs, this endpoint is abstracted via the ModelClient.chat() primitive.

ParameterTypeRequiredSpecification
access_tokenstringYesCryptographic user access token obtained via OAuth2 PKCE.
modelstringYesExact identifier of the target inference engine.
bodyobjectYesStrictly formatted JSON payload adhering to the upstream provider schema.
Schema Strictness
rNet operates as a strict proxy. It does not translate schemas between providers. If routing to OpenAI, you must supply an OpenAI-compliant schema. If routing to Gemini, you must supply a Gemini-compliant schema.

Implementation Reference

OpenAI Payload Schema

javascript
const response = await openai.chat(
  {
    model: 'text-embedding-3-small',
    input: 'Explain quantum entanglement.'
  },
  req.session.rnet.accessToken
);

Gemini Payload Schema

javascript
const response = await gemini.chat(
  {
    contents: [
      {
        role: 'user',
        parts: [{ text: 'Explain quantum entanglement.' }]
      }
    ]
  },
  req.session.rnet.accessToken
);

POST /ai/stream

Execute a streaming inference pipeline for real-time token generation. Abstracted via ModelClient.chatStream().

javascript
app.post('/api/ai/stream', async (req, res) => {
  const body = {
    contents: req.body.messages.map((msg) => ({
      role: msg.role === 'assistant' ? 'model' : 'user',
      parts: [{ text: msg.content }]
    }))
  };

  const stream = await gemini.chatStream(
    body,
    req.session.rnet.accessToken
  );

  res.setHeader('Content-Type', 'text/event-stream');
  const reader = stream.getReader();
  const decoder = new TextDecoder();

  while (true) {
    const { done, value } = await reader.read();
    if (done) break;
    res.write(decoder.decode(value, { stream: true }));
  }

  res.end();
});