ChatSDK Documentation
The ChatSDK is the core component of the Odin AI Content Creator SDK that enables you to build conversational AI applications with ease. It provides comprehensive chat management, message handling, streaming responses, and knowledge base integration.Table of Contents
- Installation
- Quick Start
- Configuration
- Authentication
- Core Methods
- Streaming Support
- Error Handling
- Examples
- Best Practices
Installation
Quick Start
Configuration
ChatSDKConfig Interface
Configuration Options
- baseUrl: The base URL of your API endpoint
- projectId: Your unique project identifier
- apiKey & apiSecret: For server-side authentication
- accessToken: For client-side authentication (web apps)
Authentication
The ChatSDK supports two authentication methods:1. API Key Authentication (Server-side)
2. Access Token Authentication (Client-side)
Core Methods
Chat Management
createChat(name?, documentKeys?)
Creates a new chat conversation.
listChats(cursor?, limit?)
Retrieve a paginated list of chats in the project.
getChatHistory(chatId)
Retrieve a chat with its complete message history.
deleteChat(chatId)
Delete a chat and all its messages permanently.
updateChatName(chatId, newName)
Update the display name of an existing chat.
Message Handling
sendMessage(message, options?)
Send a message and receive the AI response.
sendFeedback(messageId, chatId, feedback)
Provide feedback on an AI response.
Streaming Support
sendMessageStream(message, options)
Send a message with real-time streaming response.
Error Handling
The SDK throwsAPIError objects for API-related failures:
Examples
Basic Chat Application
Streaming Chat with Real-time Updates
Knowledge Base Integration
Best Practices
1. Error Handling
Always implement proper error handling for all SDK methods:2. Streaming for Better UX
Use streaming for longer responses to provide real-time feedback:3. Optimize API Calls
- Reuse chat IDs instead of creating new chats for each message
- Use pagination for chat lists
- Implement caching for frequently accessed data
4. Configuration Management
Store configuration securely and use environment variables:5. Memory Management
Clean up resources and avoid memory leaks:For more information about other SDK components, see:

