Get started

Quickstart

Add Connect with rNet to your app and make an AI request paid from the user's credits. You need an rNet account and a server-side app (Node.js, Python or Java).

1

Get a developer account

Create an rNet account, then open the account menu and choose Upgrade to Developer. See Become a developer.

2

Register your app

In the Developer Console, click New app, enter a name and your redirect URI (for local work, http://localhost:3000/callback), then click Register application. Copy the Client ID and Client secret: the secret is shown only once.

bash
RNET_CLIENT_ID=rnet-xxxxxxxx
RNET_CLIENT_SECRET=your-client-secret
3

Install the SDK

javascript
npm install @rnet-ai/rnet-oauth-node
4

Create the clients

javascript
import { RNetOAuthClient, ModelClient } from '@rnet-ai/rnet-oauth-node';

const auth = new RNetOAuthClient({
  clientId: process.env.RNET_CLIENT_ID,
  clientSecret: process.env.RNET_CLIENT_SECRET,
  redirectUri: 'https://yourapp.com/callback',
});

const ai = new ModelClient('gemini-2.5-flash-lite');
5

Send the user to Connect with rNet

When the user clicks your Connect with rNet button, start the OAuth flow:

javascript
// Create a PKCE pair and keep the verifier in the user's server-side session
const { verifier, challenge } = auth.generatePKCE();
const state = crypto.randomUUID();
req.session.rnet = { verifier, state };

// Send the user to rNet to sign in and approve your app
res.redirect(auth.getAuthorizationUrl(challenge, state));
6

Handle the callback

rNet redirects back to your redirect URI with a code. Exchange it for tokens on your server:

javascript
// GET /callback?code=...&state=...
const { verifier, state } = req.session.rnet;
if (req.query.state !== state) return res.status(400).send('Invalid state');

const tokens = await auth.exchangeCodeForToken(req.query.code, verifier);
req.session.rnet = {
  accessToken: tokens.access_token,
  refreshToken: tokens.refresh_token,
};
7

Call an AI model

Use the user's access token. The request is paid from their rNet credits.

javascript
const response = await ai.chat({
  contents: [{ role: 'user', parts: [{ text: 'Write a haiku about credits.' }] }],
}, accessToken);

console.log(response);
That's it
You never handle payments or keep a credit ledger: rNet charges the user and records usage per app. Track it in the Developer Console under Usage.

Next steps