Client
What is the SDK Client?
The SDK client is your application's runtime connector to Telygent AI. It coordinates history loading, request submission, local tool execution through your adapter, and final response handling.
You initialize it once with createAiClient(...) and then call methods like query(), queryStream(), and getConversationMessages().
Client parameters
These are the configuration fields accepted by createAiClient.
apiKey
Telygent API key used for authentication.
historyStore
Conversation storage backend (Redis, Mongo, or custom
HistoryStore).aiName
OptionalCustom assistant display name.
registry
OptionalModel registry used for tool safety, fields, and filters.
registryVersion
OptionalManually set registry version. If omitted, SDK computes one.
dbAdapter
Optional*Runs query/aggregate/document tools locally. Required when using
query()/queryStream().customServices
OptionalModel-specific handlers for
custom_query calls.log
OptionalEnables SDK runtime logs when true.
history.maxMessages
OptionalNumber of latest user turns included per request context window.
Initialization example
Typical production setup with registry, Redis history store, and Mongo adapter.
client-init.ts
1import {createAiClient, createRedisHistoryStore, createMongoAdapter} from "@telygent/ai-sdk";
2import {MongoClient} from "mongodb";
3
4const historyStore = createRedisHistoryStore({
5 url: process.env.REDIS_URL as string,
6 ttlSeconds: 3600,
7});
8
9const mongoClient = new MongoClient(process.env.MONGO_URI as string);
10await mongoClient.connect();
11const mongoDb = mongoClient.db(process.env.MONGO_DB_NAME as string);
12
13const registry = {
14 Transaction: {
15 collectionName: "transactions",
16 allowedFields: ["amount", "status", "createdAt"],
17 requiredFilters: [{field: "tenantId", contextKey: "tenantId"}],
18 },
19};
20
21const dbAdapter = createMongoAdapter({db: mongoDb, registry});
22
23const client = createAiClient({
24 apiKey: process.env.TELYGENT_API_KEY as string,
25 aiName: "Atlas",
26 registry,
27 historyStore,
28 dbAdapter,
29 log: false,
30 history: {
31 maxMessages: 10,
32 },
33});Minimal setup
The smallest valid initialization only requires apiKey. Add registry, adapter, and history store as you wire query execution.
client-minimal.ts
1import {createAiClient} from "@telygent/ai-sdk";
2
3const client = createAiClient({
4 apiKey: process.env.TELYGENT_API_KEY as string,
5});