JavaScript SDK quickstart
Found this helpful? Share it:
Found this helpful? Share it:
The idapt JavaScript SDK wraps the whole v1 API behind one typed client.
It runs in Node, serverless, and the browser, so you write client.chats.create(...) instead of hand-rolling requests
🧰
Install the package: npm install @idapt/sdk.
Create an API key under Settings → Developer. See API keys and scopes.
Connect with your key and start calling methods.
import { connect } from "@idapt/sdk";
const client = await connect({
apiUrl: "https://idapt.app",
key: process.env.IDAPT_API_KEY, // uk_...
});
const me = await client.user.me();
console.log(me.email);Keep the key in an environment variable, never in client-side code you ship to a browser. A key is a full credential that acts as you.
const workspaces = await client.workspaces.list();
const chat = await client.chats.create({
title: "Hello from the SDK",
workspace_id: workspaces[0].id,
});
const result = await client.chats.sendMessage(chat.id, {
content: "Summarize the latest AI news in three bullets.",
});
console.log(result.message);const models = await client.models.list();
console.log(models.length, "models available");Lists come back as plain arrays and single resources as plain
objects. The SDK unwraps the { data }envelope for
you.
import { NotFoundError, RateLimitError } from "@idapt/sdk";
try {
await client.chats.get("missing_id");
} catch (err) {
if (err instanceof NotFoundError) {
console.log("that chat is gone");
} else if (err instanceof RateLimitError) {
console.log("slow down and retry later");
} else {
throw err;
}
}Each failure throws a typed IdaptError subclass, so you
catch only the kinds you care about. See Rate limits and errors for the full set.
The REST API reference: the resources and endpoints behind each SDK method.
Rate limits and errors: the error classes and per-surface limits.
Related articles
REST API
Authentication, versioning, response shapes, pagination, and errors for the idapt REST API, plus the full endpoint list.
API keys and scopes
Create a key, choose its scopes, pin it to an API version, rotate it, and cap what it can spend.
Rate limits and errors
Every error shape the API returns, what each rate limit is, and how to handle a wall in code.
Was this helpful?