Drop back to raw OpenAI
The wire is iso-OpenAI, so you can skip the SDK and point the official OpenAI client at Fleeex.
@fleeex/sdk is never a lock-in. The wire is iso-OpenAI, so you can skip the package
entirely and point the official OpenAI SDK at the Fleeex base URL. Every request is
byte-identical to what @fleeex/sdk sends, and there's a non-regression test asserting
exactly that.
import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.FLEEEX_API_KEY!,
baseURL: "https://api.fleeex.dev/v1", // note the trailing /v1
defaultHeaders: { "x-fleeex-user": "user-123" },
});
const completion = await client.chat.completions.create({
model: "nova-lite",
messages: [{ role: "user", content: "Hello!" }],
});What you give up
Compared to @fleeex/sdk, going raw means:
-
You manage the connection.
baseURLmust include/v1, and you setx-fleeex-useryourself on every request. -
402is harder to use. It arrives asOpenAI.APIError(status === 402). The top-up link is in the response body, but the OpenAI SDK surfaces only the body'serrorfield, sotopupUrlisn't readily accessible.@fleeex/sdklifts it intoPaymentRequiredError.topupUrlfor you. -
No billing helpers.
getBalance(),getConnection(), andgetUsageSummary()aren't part of the OpenAI SDK, so call the routes yourself, with the same bearer key andx-fleeex-user. They sit at the root, not under/v1:Helper Route getBalance()GET /balancegetConnection()POST /connect, whereredirectUritravels in the body so it stays out of access logsgetUsageSummary()GET /usage/summary
You give up nothing on the model surface: models.list() and models.retrieve() are
plain OpenAI calls that already go through this client. See
Choosing a model.
base_url at a glance
| Client | base_url | x-fleeex-user |
|---|---|---|
@fleeex/sdk (baseURL option) | root, no /v1 (default https://api.fleeex.dev) | set for you from userId |
| Raw OpenAI SDK | with /v1 (https://api.fleeex.dev/v1) | you set it yourself |
Everything else (request bodies, streaming, response shapes) is identical.