OpenAI Integration Guide
Get Started with
Memcode Router
Use the official openai JavaScript SDK and point its baseURL at the gateway. Requests use your Memcode Router key, and metered usage is tracked against its budget.
1
Your OpenAI-compatible Base URL
Set this value as the SDK's baseURL:
https://memcode.xmemlabs.workers.dev/v12
Call the Responses API
npm install openai
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.MEMCODE_API_KEY,
baseURL: "https://memcode.xmemlabs.workers.dev/v1",
});
const response = await client.responses.create({
model: "gpt-5-mini",
input: "Explain quantum computing in simple terms.",
max_output_tokens: 256,
});
console.log(response.output_text);3
Configured Models & Pricing
Gateway rates per 1M text tokensOnly the listed IDs are accepted
gpt-5-minigpt-5-mini-2025-08-07$0.25 input$0.025 cached$2.00 output
gpt-4.1-minigpt-4.1-mini-2025-04-14$0.40 input$0.10 cached$1.60 output
Budget-aware usage tracking
The gateway records the token categories returned by supported OpenAI responses and applies the configured rates above. Check the user portal at any time to see the key's used and remaining budget.