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 (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: "anthropic.claude-3-haiku-20240307-v1:0",
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 — call the routes yourself (e.g.GET /balancewith the same bearer key +x-fleeex-user).
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.