Skip to content

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.

1 min read

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

  1. Create an AI key under AI Keys, named after the app and environment (shop-api production).

  2. Put it in your app's secrets as REMAI_API_KEY. Never in the browser.

  3. Change the base URL and the model to remai.

  4. 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 remai is 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 answer 404 unless your organisation was granted them.

  • Handle 402 insufficient_credits by telling the user, not by retrying.

  • If you set max_retries in the client, keep it; REM AI's 429s are meant to be retried with backoff.

Move your OpenAI code to REM AI in two lines · REM Platforms Blog