@formthefog/stratus-sdk-ts is the native TypeScript client for Stratus X1 — it exposes every endpoint, handles retries with exponential backoff, and ships compression utilities and vector DB adapters alongside the core API surface.
Installation
Quick Start
A minimal working example from zero to first response:STRATUS_API_KEY is the only required credential. Formation’s shared pool handles LLM calls automatically on day one — no provider key needed to get started. Add your own key at any time to remove the 25% pool markup. See Authentication for the full key resolution flow.Constructor options
Chat Completions
client.chat.completions.create(request)
Posts to POST /v1/chat/completions and returns a Promise<ChatCompletionResponse>. Retries up to config.retries (default 3) on transient failures with exponential backoff — 1s, 2s, 4s. Non-retried on 400, 401, and 422.
Hybrid orchestration extensions
Thestratus field on the request activates advanced planning modes:
The
stratus.mode field controls how the X1 world model engages. hybrid combines planning and validation in a single pass — it plans a full action sequence, verifies the predicted outcome against your threshold, and re-plans automatically if confidence falls short.Inline LLM keys
Pass provider keys per-request rather than storing them in vault. Useful for CI, multi-tenant setups, or quick testing:openai_key, anthropic_key, gemini_key, openrouter_key.
client.chat.completions.stream(request)
Forces stream: true and returns AsyncGenerator<ChatCompletionChunk>. Planning metadata appears on the first chunk’s stratus field.
Full ChatCompletionRequest type reference
Full ChatCompletionRequest type reference
StratusMetadata — on every response
StratusMetadata — on every response
brain_signal surfaces the X1 brain’s internal read on the current state — it tells you which action type the planner committed to, whether a simulation confirmed that choice, and how far the predicted outcome sits from the goal. Use brain_signal.goal_proximity as a normalized progress indicator across a multi-step task.Messages (Anthropic Format)
client.messages(request) posts to POST /v1/messages — the Anthropic-native endpoint. Use this if your codebase already speaks the Anthropic SDK format. The request takes an AnthropicRequest and the response is a standard AnthropicResponse extended with stratus?: StratusMetadata.
max_tokens is required in the Anthropic format — unlike the OpenAI endpoint where it is optional. The system parameter is the natural place to describe environment state for Stratus world model planning.StratusClient required:
Embeddings
client.embeddings(request) posts to POST /v1/embeddings. For embeddings, use the model name without an LLM suffix — stratus-x1ac-base (not stratus-x1ac-base-gpt-4o). The encoder produces 768-dimensional vectors for the base model.
encoding_format: 'base64' for high-throughput pipelines — the payload is ~25% smaller and decodes cleanly with Buffer.from(str, 'base64').
Stratus embeddings are optimized for agent state and action semantics — not general-purpose text. They excel at state similarity, goal matching, and pattern retrieval from agent memory. For document search or FAQ matching, general-purpose embeddings (OpenAI
text-embedding-3, Cohere embed-v3) are a better fit.Rollout
client.rollout(request) posts to POST /v1/rollout — pre-execution simulation. Give it a goal and an initial state description; it plans a full action sequence through the world model and returns predicted outcomes at each step before anything executes.
The
summary.planner field tells you which path the X1 brain took: brain means the top-level policy head selected actions directly; action_planner means a forward search was run through the world model to find the best sequence. Either path produces valid plans — the distinction is useful for debugging and cost tracking since forward search is more compute-intensive.RolloutRequest and RolloutResponse types
RolloutRequest and RolloutResponse types
Models
client.listModels() calls GET /v1/models. No authentication required. Returns the full list of available stratus-x1ac-{size}-{llm} combinations — every planning model size paired with every supported downstream LLM.
LLM Key Management
Store your provider keys once in Stratus vault — encrypted at rest with AES-256-GCM — and every future request uses them automatically, bypassing the Formation pool markup entirely.client.account.llmKeys.set(keys)
Posts to POST /v1/account/llm-keys. All fields optional — provide any combination. Omitted keys remain unchanged.
400 with the provider name and rejection reason.
client.account.llmKeys.get()
Calls GET /v1/account/llm-keys. Returns presence and last-validated timestamps — never the raw key values.
formation_keys_available is true for all active accounts. Even after you store your own keys, Formation’s pool remains available as a fallback — it activates only when no native key is found for a given provider. You can remove it as the path for a specific provider by storing that provider’s key.client.account.llmKeys.delete(provider?)
Calls DELETE /v1/account/llm-keys. Pass a provider name to remove a single key, or omit to delete all stored keys.
'openai', 'anthropic', 'google', 'openrouter'.
Credits
client.credits.packages()
Calls GET /v1/credits/packages. No authentication required. Lists available credit packages with current pricing.
client.credits.purchase(pkg, paymentHeader)
Posts to POST /v1/credits/purchase/{pkg} with an X-PAYMENT header containing a signed x402 transaction. On success, returns a CreditPurchaseResponse — and for first-ever account creation, the response includes stratus_api_key with your new key.
Error Handling
The SDK throwsStratusAPIError for any non-2xx response. Catch it and branch on errorType:
StratusAPIError shape
Retry behavior
The client retries automatically on any error that is not 400, 401, or 422. Backoff is exponential starting at 1s:1s → 2s → 4s. The number of retries is controlled by config.retries (default 3). To disable retries entirely, set retries: 0 in the constructor.
Compression Utilities
@formthefog/stratus-sdk-ts ships a suite of vector compression and quality analysis utilities alongside the API client. Use them to reduce embedding storage costs by 10–20× with 99%+ retention quality.
Compression profiles
Pre-tuned profiles for common embedding shapes:MJEPA_768_* profiles for vectors produced by stratus-x1ac-base. Use OPENAI_* profiles for OpenAI text-embedding-3 vectors.
Vector DB adapters
Drop-in adapters for Pinecone, Weaviate, and Qdrant that compress vectors before upsert and decompress on fetch — transparently:Health Check
client.health() calls GET /health. No authentication required. Returns current system status — use it to check whether vault is available before calling account.llmKeys.set().
Next Steps
Authentication
Set up your Stratus API key, configure BYOK, and understand the three-tier key resolution flow.
API Reference
Full endpoint docs, request parameters, response shapes, and error codes.
Tutorials
Real-world agents — web navigation, cascade prediction, and concurrent task orchestration.

