@chanx-ai/sdk
v0.1.0
Published
MIT-licensed package prepared for public npm release. No external runtime dependencies. The default whole-request timeout is 240 seconds. A stream must deliver its protocol terminal event (`[DONE]`, `response.completed`, or `message_stop`); EOF before tha
Readme
Chanx AI SDK and CLI
MIT-licensed package prepared for public npm release. No external runtime dependencies.
The default whole-request timeout is 240 seconds. A stream must deliver its
protocol terminal event ([DONE], response.completed, or message_stop);
EOF before that produces a ChanxError with code stream_interrupted. Partial
events already yielded remain available to the caller. An SSE error event fails
the iterator even when the HTTP response started with status 200.
import { ChanxAI } from '@chanx-ai/sdk';
const client = new ChanxAI({apiKey: process.env.CHANX_API_KEY, baseURL: process.env.CHANX_BASE_URL});
const result = await client.chat({model:'smart-fast',messages:[{role:'user',content:'Hello'}],max_tokens:100});
for await (const event of client.streamResponses({model:'smart-fast',input:'Hello',max_output_tokens:100})) {
console.log(event);
}Set CHANX_BASE_URL to the actual dashboard endpoint, ending in /v1. Keep API keys on the server. Billable requests are never automatically retried. Errors contain status, code and Chanx request ID; provider error bodies are not printed. SSE delivery is incremental and honors caller cancellation and the configured deadline.
CLI: npx @chanx-ai/cli help; tests in the source repository:
node --test packages/sdk/sdk.test.mjs.
For connection diagnostics, run chanx doctor --model smart-fast (catalog,
endpoint and API-key checks, no inference charge). To test a real completion,
use chanx doctor --model smart-fast --paid-probe --accept-charge; add
--stream to validate a terminal SSE event. The paid probe caps output at 16
tokens, still incurs actual usage, and is never retried automatically. The
report contains layer, safe error code, HTTP status and request ID; it never
prints the API key. Tool support is not inferred from a catalog response.
