GlexirDocs
Dashboard

Get started

Quickstart

This page takes you from a new account to your first request in a few minutes. You need a Glexir account at app.glexir.com and, for the TypeScript example, Node 20 or later.

Add credit

Glexir is prepaid. Open Billing in the dashboard and add credit. Requests are charged at OpenAI list price. Without enough credit, requests fail with 402 and code credit_balance_exhausted.

Create an API key

Open API keys and click Create new secret key.

  • Name is optional. A blank name becomes "Secret key".
  • Monthly limit is optional. Once the key's spend this month (UTC) reaches it, the key's requests are rejected. Leave it blank for no limit.

Copy the key when it is shown. It starts with glx_live_, and you cannot view it again after you close the dialog.

Set the key in your environment

Shell
export GLEXIR_API_KEY="glx_live_..."

The SDK reads GLEXIR_API_KEY when you don't pass apiKey. Keep the key on your server. See Authentication.

Install the SDK

Shell
npm install @glexir/sdk

@glexir/sdk has no runtime dependencies. It runs anywhere with fetch: Node 20+, Deno, Bun and edge runtimes. To use another language, skip this step and use the curl or Python example below.

Send a request

import Glexir from "@glexir/sdk";

const glexir = new Glexir({ apiKey: process.env.GLEXIR_API_KEY });

const response = await glexir.responses.create({
  model: "gpt-6-luna",
  input: "Write a one-sentence bedtime story about a unicorn.",
});

console.log(response.output_text);
console.log(response._request_id);

Save the TypeScript example as index.mjs and run node index.mjs. It prints the story and the request ID. With curl, -i prints the response headers, including x-request-id.

See the request in the dashboard

  • Logs lists each request. Paste the request ID to open it, or go to https://app.glexir.com/logs/<request id>.
  • Usage shows spend and request counts by day. Group by API key to see what each key spent.

What the example does

new Glexir() creates a client. It reads the key from apiKey, or from GLEXIR_API_KEY when apiKey is not passed, and throws a GlexirError if neither is set. Every request sends the key as Authorization: Bearer <key>.

glexir.responses.create() calls POST /v1/responses and returns a Response. response.output_text is the text of every output_text part joined together. The SDK computes it; the API doesn't send it. response._request_id is the gateway's x-request-id header. Include it when you contact support.

The client retries connection errors and 408, 409, 429 and 5xx responses twice by default. Every non-GET request carries an Idempotency-Key, so a retry is never billed twice. See Errors & retries.

Common errors

StatusCodeCauseFix
401invalid_api_keyThe key is missing, mistyped or revoked.Check GLEXIR_API_KEY, or create a new key.
402credit_balance_exhaustedYour credit balance can't cover the request.Add credit on the Billing page.
402spend_limit_exceededThe key's or the organization's monthly limit is reached.Raise the limit, or wait until the 1st (UTC).
400model_not_foundThe model ID is wrong or not available on this endpoint.Pick a model from GET /models.
400unsupported_on_glexirThe request uses a feature Glexir doesn't offer, such as a hosted tool.See What is not available.

All codes are listed in HTTP error codes.

Next steps