@airctrl/sdk combines the HTTP client, record cryptography and secret-format support. Use it in Node.js applications, scripts, CI workers and local tools.
The SDK does not read the CLI login file. Pass its identity explicitly through application configuration. See Combine tools when the CLI prepares a developer environment and the SDK performs runtime work.
Install
Create a human client
auth can also be a function. Use this when your application refreshes or resolves the token at call time.
Create a Service Account client
For an active Service Account credential, pass the matching bearer, credential ID and capability private key from one bundle.createServiceClient remains available as a compatibility alias. New code should use createClient for both humans and Service Accounts.
Create a confidential OAuth partner client
OAuth partner integrations use a separate client because they authenticate a registered confidential App, not a human PAT or Service Account:Supported bindings and advanced primitives
The methods in SDK methods are the supported developer bindings over the public API. The package also exports lower-level first-party primitives used by the Web app and CLI for Service Account credential lifecycle, includingAirctrlClient, Session, bootstrap contexts and lifecycle coordinators. Those advanced exports do not imply matching lifecycle commands or tools in the public CLI or MCP server. Use the installed package’s TypeScript declarations as the exact reference when you deliberately integrate those primitives.
Gateway connection URLs
buildGatewayConnectionConfig(apiUrl, gatewaySlug) is the shared URL builder used by the Web app and MCP server. It returns the compatibility base plus native OpenAI, Anthropic, Gemini, Mistral, OpenRouter, HiTheo, Groq, Novita AI, Atlas Cloud, and xAI bases, including the OpenAI, Gemini and Mistral realtime WebSocket URLs.
model query parameter for OpenAI and Mistral realtime connections. Authenticate every data-plane connection with a Gateway token, never with the stored provider key.
Read encrypted records
A human passes a vault passphrase to operations that decrypt or create record values:Account and project context
With a human PAT, calllistAccounts() first when you do not know the account ID. A Service Account
is already bound to one account and cannot enumerate accounts. Methods that act in account context
require accountId. Project and resource IDs never replace account context.
Errors
API failures throwAirctrlError with:
status: HTTP status.code: stable error category when available.message: safe reason for the failure.details: optional validation details.
OAuthPartnerClient is separate from AirctrlClient. Its failures throw
AirctrlOAuthError with status, the OAuth or error code, and optional
description.
See Errors and retries.
Idempotency
The SDK adds an idempotency key to writes. Record creation methods also accept your own stableidempotencyKey. Reuse that value only when retrying the same intended action with the same input.
Security notes
- Never log the client options, tokens, bundle or decrypted records.
- Keep the vault passphrase and Service Account capability in process memory only as long as needed.
- Use named SDK methods. They carry the supported public contract and keep CLI and MCP behavior aligned.
- Treat log bodies as sensitive data.