Skip to main content

Install and construct

Use Node.js 22.20 or later and ESM. Keep the key in a server process.
Validate your environment first; a TypeScript non-null assertion does not validate an environment variable.

Tools

The tool input envelope accepts body, queryParams and pathParams. Inspect the selected endpoint before constructing it. See tool API.

Models

Messages support system, user, assistant and tool roles. Function calls are returned data: your application must authorize and execute them. Preserve the assistant message, call IDs and reasoning details on continuation. See function calling. The separate freeChat({model, prompt, signal?}) method is development-only. Use models.createRun in production, including for free models.

Compute

LocalComputeClient is exported from @dreamtune/sdk/node. Its constructor takes apiKey, baseUrl, stateDirectory and timeoutMs. Use prepare and start with {name, instanceType, region}; connection takes id, sshUser, optional name and signal. See GPU access.

Observability

See observability API and prompt API.

Cancellation and errors

Pass an AbortSignal to enforce your deadline. Aborting a request does not prove a provider stopped or that a GPU terminated. Read the saved operation and stop compute explicitly. Catch DreamtuneError and inspect its status and message without logging credentials or customer content. HTTP success can contain a failed or pending operation. Check state before using output. Amounts are integer strings; use BigInt and the returned scale. Pending zero charges are not final receipts. See conventions.