Skip to main content

Overview

AtlasFlux provides an official @atlasflux/sdk package for server-side JavaScript and TypeScript applications. The package requires Node.js 18 or later and provides typed clients for the Responses API, Chat Completions, models, streaming, retries, and structured API errors. The SDK uses the same API key and base URL as the AtlasFlux API. It does not provide clients for dashboard, billing, or webhook endpoints.
Keep your API key on the server. Never expose it in browser JavaScript, mobile apps, or other client-side code.

View @atlasflux/sdk on npm

Install the latest published version and view package release information.

Install

Quick start

Set your API key in the environment before starting your application:
Create a client and call the Responses API:
The SDK automatically sends Authorization: Bearer <api-key> and uses https://api.atlasflux.my by default.

Client configuration

Responses API

Use client.responses.create() for the native AtlasFlux response format:
The model is optional. When omitted, AtlasFlux uses its default public model. The input can be a string, an array of strings, or an array of typed input messages.

Responses parameters

See request and response formats and the API Reference for field limits and response schemas.

Chat Completions

Use client.chat.completions.create() for the OpenAI-compatible format:

Chat Completions parameters

Streaming

The SDK exposes async generators for both API formats. Streaming calls return events with an event name and data payload.

Responses streaming

Responses streams use AtlasFlux event names such as response.created, response.output_text.delta, response.usage, response.completed, and response.failed. See Responses streaming for the event format.

Chat Completions streaming

Chat streams use the OpenAI-compatible chunk format. A stream error may arrive after the HTTP response has started, so inspect event payloads and handle structured errors before finishing. See Chat Completions streaming.
Streaming methods are not automatically retried. Reconnect only when your application can safely resume or repeat the request.

Models

List available models or retrieve one by identifier:
The SDK currently covers these developer API endpoints: The SDK does not cover dashboard, billing checkout, or Stripe webhook routes. Use the API Reference for those endpoints.

Request options and retries

Pass request-specific options as the second argument to create() or stream():
For non-streaming requests, the SDK retries retryable API errors and network failures. GET requests can be retried automatically. POST requests are retried only when an idempotencyKey is supplied, unless allowUnsafeRetries is enabled. The SDK honors retry_after_seconds and the Retry-After header before falling back to exponential backoff. See error handling for the API retry policy and rate limits for idempotency guidance.

Errors

The SDK exports AtlasFluxError for API responses and AtlasFluxNetworkError for connection or transport failures:
AtlasFluxError includes status, type, code, param, requestId, guidance, actionUrl, retryable, and retryAfterSeconds. Match on code, not the complete message. Streaming failures that arrive after the connection starts are emitted as stream events instead of being thrown as an initial HTTP error. See the complete error catalog.