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

ainative-openai

v1.0.0

Published

Drop-in replacement for the openai npm package — routes to AINative's free OpenAI-compatible API. Free Llama 3.3 70B, Qwen, DeepSeek models with zero config.

Readme

ainative-openai

Drop-in replacement for the openai npm package — routes to AINative's free OpenAI-compatible API.

Get free access to Llama 3.3 70B, Qwen, DeepSeek, and more open-source models. Same API, zero config.

Quick Start

npm install ainative-openai openai
import OpenAI from 'ainative-openai';

const client = new OpenAI();

const response = await client.chat.completions.create({
  model: 'llama-3.3-70b',
  messages: [{ role: 'user', content: 'Explain quantum computing in one paragraph.' }]
});

console.log(response.choices[0].message.content);

That's it. No API key needed on first run — one is auto-provisioned for you.

Why?

| Feature | openai | ainative-openai | |---------|----------|-------------------| | Price | Pay per token | Free tier included | | Models | OpenAI only | Llama 3.3 70B, Qwen, DeepSeek, + more | | Setup | API key required | Zero config (auto-provisions) | | API | OpenAI API | Same OpenAI API | | Streaming | Yes | Yes | | Tool calling | Yes | Yes | | TypeScript | Yes | Yes (inherits from openai) |

How It Works

ainative-openai wraps the official openai npm package and:

  1. Points baseURL to AINative's OpenAI-compatible API (https://api.ainative.studio/api/v1)
  2. Auto-provisions a free account on first use if no API key is found
  3. Saves credentials to ~/.ainative/config.json, .env, and .mcp.json

Everything else — streaming, tool calling, TypeScript types, error handling — comes directly from the openai package.

Available Models (Free Tier)

| Model | Best For | |-------|----------| | llama-3.3-70b | General purpose, reasoning | | qwen3-coder | Code generation | | deepseek-coder-v2 | Code + reasoning | | qwen-2.5-72b | Multilingual, math | | llama-3.1-8b | Fast, lightweight tasks |

Streaming

import OpenAI from 'ainative-openai';

const client = new OpenAI();

const stream = await client.chat.completions.create({
  model: 'llama-3.3-70b',
  messages: [{ role: 'user', content: 'Write a haiku about code.' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}

Tool Calling

import OpenAI from 'ainative-openai';

const client = new OpenAI();

const response = await client.chat.completions.create({
  model: 'qwen3-coder',
  messages: [{ role: 'user', content: 'What is the weather in San Francisco?' }],
  tools: [{
    type: 'function',
    function: {
      name: 'get_weather',
      description: 'Get current weather for a city',
      parameters: {
        type: 'object',
        properties: {
          city: { type: 'string', description: 'City name' }
        },
        required: ['city']
      }
    }
  }]
});

console.log(response.choices[0].message.tool_calls);

Authentication

Credentials are resolved in this order:

  1. opts.apiKey passed to constructor
  2. AINATIVE_API_KEY environment variable
  3. OPENAI_API_KEY environment variable
  4. ZERODB_API_KEY environment variable
  5. ~/.ainative/config.json
  6. .mcp.json in project directory (walks up 6 levels)
  7. Auto-provision a free account (credentials saved for next time)

Using an existing API key

export AINATIVE_API_KEY=ak_your_key_here

Or pass it directly:

const client = new OpenAI({ apiKey: 'ak_your_key_here' });

Claiming your auto-provisioned account

On first run, you'll see a claim URL printed to stderr:

ainative-openai: No API key found — provisioning a free account...
Auto-provisioned! Project: proj_abc123
Claim your account: https://ainative.studio/claim/abc123

Visit the claim URL to set a password and get persistent access.

Migrating from openai

- import OpenAI from 'openai';
+ import OpenAI from 'ainative-openai';

  const client = new OpenAI();
- // Requires OPENAI_API_KEY and costs money
+ // Free Llama/Qwen/DeepSeek — auto-provisions if no key set

  const res = await client.chat.completions.create({
-   model: 'gpt-4',
+   model: 'llama-3.3-70b',
    messages: [{ role: 'user', content: 'Hello!' }]
  });

Async Provisioning

If you need to ensure the API key is ready before making requests:

const client = new OpenAI();
await client.waitForProvisioning();
// Now safe to make requests

MCP Integration

After auto-provisioning, a .mcp.json entry is written so MCP-compatible tools (Claude Code, Cursor, Windsurf) can use your credentials:

{
  "mcpServers": {
    "ainative-openai": {
      "command": "npx",
      "args": ["-y", "ainative-openai"],
      "env": {
        "AINATIVE_API_KEY": "ak_...",
        "AINATIVE_PROJECT_ID": "proj_..."
      }
    }
  }
}

License

MIT

Links