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

@topthink/ai

v1.0.1

Published

ThinkAI SDK — TypeScript client for the ThinkAI platform

Readme

@topthink/ai

ThinkAI SDK & CLI — TypeScript 客户端,同时提供命令行工具 tai

安装

npm install @topthink/ai

CLI

npm install -g @topthink/ai

支持环境变量 THINKAI_API_KEYTHINKAI_BASE_URL,全局选项可覆盖:

--api-key <key>   API key (or set THINKAI_API_KEY env var)
--base-url <url>  API base URL (or set THINKAI_BASE_URL env var)

tai chat

tai chat --model gpt-4 --message "Hello!"
tai chat --model gpt-4 --system "You are a poet." --message "写首诗" --stream
tai chat --model gpt-4 --message "Hello!" --json

tai image

tai image generations --model dall-e-3 --prompt "A cat" --size 1024x1024
tai image generations --model dall-e-3 --prompt "A cat" --image ./ref.png --out cat.png
tai image generations --model dall-e-3 --prompt "A cat" --n 2 --ratio 16:9 --style vivid

tai audio

tai audio speech --model tts-1 --input "你好世界" --voice alloy --out hello.mp3
tai audio voice --model tts-1

tai music

tai music song --model xxx --prompt "流行摇滚" --lyrics "歌词..." --out song.mp3
tai music bgm --model xxx --prompt "史诗管弦" --duration 60 --out bgm.mp3
tai music query --model xxx --id 123456

tai video

tai video generations --model kling-video-o1 --prompt "A sunset" --out sunset.mp4
tai video generations --model xxx --prompt "..." --first-frame ./start.png --last-frame ./end.png --audio
tai video query --model kling-video-o1 --id 123456 --out result.mp4

tai model

tai model list
tai model list --type chat
tai model show chat gpt-4

SDK

import { Client } from '@topthink/ai';

const client = new Client({
  apiKey: 'sk-xxx',
  baseUrl: 'https://ai.topthink.com',
});

apiKey 和 baseUrl 可省略,自动从 THINKAI_API_KEY / THINKAI_BASE_URL 环境变量读取。

Chat

// 非流式
const result = await client.chat.completions({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello!' }],
});
// result.message.content

// 流式
const stream = await client.chat.completions({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Hello!' }],
  stream: true,
});
for await (const event of stream) {
  console.log(event.delta.content);
}

Image

const result = await client.image.generations({
  model: 'dall-e-3',
  prompt: 'A cat in a spacesuit',
  n: 2,
  size: '1024x1024',
});
// result.images[0].url

Audio

const speech = await client.audio.speech({
  model: 'tts-1',
  input: 'Hello, world!',
  voice: 'alloy',
});
// speech.audio.data (base64)

const voices = await client.audio.voice({ model: 'tts-1' });

Music

const result = await client.music.song({
  model: 'music-2.6',
  prompt: 'A pop rock song',
  lyrics: '[verse] La da dee...',
});
// result.id or result.audios[0].url

const bgm = await client.music.bgm({ model: 'music-2.6', prompt: 'Epic orchestral' });
const task = await client.music.query({ model: 'music-2.6', id: '...' });

Video

const task = await client.video.generations({
  model: 'kling-video-o1',
  prompt: 'A sunset',
});
// task.id

const result = await client.video.query({ model: 'kling-video-o1', id: task.id });
// result.videos[0].url

Model

const models = await client.model.list('chat');
const model = await client.model.get('chat', 'gpt-4');

错误处理

import { Exception } from '@topthink/ai';

try {
  const result = await client.chat.completions({ ... });
} catch (err) {
  if (err instanceof Exception) {
    console.error(err.status, err.message);
  }
}

License

MIT