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

@apimaster/ai-sdk-provider

v0.2.1

Published

Vercel AI SDK provider for APIMaster and other OpenAI-compatible gateways, with chat, image and video helpers

Readme

@apimaster/ai-sdk-provider

Vercel AI SDK provider for APIMaster and any other OpenAI-compatible gateway — plus generateVideo, which the AI SDK has no model type for.

npm i @apimaster/ai-sdk-provider ai zod

0.2.x targets AI SDK 7 and needs Node 22 or later. On AI SDK 5, use @apimaster/[email protected].

import { apimaster } from '@apimaster/ai-sdk-provider';
import { generateText } from 'ai';

const { text } = await generateText({
  model: apimaster('gpt-5.5'),
  prompt: 'Why does time to first token matter?',
});

Set APIMASTER_API_KEY in the environment, or pass a key explicitly:

import { createAPIMaster } from '@apimaster/ai-sdk-provider';

const apimaster = createAPIMaster({
  apiKey: process.env.MY_KEY,
  baseURL: 'https://apimaster.ai/v1',   // any OpenAI-compatible gateway
});

What you get

| Call | Backed by | | --- | --- | | apimaster(id) / apimaster.chatModel(id) | @ai-sdk/openai-compatible chat model | | apimaster.completionModel(id) | completion model | | apimaster.embeddingModel(id) | embedding model | | apimaster.imageModel(id) | image model (generateImage from ai) | | apimaster.generateVideo({...}) | submit + poll + MP4 URL |

Chat, completion, embedding and image models come straight from @ai-sdk/openai-compatible. This package deliberately does not reimplement them — it adds the preset base URL, the key lookup, model-id autocomplete, and video.

Streaming, tools, structured output

Everything the AI SDK does works unchanged:

import { streamText, generateObject } from 'ai';
import { z } from 'zod';

const stream = streamText({ model: apimaster('claude-sonnet-4-6'), prompt: 'Count to ten' });
for await (const chunk of stream.textStream) process.stdout.write(chunk);

const { object } = await generateObject({
  model: apimaster('gpt-5.5'),
  schema: z.object({ name: z.string(), age: z.number() }),
  prompt: 'Invent a character',
});

One setting worth getting right

Most models on this gateway are reasoning models: they spend part of the token budget on hidden reasoning before emitting visible text. A tight maxOutputTokens returns an empty string, not a short answer. Measured on one model, a 64-token budget was consumed 59 tokens by reasoning; at 256 it answered correctly. If output is empty, raise the budget before assuming the model is broken.

Images

import { generateImage } from 'ai';

const { image } = await generateImage({
  model: apimaster.imageModel('gpt-image-2'),
  prompt: 'a corgi astronaut on the moon',
  size: '1792x1024',
});

Image generation is slow — a 1K render measured 160 s, and 4K can take ten minutes. Give the request a generous timeout.

Video

const video = await apimaster.generateVideo({
  model: 'seedance-2.5',
  prompt: 'a waterfall forming a rainbow, cinematic',
  durationSeconds: 4,
  aspectRatio: '16:9',
});

console.log(video.url, video.elapsedMs);

Video is slow: seedance-2.5 took about 15 minutes for a 4-second clip, so generateVideo waits up to 30 minutes by default (maxWaitMs).

Image-to-video:

const video = await apimaster.generateVideo({
  prompt: 'slow push-in, hair moving in the breeze',
  referenceImageUrl: 'https://example.com/face.jpg',
  aspectRatio: '9:16',      // always explicit: a portrait reference with no aspect
  download: true,           // ratio is treated as 16:9 and comes back letterboxed
});

await fs.writeFile('clip.mp4', video.bytes!);

The returned URL needs the API key as a bearer token and expires, so download: true is the safer option when you intend to keep the file.

If the job outlives maxWaitMs, the error includes the task id — the job is not lost and you can keep polling GET /v1/videos/{id} yourself.

Model ids

The ids in the types are the ones verified on the default gateway; any other string is accepted, so a model added after this release still works. List what an endpoint serves:

curl -s https://apimaster.ai/v1/models \
  -H "Authorization: Bearer $APIMASTER_API_KEY" | jq -r '.data[].id'

Development

npm install
npm run typecheck
npm run build && npm test

Tests inject a stub fetch, so they need no key, no network and spend nothing.

License

MIT