npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

aisearchapi-client

v1.0.11

Published

TypeScript client library for AI Search API - search and retrieve intelligent responses with context awareness

Readme

⚡ AI Search API - TypeScript Client

npm version TypeScript JavaScript Node.js

A comprehensive TypeScript client for the AI Search API that provides intelligent semantic search with context awareness and flexible response formats.

👉 Start by creating your free account:


✨ Features

  • 🔍 Semantic AI Search – Natural language queries powered by embeddings
  • 💬 Context Awareness – Add chat-like conversation context
  • 📝 Flexible Responses – Markdown or plain text
  • TypeScript First – Strong typing, IntelliSense, better DX
  • 📊 Usage Tracking – Check API balance anytime

📦 Installation

npm install aisearchapi-client
# or with yarn
yarn add aisearchapi-client

Or install from source:

git clone https://github.com/aisearchapi/aisearchapi-js.git
cd aisearchapi-js
npm install

🚀 Quick Start

import { AISearchAPIClient } from 'aisearchapi-client';

const client = new AISearchAPIClient({
  apiKey: 'your-api-key-here' // get it from https://app.aisearchapi.io/dashboard?utm_source=github
});

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);

🔧 API Reference

Client Configuration

const client = new AISearchAPIClient({
  apiKey: 'your-api-key',
  baseUrl: 'https://api.aisearchapi.io',
  timeout: 30000 // in ms
});

Search

const result = await client.search({
  prompt: 'Your query',
  context: [{ role: 'user', content: 'Previous message' }],
  response_type: 'markdown'
});

Balance

const balance = await client.balance();
console.log('Credits left:', balance.available_credits);

💡 Usage Examples

Basic Search

const result = await client.search({ prompt: 'Explain quantum computing simply' });
console.log(result.answer);

Contextual Search

const result = await client.search({
  prompt: 'What are the benefits?',
  context: [
    { role: 'user', content: 'I am researching renewable energy' },
    { role: 'user', content: 'Specifically solar and wind' }
  ]
});

Check Balance

const balance = await client.balance();
if (balance.available_credits < 10) {
  console.warn('Low balance!');
}

Error Handling

import { AISearchAPIError } from 'aisearchapi-client';

try {
  const result = await client.search({ prompt: 'Hello' });
} catch (error) {
  if (error instanceof AISearchAPIError) {
    console.error(`API Error [${error.statusCode}]:`, error.message);
  }
}

📘 TypeScript Support

This client is built in TypeScript:

import type { SearchRequest, SearchResponse } from 'aisearchapi-client';

const params: SearchRequest = { prompt: 'What is TypeScript?', response_type: 'markdown' };
const response: SearchResponse = await client.search(params);

📝 Response Formats

  • Markdown (default): rich text formatting, lists, code blocks
  • Plain text: simple string without formatting
await client.search({ prompt: 'Explain REST APIs', response_type: 'markdown' });
await client.search({ prompt: 'Explain Node.js', response_type: 'text' });

⚠️ Error Codes

| Code | Meaning | Fix | |------|---------|-----| | 401 | Unauthorized | Invalid API key → Get key | | 429 | Too Many Requests | Rate limit hit | | 433 | Quota Exceeded | Credits finished | | 500 | Server Error | Try again later | | 503 | Service Down | Maintenance |


🔑 Environment Variables

# .env
AI_SEARCH_API_KEY=your-key-here
const client = new AISearchAPIClient({
  apiKey: process.env.AI_SEARCH_API_KEY!
});

🌐 Browser Support

Primarily for Node.js. For browsers: configure CORS + secure your keys.


📚 Resources


📜 License

MIT License - see the LICENSE.


🔍 SEO Keywords

AI Search API TypeScript client, semantic search Node.js, contextual AI JavaScript, AI Search API npm package, AI Search API key setup, intelligent search SDK