Fleeexdocs

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. baseURL must include /v1, and you set x-fleeex-user yourself on every request.
  • 402 is harder to use. It arrives as OpenAI.APIError (status === 402). The top-up link is in the response body, but the OpenAI SDK surfaces only the body's error field, so topupUrl isn't readily accessible. @fleeex/sdk lifts it into PaymentRequiredError.topupUrl for you.
  • No billing helpers. getBalance(), getConnection(), and getUsageSummary() aren't part of the OpenAI SDK — call the routes yourself (e.g. GET /balance with the same bearer key + x-fleeex-user).

base_url at a glance

Clientbase_urlx-fleeex-user
@fleeex/sdk (baseURL option)root, no /v1 (default https://api.fleeex.dev)set for you from userId
Raw OpenAI SDKwith /v1 (https://api.fleeex.dev/v1)you set it yourself

Everything else — request bodies, streaming, response shapes — is identical.