condensationai
v0.2.0
Published
Condensation SDK for sandbox infrastructure and the shared Codegraff wallet
Maintainers
Readme
condensationai
JavaScript and TypeScript SDK for Condensation. The package ships ESM, CommonJS, and TypeScript declarations with no runtime dependencies. Requires Node.js 20+.
Install
npm install condensationaiSign in at https://workspaces.condensation.ai/account using Codegraff and create a
sandbox API key. Set CONDENSATION_API_KEY in your server environment. Never
embed it in browser code or commit it to Git.
import { Condensation } from 'condensationai';
const client = new Condensation();
const wallet = await client.wallet();
console.log(wallet.purchasedMicroUsd / 1_000_000);
const sandbox = await client.create({ language: 'python', autoStopMinutes: 5 });
try {
const result = await client.run(sandbox.id, 'python -c "print(1 + 1)"');
console.log(result.result);
} finally {
await client.delete(sandbox.id);
}The same example works in JavaScript. CommonJS: const { Condensation } =
require('condensationai').
Billing and access
Purchased credits use the existing Codegraff balance, shared with nanohub and Condensation. This first SDK release routes sandboxes through Codegraff's existing gateway and uses that gateway's resource rates, not the Condensation fleet rates on the pricing page. Condensation monthly bonuses do not fund this gateway path; Build checkout remains disabled until that integration is ready. Inspect the sandbox meter and configure a small auto-stop window. Stopped sandboxes can still incur storage charges; delete them when finished.
SDK keys can read their owner's wallet and manage that account's sandboxes. They cannot access inference, GitHub credentials, chat sessions, billing mutations, or admin endpoints. They see the owner's Codegraff sandboxes too. The configured monthly key budget is checked by the gateway at request admission; concurrent or already-running work can exceed a budget. The shared account balance remains the funding source.
API
wallet(),list(),get(id),create(options)run(id, command, options),runAsync(id, command, options)execution(id, execId),cancelExecution(id, execId)uploadBase64(id, path, contentBase64),downloadBase64(id, path)meter(id),stop(id),start(id),delete(id)
File operations reflect the gateway API. Its current download implementation is text-oriented; arbitrary binary round trips are not guaranteed.
new Condensation({ apiKey, baseUrl, timeoutMs, fetch }) supports explicit
configuration and injected fetch for tests. The default base URL is
https://api.condensation.ai; the default timeout is 120 seconds.
Requests never follow redirects or retry automatically. On a failed create,
command, or deletion, inspect state before repeating it: the server may have
completed the operation. CondensationError.status carries the HTTP status (zero
for a transport failure), and .details carries the API error body.
Source contract: api/openapi.json in the Condensation repository.
Own-fleet preview (0.2.0)
Use client.fleet for Condensation's own Cube infrastructure. The original
client.create API still uses the existing gateway provider and its pricing.
Own-fleet machines have 2 vCPU and 2000 MiB memory. Rates are $0.03/vCPU-hour plus $0.01/GiB-hour, with ephemeral storage included. Leases are 60–1800 seconds. Creation requires a UUID request ID, reserves purchased account credits, and is never automatically retried. Preserve the same request ID after an uncertain response. Confirm a terminal state after deletion to verify cleanup and settlement.
The fleet supports pricing, list, get, create, command execution, base64 file upload/download (1 MB), and permanent deletion. Python and shell are available. See https://workspaces.condensation.ai/docs/fleet for examples and MCP setup.
The Python distribution includes the condensation-mcp stdio command. Configure
CONDENSATION_API_KEY with an account-scoped key from the account page.
