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 🙏

© 2026 – Pkg Stats / Ryan Hefner

aivok

v1.0.6

Published

A lightweight JavaScript library for calling AI language models — zero boilerplate, automatic provider fallback, agentic tool loops, and custom AI personas.

Readme

aivok

npm version npm downloads License TypeScript CI

A unified JavaScript/TypeScript library for calling AI language models — with zero boilerplate, automatic provider fallback, agentic tool loops, and custom AI personas.


Why aivok?

  • One import, every provider — Gemini, Groq, Anthropic, Mistral, Cohere, OpenAI, Ollama, OpenRouter, and any OpenAI-compatible API
  • Zero boilerplate — retries, rate limit backoff, message history, tool formatting handled automatically
  • Provider-agnostic — swap models by changing one config line
  • TypeScript native — full type safety, works seamlessly in JS and TS projects
  • Zero runtime dependencies — lightweight, auditable, no bloat

Quick Start

npm install aivok
import { createAivok } from 'aivok'

### One-line setup (auto-detects API keys from `.env`)

```js
import 'dotenv/config'
import { createAivok } from 'aivok'

const ai = createAivok()
const answer = await ai.ask('Explain async/await in JavaScript')
console.log(answer)

Explicit configuration

import { createAivok } from 'aivok'

const ai = createAivok({
  provider: 'gemini',
  model:    'gemini-2.0-flash',
  apiKey:   process.env.GEMINI_API_KEY,
})

Supported Providers

| Provider | Description | |---|---| | Gemini | Google Gemini — large context window | | Groq | Groq — fast inference | | Anthropic | Anthropic Claude — careful reasoning | | Mistral | Mistral AI — multilingual | | Cohere | Cohere — enterprise, RAG | | OpenAI | OpenAI GPT models | | OpenAI-compatible | Ollama, OpenRouter, DeepSeek, xAI |

See docs/providers.md for setup guides and API key instructions.


Features

Single question

const reply = await ai.ask('What is the capital of France?')

Multi-turn chat

const session = ai.chat()
await session.send('Explain closures in JavaScript')
await session.send('Give me a real-world example')

Streaming

await ai.stream('Write a story', (chunk) => process.stdout.write(chunk))

Structured JSON

const data = await ai.json('List 5 JS frameworks with name and year')
// Returns parsed JavaScript object

Custom persona

const ai = createAivok({
  provider: 'gemini',
  persona: {
    name:  'Nova',
    role:  'a helpful portfolio assistant',
    tone:  'friendly and concise',
    rules: ['keep answers short', 'only discuss my projects'],
  },
})

Provider fallback

const ai = createAivok({
  providers: [
    { name: 'gemini', model: 'gemini-2.0-flash', apiKey: process.env.GEMINI_API_KEY, primary: true },
    { name: 'groq',   model: 'llama-3.3-70b-versatile', apiKey: process.env.GROQ_API_KEY },
  ],
})
// Tries Gemini first, automatically falls back to Groq on rate limit

Agentic tool loop

const result = await ai.agent({
  goal: 'Read package.json, bump the patch version, save it back',
  tools: {
    readFile:  { description: 'Read a file', params: { path: 'string' }, run: async ({ path }) => fs.readFileSync(path, 'utf8') },
    writeFile: { description: 'Write a file', params: { path: 'string', content: 'string' }, run: async ({ path, content }) => { fs.writeFileSync(path, content); return 'done' } },
  },
  maxSteps: 5,
})

console.log(result.answer)     // final response
console.log(result.steps)      // audit trail

Built-in persona presets

import { createAivok, personas } from 'aivok'

const ai = createAivok({ ..., persona: personas.coder })
// personas.support | personas.tutor | personas.writer | personas.coder

Documentation

| Guide | Description | |---|---| | API Reference | Every function, parameter, and return type | | Providers | Setup guides and API key instructions | | Agents | Tool loop, tool definition format, examples | | Personas | Custom AI identities, presets | | Examples | Annotated copy-paste examples |


Error Handling

All methods throw errors with a code property:

try {
  const reply = await ai.ask('Hello')
} catch (err) {
  if (err.code === 'RATE_LIMIT')    console.log('All providers rate limited')
  if (err.code === 'AUTH_ERROR')    console.log('Invalid API key')
  if (err.code === 'MAX_STEPS')     console.log('Agent exceeded maxSteps')
  if (err.code === 'PARSE_ERROR')   console.log('Invalid JSON response')
}

Author

Built by @tyecode


License

MIT