The official JavaScript/TypeScript library for the HelpingAI API - Advanced AI with Emotional Intelligence
- OpenAI-Compatible API: Drop-in replacement with familiar interface
- Emotional Intelligence: Advanced AI models with emotional understanding
- Streaming Support: Real-time response streaming
- Comprehensive Error Handling: Detailed error types and retry mechanisms
- TypeScript Support: Full type definitions included
- Cross-Platform: Works in Node.js and browsers
- Flexible Configuration: Environment variables and direct initialization
npm install helpingai
# or
yarn add helpingai
# or
pnpm add helpingai
Get your API key from the HelpingAI Dashboard.
export HAI_API_KEY='your-api-key'
import { HAI } from 'helpingai';
const hai = new HAI({ apiKey: 'your-api-key' });
import { HAI } from 'helpingai';
// Initialize client
const hai = new HAI();
// Create a chat completion
const response = await hai.chat.completions.create({
model: "Helpingai3-raw",
messages: [
{ role: "system", content: "You are an expert in emotional intelligence." },
{ role: "user", content: "What makes a good leader?" }
]
});
console.log(response.choices[0].message.content);
const { HAI } = require('helpingai');
// Initialize client
const hai = new HAI();
async function example() {
// Create a chat completion
const response = await hai.chat.completions.create({
model: "Helpingai3-raw",
messages: [
{ role: "user", content: "Tell me about empathy" }
]
});
console.log(response.choices[0].message.content);
}
example();
// Stream responses in real-time
const stream = await hai.chat.completions.create({
model: "Helpingai3-raw",
messages: [{ role: "user", content: "Tell me about empathy" }],
stream: true
});
for await (const chunk of stream) {
if (chunk.choices[0].delta.content) {
process.stdout.write(chunk.choices[0].delta.content);
}
}
const response = await hai.chat.completions.create({
model: "Dhanishtha-2.0-preview",
messages: [{ role: "user", content: "Write a story about empathy" }],
temperature: 0.7, // Controls randomness (0-1)
max_tokens: 500, // Maximum length of response
top_p: 0.9, // Nucleus sampling parameter
frequency_penalty: 0.3, // Reduces repetition
presence_penalty: 0.3, // Encourages new topics
hideThink: true // Filter out reasoning blocks
});
const hai = new HAI({
apiKey: "your-api-key",
baseURL: "https://api.helpingai.co/v1", // Custom base URL
timeout: 30000, // Request timeout (ms)
organization: "your-org-id" // Organization ID
});
import {
HAI,
HAIError,
RateLimitError,
InvalidRequestError,
AuthenticationError
} from 'helpingai';
async function makeCompletionWithRetry(messages: any[], maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
try {
return await hai.chat.completions.create({
model: "Helpingai3-raw",
messages
});
} catch (error) {
if (error instanceof RateLimitError) {
if (attempt === maxRetries - 1) throw error;
await new Promise(resolve =>
setTimeout(resolve, (error.retryAfter || 1) * 1000)
);
} else if (error instanceof InvalidRequestError) {
console.error(`Invalid request: ${error.message}`);
throw error;
} else if (error instanceof AuthenticationError) {
console.error(`Authentication failed: ${error.message}`);
throw error;
} else if (error instanceof HAIError) {
console.error(`API error: ${error.message}`);
throw error;
} else {
throw error;
}
}
}
}
- Advanced Emotional Intelligence: Enhanced emotional understanding and contextual awareness
- Training Data: 15M emotional dialogues, 3M therapeutic exchanges, 250K cultural conversations, 1M crisis response scenarios
- Best For: AI companionship, emotional support, therapy guidance, personalized learning
- World's First Intermediate Thinking Model: Multi-phase reasoning with self-correction capabilities
- Unique Features:
<think>...</think>
blocks for transparent reasoning, structured emotional reasoning (SER) - Best For: Complex problem-solving, analytical tasks, educational content, reasoning-heavy applications
// List all available models
const models = await hai.models.list();
models.forEach(model => {
console.log(`Model: ${model.id} - ${model.description}`);
});
// Get specific model info
const model = await hai.models.retrieve("Helpingai3-raw");
console.log(`Model: ${model.name}`);
// Use Dhanishtha-2.0 for complex reasoning
const response = await hai.chat.completions.create({
model: "Dhanishtha-2.0-preview",
messages: [{ role: "user", content: "Solve this step by step: What's 15% of 240?" }],
hideThink: false // Show reasoning process
});
For browser environments, you can use a CDN:
<script type="module">
import { HAI } from 'https://cdn.skypack.dev/helpingai';
const hai = new HAI({ apiKey: 'your-api-key' });
const response = await hai.chat.completions.create({
model: "Helpingai3-raw",
messages: [{ role: "user", content: "Hello!" }]
});
console.log(response.choices[0].message.content);
</script>
helpingai-js/
├── src/
│ ├── index.ts # Main entry point
│ ├── client.ts # HAI client and API classes
│ ├── models.ts # Model management
│ ├── types.ts # TypeScript type definitions
│ └── errors.ts # Error classes
├── dist/ # Compiled JavaScript
├── package.json # Package configuration
├── tsconfig.json # TypeScript configuration
└── README.md # This file
- Node.js: 14+ (for Node.js environments)
- Modern Browsers: Chrome 63+, Firefox 57+, Safari 10.1+, Edge 79+
- Dependencies:
node-fetch
(for Node.js environments without native fetch)
This library is written in TypeScript and includes full type definitions:
import {
HAI,
ChatCompletion,
ChatCompletionChunk,
Model,
HAIClientOptions
} from 'helpingai';
// Full type safety
const options: HAIClientOptions = {
apiKey: "your-api-key",
timeout: 30000
};
const hai = new HAI(options);
const response: ChatCompletion = await hai.chat.completions.create({
model: "Helpingai3-raw",
messages: [{ role: "user", content: "Hello!" }]
});
We welcome contributions! Please see our Contributing Guide for details.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Documentation: HelpingAI Docs
- Dashboard: HelpingAI Dashboard
- Email: [email protected]
- Cross-Platform Support: Works in Node.js and browsers
- Updated Models: Support for latest models (Helpingai3-raw, Dhanishtha-2.0-preview)
- Dhanishtha-2.0 Integration: World's first intermediate thinking model with multi-phase reasoning
- HelpingAI3 Support: Enhanced emotional intelligence with advanced contextual awareness
- OpenAI-Compatible Interface: Familiar API design
- Enhanced Error Handling: Comprehensive exception types
- Streaming Support: Real-time response streaming
- Advanced Filtering: Hide reasoning blocks with
hideThink
parameter - Full TypeScript Support: Complete type definitions
Built with ❤️ by the HelpingAI Team
Empowering AI with Emotional Intelligence