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.
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:Authorization: Bearer <api-key> and uses https://api.atlasflux.my by default.
Client configuration
Responses API
Useclient.responses.create() for the native AtlasFlux response format:
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
Useclient.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 anevent name and data payload.
Responses streaming
response.created, response.output_text.delta, response.usage, response.completed, and response.failed. See Responses streaming for the event format.
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 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 tocreate() 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 exportsAtlasFluxError 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.
Related documentation
- Authentication - Create, store, and rotate API keys
- Quickstart - Make a first API call without an SDK
- Text generation - Configure prompts and output
- Streaming responses - Work with SSE directly
- Models - Review capabilities and routing
- API Reference - Full endpoint and parameter reference
