In today’s information-rich world, traditional keyword-based search often falls short of user expectations. Users want to ask questions naturally and receive intelligent, contextual answers. That’s where our AI Search API TypeScript Client comes in – a powerful Node.js SDK that brings semantic AI search capabilities directly to your JavaScript and TypeScript applications.
Why Choose AI Search API?
🧠 Semantic Understanding, Not Just Keywords
Unlike traditional search that matches exact words, our AI-powered search understands meaning. Ask “How do neural networks learn?” and get comprehensive answers about machine learning, not just pages containing those exact words.
💬 Conversational Context
Build chat-like experiences where each query understands previous conversation history. Your users can ask follow-up questions like “What are the benefits?” and the API remembers you were discussing renewable energy.
📝 Flexible Response Formats
Get answers in Markdown for rich formatting with lists, code blocks, and structured content, or choose plain text for simple integrations.
⚡ TypeScript-First Development
Built from the ground up with TypeScript, featuring strong typing, IntelliSense support, and superior developer experience.
Getting Started in Minutes
Installation
npm install aisearchapi-client
# or with yarn
yarn add aisearchapi-clientQuick Setup
import { AISearchAPIClient } from 'aisearchapi-client';
const client = new AISearchAPIClient({
apiKey: 'your-api-key-here' // Get yours at https://app.aisearchapi.io/dashboard
});
const result = await client.search({
prompt: 'What is machine learning and how does it work?',
response_type: 'markdown'
});
console.log(result.answer);
console.log('Sources:', result.sources);Real-World Use Cases
1. Knowledge Base Search
Transform your documentation into an intelligent assistant:
const result = await client.search({
prompt: 'How do I authenticate users in my React app?'
});
// Get comprehensive answers with code examples and best practices2. Contextual Customer Support
Build support bots that remember conversation context:
const result = await client.search({
prompt: 'What are the pricing options?',
context: [
{ role: 'user', content: 'I run a small business with 10 employees' },
{ role: 'user', content: 'Looking for project management software' }
]
});
// Returns pricing specifically relevant to small business PM tools3. Research and Analysis
Power research tools with intelligent information retrieval:
const result = await client.search({
prompt: 'Compare renewable energy trends in 2024',
response_type: 'markdown'
});
// Get structured analysis with charts, comparisons, and sourcesAdvanced Features
Usage Monitoring
Keep track of your API usage and credits:
const balance = await client.balance();
console.log('Credits remaining:', balance.available_credits);
if (balance.available_credits < 10) {
console.warn('Time to top up your credits!');
}Error Handling
Robust error handling with typed exceptions:
import { AISearchAPIError } from 'aisearchapi-client';
try {
const result = await client.search({ prompt: 'Hello world' });
} catch (error) {
if (error instanceof AISearchAPIError) {
console.error(`API Error [${error.statusCode}]:`, error.message);
}
}Custom Configuration
Customize client behavior for your needs:
const client = new AISearchAPIClient({
apiKey: process.env.AI_SEARCH_API_KEY,
baseUrl: 'https://api.aisearchapi.io',
timeout: 30000 // 30 second timeout
});TypeScript Excellence
Enjoy full type safety and excellent IntelliSense:
import type { SearchRequest, SearchResponse } from 'aisearchapi-client';
const searchParams: SearchRequest = {
prompt: 'Explain GraphQL vs REST APIs',
response_type: 'markdown',
context: [
{ role: 'user', content: 'I'm building a modern web application' }
]
};
const response: SearchResponse = await client.search(searchParams);Response Formats Compared
Markdown Response (Default)
Perfect for rich content display:
const result = await client.search({
prompt: 'Explain REST APIs',
response_type: 'markdown'
});Plain Text Response
Great for simple integrations:
const result = await client.search({
prompt: 'What is Node.js?',
response_type: 'text'
});Best Practices
1. Secure Your API Keys
// ✅ Good: Use environment variables
const client = new AISearchAPIClient({
apiKey: process.env.AI_SEARCH_API_KEY!
});
// ❌ Bad: Hardcoded keys
const client = new AISearchAPIClient({
apiKey: 'sk-1234567890abcdef' // Never do this!
});2. Handle Rate Limits Gracefully
try {
const result = await client.search({ prompt: 'Your query' });
} catch (error) {
if (error instanceof AISearchAPIError && error.statusCode === 429) {
// Implement retry logic or user feedback
console.log('Rate limit reached, please try again later');
}
}3. Optimize Context Usage
Keep context relevant but concise for better performance and accuracy:
// ✅ Good: Focused context
const context = [
{ role: 'user', content: 'I need help with React state management' }
];
// ❌ Avoid: Excessive irrelevant context
const context = [
{ role: 'user', content: 'I had coffee this morning' },
{ role: 'user', content: 'Weather is nice today' },
{ role: 'user', content: 'I need help with React...' }
];Getting Started Today
Ready to add intelligent search to your applications?
- Sign up for free – No credit card required
- Get your API key from the dashboard
- Install the client:
npm install aisearchapi-client - Start building with semantic search in minutes!
What’s Next?
The AI Search API TypeScript Client is actively maintained and regularly updated with new features. Check out the GitHub repository for the latest updates, contribute to the project, or report issues.
Whether you’re building a knowledge base, customer support system, research tool, or any application that needs intelligent search capabilities, the AI Search API TypeScript Client provides the foundation for exceptional user experiences.
Start your intelligent search journey today – your users will thank you for it!
Ready to transform your search experience? Get started with AI Search API and see the difference semantic search can make.