Simple & Intuitive
Easy-to-use API for creating conversational AI applications with just a few lines of code.
Official JavaScript/TypeScript SDK with client-side tool execution support
import { CognipeerClient } from '@cognipeer/sdk';
const client = new CognipeerClient({
token: 'pat_your-personal-access-token',
hookId: 'your-channel-hook-id'
});
// Get peer, user, and channel information
const peer = await client.peers.get();
const user = await client.users.get();
const channel = await client.channels.get();
console.log(`Using peer: ${peer.name}`);
console.log(`Authenticated as: ${user.email}`);
console.log(`Channel: ${channel.name}`);
// Create a conversation
const response = await client.conversations.create({
messages: [
{ role: 'user', content: 'Hello! How can you help me?' }
]
});
console.log(response.content);
// List conversations with pagination
const { data, total } = await client.conversations.list({
page: 1,
limit: 10
});
console.log(`You have ${total} conversations`);// Create a conversation with client tools
const response = await client.conversations.create({
messages: [
{ role: 'user', content: 'What is the weather in San Francisco?' }
],
clientTools: [{
type: 'function',
function: {
name: 'getCurrentWeather',
description: 'Get current weather for a location',
parameters: {
type: 'object',
properties: {
location: { type: 'string' }
},
required: ['location']
}
},
implementation: async ({ location }) => {
// Your weather API call here
return `Weather in ${location}: Sunny, 72°F`;
}
}]
});console.log(response.content); // The AI automatically called your function and used the result!
## Installation
::: code-group
```bash [npm]
npm install @cognipeer/sdkyarn add @cognipeer/sdkpnpm add @cognipeer/sdk:::
The Cognipeer SDK makes it incredibly easy to build AI applications with function calling capabilities. Unlike traditional AI SDKs that only support server-side tools, Cognipeer enables client-side tool execution where your JavaScript functions are automatically called by the AI and the results are seamlessly integrated into the conversation.