Streaming
Streaming is an optional capability. Gate on supports.streaming before subscribing; the compile-checked capability pattern demonstrates the guard.
Through the createApiClient facade, streamRun(body, handlers, { signal? }) resolves a CapabilityResult<RunStreamOutcome>. ok reflects the streaming call; data carries the run's terminal state (runId + outcome), so a run that fails as a run.failed event still resolves ok:true. Runtime-only providers stream natively; gateway providers (Hermes, OpenClaw) are bridged over their event transport. A caller abort (options.signal) resolves ok:false with a request-aborted gap and issues a best-effort cancelRun.
This client mirrors and verifies upstream-compatible behavior. Upstream runtimes remain the canonical protocol owners.
Referenced examples
Verified example · TypeScript
Runtime capabilities
examples/runtime-capabilities.ts
import { runtimeSupports, type RuntimeClient } from "@cavi-ai/api-client";
export async function submitWhenBatchIsAvailable(client: RuntimeClient) {
const capabilities = await client.getRuntimeCapabilities();
if (!runtimeSupports(capabilities, "batch") || !client.submitBatch) return null;
return client.submitBatch([{ customId: "summary", body: { input: "Summarize this." } }]);
}
Package imports
Referenced by
Artifact provenance
- Package
- @cavi-ai/api-client@0.16.0
- Release
- v0.16.0
- Commit
482141371d7fdb2dd38f7d6eaa5732aec669385a- Source
examples/runtime-capabilities.ts- Tarball SHA-256
f8ca0ce45d7bf563b1212c708668a5fe788967b8b7d5dbdc9e119e9e09d60167- Content SHA-256
274cf7e926de9581e270ef9bf6120666e7f0595ddf98b6378d7b9921fcff88d3