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
The SDK reads GLEXIR_API_KEY when you don't pass apiKey. Keep the key on your server. See Authentication.
Install the 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
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
| Status | Code | Cause | Fix |
|---|---|---|---|
| 401 | invalid_api_key | The key is missing, mistyped or revoked. | Check GLEXIR_API_KEY, or create a new key. |
| 402 | credit_balance_exhausted | Your credit balance can't cover the request. | Add credit on the Billing page. |
| 402 | spend_limit_exceeded | The key's or the organization's monthly limit is reached. | Raise the limit, or wait until the 1st (UTC). |
| 400 | model_not_found | The model ID is wrong or not available on this endpoint. | Pick a model from GET /models. |
| 400 | unsupported_on_glexir | The 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
- Responses: multi-turn input, function calling and structured outputs.
- Streaming: print tokens as they arrive.
- Client configuration: timeouts, retries and custom
fetch. - Authentication: rotating keys and keeping them off the client.