0.6.0. This binding uses ABI 1 / ops 1.0. The 0.5 top-level
openai(...)/generateText(...)helpers are removed. See the 0.6 upgrade guide.
The Node binding is the native napi-rs path: it calls the shared
aimux_ops::dispatch directly, not the C ABI. It requires Node 18+ and a
matching platform package.
npm install @arcships/aimuxThe package ships the platform .node binary in the matching
@arcships/aimux-* package; no Rust toolchain is needed.
import { Client, LanguageModel } from '@arcships/aimux'
const client = new Client()
const provider = await client.provider({
package: 'openai',
settings: { apiKey: process.env.OPENAI_API_KEY },
})
const model = await provider.model('gpt-4o-mini', 'languageModel')
try {
if (!(model instanceof LanguageModel)) throw new Error('Expected Language')
console.log((await model.generate('Hello')).text)
const controller = new AbortController()
for await (const frame of await model.stream('Hello', {}, { signal: controller.signal })) {
if (frame.type === 'event') console.log(frame.event)
else console.log(frame.outcome, frame.error)
}
} finally {
await model.close()
await provider.close()
}Client and the generated resource classes expose the same operation names as the manifest:
provider.create, provider.model, text.generate, text.stream,
embedding.embed, speech.generate, transcription.start,
decision.decide, provider.files, and so on. LanguageModel is the typed
facade for a language handle; other resource classes follow the same pattern.
@arcships/aimux/raw exposes the transport without the typed wrapper:
import { Runtime } from '@arcships/aimux/raw'
const runtime = new Runtime()
const manifest = await runtime.call('0', 'runtime.describe', '{}')
const result = await runtime.call(handle, 'text.generate', JSON.stringify(params))runtime.stream(handle, op, paramsJson, abort?) returns the same event/end
frames. Handles and sequence numbers are decimal strings, including values
above 2^53.
- A stream delivers business event frames plus one explicit end frame. Recoverable error events remain data; the end frame describes the terminal outcome.
return(),throw(), reader cancellation, object collection and Env teardown cancel the underlying work.- A full queue applies backpressure. Explicit cancellation wakes a blocked producer.
AbortController.signalmaps to native Abort; aborting a shared handle cancels every user of that work.
try {
await model.generate('Hello')
} catch (error) {
// AimuxError: kind, code, message, error, cause
console.error(error.kind, error.code, error.message, error.error)
}- The envelope is
{ kind, code, message, error }. error.causeis anAimuxCauseErrorfor a nested AI SDK error or anAimuxSourceErrorfor an OS/TLS/parser error; follow its owncausechain.- A retry error's cause is its last attempt.
- Read a retry delay from
error.responseHeaders(retry-after-ms, thenretry-after), not from a dedicated retry field.
- Top-level
openai,generateText,streamTextand provider-specific constructors are removed; useClientand the resource classes. - Errors are the shared envelope;
retryMsand the old error-value companion are gone. - DTOs are generated from the Rust types; hand-written 0.5 wire types are removed.
- The runtime requires the exact
ABI_VERSION, exactopsVersion, and manifest compatibility (MANIFEST_DIGESTfast-path or fullTYPE_SCHEMA_HASHESschemaHashfallback).
- bindings/node/README.md — limits, test commands, raw transport and lifecycle details.
- docs/api/ops.md — operation names.
- docs/error-model.md — error codes and cause chains.
- Node provider list.