WiliChat Developer Documentation
Build powerful AI-powered applications with WiliChat SDK. Integrate chatbots, assistants, and analyzers in minutes.
Install the SDK
npm install @wilichat/sdkGet Your API Key
Sign up for a WiliChat account and navigate to Settings → API Keys to create your first API key.
export WILICHAT_API_KEY="your-api-key-here"Make Your First Request
import WiliChat from '@wilichat/sdk';
const client = new WiliChat({
apiKey: process.env.WILICHAT_API_KEY
});
const response = await client.chat.create({
model: 'gpt-4',
messages: [
{ role: 'user', content: 'Hello, WiliChat!' }
],
stream: true
});
for await (const chunk of response) {
process.stdout.write(chunk.content);
}SDK Methods
client.chat.create()Create a new chat conversation with streaming support
client.chat.stream()Stream chat responses in real-time
client.chat.createConversation()Create a new conversation thread
client.chat.getConversation()Retrieve conversation history
client.files.upload()Upload files for document processing and RAG
client.files.list()List all uploaded files
client.files.delete()Delete a file
client.files.reprocess()Reprocess a file for better indexing
client.conversations.list()List all conversations
client.conversations.get()Get conversation details
client.conversations.delete()Delete a conversation
client.conversations.messages()Get messages from a conversation
Build Chatbots
Create intelligent chatbots for customer support, sales, and engagement
const chatbot = await client.chat.create({
model: 'gpt-4',
messages: [{ role: 'user', content: userMessage }],
persona: 'customer-support'
});Document Analysis
Upload documents and ask questions based on their content using RAG
// Upload document
const file = await client.files.upload({
file: documentFile,
type: 'pdf'
});
// Query the document
const response = await client.chat.create({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Summarize this document' }],
fileId: file.id
});Streaming Responses
Get real-time streaming responses for better user experience
const stream = await client.chat.stream({
model: 'gpt-4',
messages: [{ role: 'user', content: 'Tell me a story' }]
});
for await (const chunk of stream) {
displayChunk(chunk.content);
}Official SDKs available for popular languages. More coming soon!
Receive real-time notifications for events like new messages, conversation updates, and file processing.
Using API Keys
Your API key is automatically used when you initialize the SDK:
const client = new WiliChat({
apiKey: process.env.WILICHAT_API_KEY
});Security Best Practices
- • Never expose your API keys in client-side code
- • Use environment variables to store API keys
- • Rotate your API keys regularly
- • Revoke compromised keys immediately