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

@microfox/ai-provider-openai

v1.3.1

Published

A Wrapped OpenAI Provider for Vercels AI SDK

Readme

Note: This package is deprecated and will no longer be maintained. Please consider using an alternative.

OpenAI Provider for Vercel's AI SDK

This package provides a convenient wrapper for using OpenAI's various models through Vercel's AI SDK.

Installation

npm install @microfox/ai-provider-openai

Usage

Language Models

import { OpenAiProvider } from '@microfox/ai-provider-openai';
import { generateText } from 'ai';

const openai = new OpenAiProvider({
  apiKey: process.env.OPENAI_API_KEY!,
});

const response = await generateText({
  model: openai.languageModel('gpt-4o'),
  prompt: 'Hello, world!',
});

console.log(response);

Image Generation

import { OpenAiProvider } from '@microfox/ai-provider-openai';
import { generateImage } from 'ai';

const openai = new OpenAiProvider({
  apiKey: process.env.OPENAI_API_KEY!,
});

const image = await generateImage({
  model: openai.imageModel('dall-e-3'),
  prompt: 'A serene landscape with mountains and a lake',
  size: '1024x1024',
  quality: 'standard',
  style: 'natural',
});

console.log(image.url);

Speech Generation

import { OpenAiProvider } from '@microfox/ai-provider-openai';
import { generateSpeech } from 'ai';

const openai = new OpenAiProvider({
  apiKey: process.env.OPENAI_API_KEY!,
});

const speech = await generateSpeech({
  model: openai.speechModel('tts-1'),
  input: 'Hello, this is a test of the speech generation.',
  voice: 'alloy',
  responseFormat: 'mp3',
});

// Save the audio file or stream it
console.log(speech.audio);

Audio Transcription

import { OpenAiProvider } from '@microfox/ai-provider-openai';
import { transcribeAudio } from 'ai';

const openai = new OpenAiProvider({
  apiKey: process.env.OPENAI_API_KEY!,
});

const transcription = await transcribeAudio({
  model: openai.transcriptionModel('whisper-1'),
  audio: audioFileBuffer, // Your audio file buffer
  language: 'en',
  responseFormat: 'text',
});

console.log(transcription.text);

Configuration Options

OpenAiProvider Options

interface OpenAiProviderConfig {
  apiKey: string;
  organization?: string;
  baseURL?: string;
}

Model Options

Language Models

  • Available models: 'gpt-4', 'gpt-4-turbo', 'gpt-3.5-turbo'
  • Additional options: temperature, maxTokens, etc.

Image Models

  • Available models: 'dall-e-2', 'dall-e-3'
  • Size options: '256x256', '512x512', '1024x1024'
  • Quality options: 'standard', 'hd'
  • Style options: 'natural', 'vivid'

Speech Models

  • Available models: 'tts-1'
  • Voice options: 'alloy', 'echo', 'fable', 'onyx', 'nova', 'shimmer'
  • Response format options: 'mp3', 'opus', 'aac', 'flac'

Transcription Models

  • Available models: 'whisper-1'
  • Language options: 'en', 'fr', 'de', etc.
  • Response format options: 'text', 'srt', 'vtt', 'json'

Error Handling

The provider includes built-in error handling for common API issues:

try {
  const response = await generateText({
    model: openai.languageModel('gpt-4'),
    prompt: 'Hello, world!',
  });
} catch (error) {
  if (error instanceof OpenAiError) {
    console.error('OpenAI API Error:', error.message);
  }
}

Best Practices

  1. Always store your API key in environment variables
  2. Implement proper error handling
  3. Use appropriate model versions for your use case
  4. Consider rate limits and costs when choosing models
  5. Implement proper caching strategies for production use

License

MIT