Package Exports
- @incheckai/sdk
Readme
InCheck Node.js SDK
TypeScript-first Node.js SDK for InCheck AI APIs.
Install
npm install @incheck/sdk
# or
pnpm add @incheck/sdk
# or
yarn add @incheck/sdk
# or
bun add @incheck/sdkRequirements
- Node.js
>=18
Authentication
Set your API key in either way:
- Constructor option:
apiKey - Environment variable:
INCHECK_API_KEY
import { Client } from "@incheck/sdk";
const client = new Client({
apiKey: process.env.INCHECK_API_KEY
});Environment and Base URL
Resolution order:
baseUrloptionINCHECK_BASE_URLenvironmentoption ("production" | "staging")INCHECK_ENVIRONMENT- Production default (
https://api.incheck.ai)
Staging URL:
https://api-acceptance.incheck.ai
const client = new Client({
environment: "staging"
});Client Exports
IncheckClientClient(alias)AsyncClient(alias)
Chat (EMS / Unified)
One-shot response
const result = await client.chat.create({
content: "Summarize this patient note.",
options: {
orgId: "org_123", // optional; omit for EMS mode
userId: "user_42"
}
});
console.log(result.content);Streaming response
for await (const chunk of client.chat.stream({
content: "Give me a step-by-step care plan.",
options: { orgId: "org_123" }
})) {
if (chunk.content) process.stdout.write(chunk.content);
}Documents
List orgs / documents
const orgs = await client.documents.listOrgs();
const docs = await client.documents.list("org_123");
// Normalization: download_url falls back to presigned_url
console.log(docs.documents[0]?.download_url);Upload files
import { readFile } from "node:fs/promises";
const status = await client.documents.upload(
"org_123",
[
"./docs/protocol.pdf",
{ filename: "extra.txt", data: new Uint8Array(await readFile("./docs/extra.txt")) }
],
{
batchSize: 6,
wait: true,
timeoutMs: 600_000,
pollIntervalMs: 10_000
}
);
console.log(status.status);Error Handling
import {
IncheckAuthenticationError,
IncheckRateLimitError,
IncheckValidationError
} from "incheck-nodejs";
try {
await client.chat.create({ content: "Hello" });
} catch (error) {
if (error instanceof IncheckAuthenticationError) {
console.error("Bad API key");
} else if (error instanceof IncheckRateLimitError) {
console.error("Rate limited", error.message);
} else if (error instanceof IncheckValidationError) {
console.error("Validation issue", error.message);
} else {
console.error("Unhandled error", error);
}
}