Move your OpenAI code to REM AI in two lines
REM AI speaks the OpenAI API. Change the base URL and the key, keep your code - and get budgets, rate limits and usage per key on top.
If your app already calls an OpenAI-compatible API, moving it to REM AI takes two changed lines. This post shows the change in Python and Node, and what you get in return.
The change
Python:
from openai import OpenAI
client = OpenAI(base_url="https://ai.remplatforms.com/v1", api_key=os.environ["REMAI_API_KEY"])
reply = client.chat.completions.create(model="remai", messages=[{"role": "user", "content": "Hello"}])Node:
const client = new OpenAI({ baseURL: "https://ai.remplatforms.com/v1", apiKey: process.env.REMAI_API_KEY });
const reply = await client.chat.completions.create({ model: "remai", messages: [{ role: "user", content: "Hello" }] });Streaming, tools (function calling) and embeddings work the same way. Your error handling keeps working too: REM AI returns errors in the OpenAI format, so RateLimitError is still a 429 and authentication errors are still a 401.
Step by step
Create an AI key under AI Keys, named after the app and environment (shop-api production).
Put it in your app's secrets as
REMAI_API_KEY. Never in the browser.Change the base URL and the model to
remai.Deploy, then open Usage grouped by Key: your app's calls appear within seconds.
What you get on top
Usage per key, model, tag and day, with a CSV export, instead of one bill for everything.
Limits that protect you: requests and tokens per minute and a budget per period from your plan, and (Pro and above) per key, so a loop in one app cannot spend the month's credits.
Fallbacks: if the model behind
remaiis busy, REM AI tries the next one before answering with an error.One credit balance with the rest of the REM platform.
Things to check
If your code names a specific model, switch it to
remai; other names answer404unless your organisation was granted them.Handle
402 insufficient_creditsby telling the user, not by retrying.If you set
max_retriesin the client, keep it; REM AI's429s are meant to be retried with backoff.