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

@runpod/ai-sdk-provider

v0.11.1

Published

The **Runpod provider** for the [AI SDK](https://ai-sdk.dev/docs) contains language model and image generation support for [Runpod's](https://runpod.io) public endpoints.

Readme

Runpod AI SDK Provider

The Runpod provider for the AI SDK contains language model and image generation support for Runpod's public endpoints.

Setup

The Runpod provider is available in the @runpod/ai-sdk-provider module. You can install it with:

# npm
npm install @runpod/ai-sdk-provider

# pnpm
pnpm add @runpod/ai-sdk-provider

# yarn
yarn add @runpod/ai-sdk-provider

# bun
bun add @runpod/ai-sdk-provider

Provider Instance

You can import the default provider instance runpod from @runpod/ai-sdk-provider:

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

If you need a customized setup, you can import createRunpod and create a provider instance with your settings:

import { createRunpod } from '@runpod/ai-sdk-provider';

const runpod = createRunpod({
  apiKey: 'your-api-key', // optional, defaults to RUNPOD_API_KEY environment variable
  baseURL: 'custom-url', // optional, for custom endpoints
  headers: {
    /* custom headers */
  }, // optional
});

You can use the following optional settings to customize the Runpod provider instance:

  • baseURL string

    Use a different URL prefix for API calls, e.g. to use proxy servers or custom endpoints. Supports vLLM deployments, SGLang servers, and any OpenAI-compatible API. The default prefix is https://api.runpod.ai/v2.

  • apiKey string

    API key that is being sent using the Authorization header. It defaults to the RUNPOD_API_KEY environment variable. You can obtain your api key from the Runpod Console under "API Keys".

  • headers Record<string,string>

    Custom headers to include in the requests.

  • fetch (input: RequestInfo, init?: RequestInit) => Promise<Response>

    Custom fetch implementation. You can use it as a middleware to intercept requests, or to provide a custom fetch implementation for e.g. testing.

Language Models

You can create language models using the provider instance. The first argument is the model ID:

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

const { text } = await generateText({
  model: runpod('qwen/qwen3-32b-awq'),
  prompt: 'What is the capital of Germany?',
});

Returns:

  • text - Generated text string
  • finishReason - Why generation stopped ('stop', 'length', etc.)
  • usage - Token usage information (prompt, completion, total tokens)

Streaming

import { runpod } from '@runpod/ai-sdk-provider';
import { streamText } from 'ai';

const { textStream } = await streamText({
  model: runpod('qwen/qwen3-32b-awq'),
  prompt:
    'Write a short poem about artificial intelligence in exactly 4 lines.',
  temperature: 0.7,
});

for await (const delta of textStream) {
  process.stdout.write(delta);
}

Model Capabilities

| Model ID | Description | Streaming | Object Generation | Tool Usage | Reasoning Notes | | --------------------------------- | ------------------------------------------------------------------- | --------- | ----------------- | ---------- | ------------------------- | | qwen/qwen3-32b-awq | 32B parameter multilingual model with strong reasoning capabilities | ✅ | ❌ | ✅ | Standard reasoning events | | openai/gpt-oss-120b | 120B parameter open-source GPT model | ✅ | ❌ | ✅ | Standard reasoning events | | deepcogito/cogito-671b-v2.1-fp8 | 671B parameter Cogito model with FP8 quantization | ✅ | ❌ | ✅ | Standard reasoning events |

Note: This list is not complete. For a full list of all available models, see the Runpod Public Endpoint Reference.

Chat Conversations

const { text } = await generateText({
  model: runpod('qwen/qwen3-32b-awq'),
  messages: [
    { role: 'system', content: 'You are a helpful assistant.' },
    { role: 'user', content: 'What is the capital of France?' },
  ],
});

Tool Calling

import { generateText, tool } from 'ai';
import { z } from 'zod';

const { text, toolCalls } = await generateText({
  model: runpod('openai/gpt-oss-120b'),
  prompt: 'What is the weather like in San Francisco?',
  tools: {
    getWeather: tool({
      description: 'Get weather information for a city',
      inputSchema: z.object({
        city: z.string().describe('The city name'),
      }),
      execute: async ({ city }) => {
        return `The weather in ${city} is sunny.`;
      },
    }),
  },
});

Additional Returns:

  • toolCalls - Array of tool calls made by the model
  • toolResults - Results from executed tools

Structured output

Using generateObject to enforce structured ouput is not supported by two models that are part of this provider.

You can still return structured data by instructing the model to return JSON and validating it yourself.

import { runpod } from '@runpod/ai-sdk-provider';
import { generateText } from 'ai';
import { z } from 'zod';

const RecipeSchema = z.object({
  name: z.string(),
  ingredients: z.array(z.string()),
  steps: z.array(z.string()),
});

const { text } = await generateText({
  model: runpod('qwen/qwen3-32b-awq'),
  messages: [
    {
      role: 'system',
      content:
        'return ONLY valid JSON matching { name: string; ingredients: string[]; steps: string[] }',
    },
    { role: 'user', content: 'generate a lasagna recipe.' },
  ],
  temperature: 0,
});

const parsed = JSON.parse(text);
const result = RecipeSchema.safeParse(parsed);

if (!result.success) {
  // handle invalid JSON shape
}

console.log(result.success ? result.data : parsed);

Image Models

You can create Runpod image models using the .imageModel() factory method.

Basic Usage

import { runpod } from '@runpod/ai-sdk-provider';
import { experimental_generateImage as generateImage } from 'ai';

const { image } = await generateImage({
  model: runpod.imageModel('qwen/qwen-image'),
  prompt: 'A serene mountain landscape at sunset',
  aspectRatio: '4:3',
});

// Save to filesystem
import { writeFileSync } from 'fs';
writeFileSync('landscape.jpg', image.uint8Array);

Returns:

  • image.uint8Array - Binary image data (efficient for processing/saving)
  • image.base64 - Base64 encoded string (for web display)
  • image.mediaType - MIME type ('image/jpeg' or 'image/png')
  • warnings - Array of any warnings about unsupported parameters

Model Capabilities

| Model ID | Description | Supported Aspect Ratios | | -------------------------------------- | ------------------------------- | ------------------------------------- | | bytedance/seedream-3.0 | Advanced text-to-image model | 1:1, 4:3, 3:4 | | bytedance/seedream-4.0 | Text-to-image (v4) | 1:1 (supports 1024, 2048, 4096) | | bytedance/seedream-4.0-edit | Image editing (v4, multi-image) | 1:1 (supports 1024, 1536, 2048, 4096) | | black-forest-labs/flux-1-schnell | Fast image generation (4 steps) | 1:1, 4:3, 3:4 | | black-forest-labs/flux-1-dev | High-quality image generation | 1:1, 4:3, 3:4 | | black-forest-labs/flux-1-kontext-dev | Context-aware image generation | 1:1, 4:3, 3:4 | | qwen/qwen-image | Text-to-image generation | 1:1, 4:3, 3:4 | | qwen/qwen-image-edit | Image editing (prompt-guided) | 1:1, 4:3, 3:4 | | nano-banana-edit | Image editing (multi-image) | 1:1, 4:3, 3:4 | | google/nano-banana-pro-edit | Image editing (Gemini-powered) | Uses resolution param (1k, 2k) | | pruna/p-image-t2i | Pruna text-to-image | 1:1, 16:9, 9:16, 4:3, 3:4, etc. | | pruna/p-image-edit | Pruna image editing | match_input_image, 1:1, 16:9, etc. |

Note: The provider uses strict validation for image parameters. Unsupported aspect ratios (like 16:9, 9:16, 3:2, 2:3) will throw an InvalidArgumentError with a clear message about supported alternatives.

Note: This list is not complete. For a full list of all available models, see the Runpod Public Endpoint Reference.

Advanced Parameters

const { image } = await generateImage({
  model: runpod.imageModel('bytedance/seedream-3.0'),
  prompt: 'A sunset over mountains',
  size: '1328x1328',
  seed: 42,
  providerOptions: {
    runpod: {
      negative_prompt: 'blurry, low quality',
      enable_safety_checker: true,
    },
  },
});

Modify Image

Transform existing images using text prompts.

// Example: Transform existing image
const { image } = await generateImage({
  model: runpod.imageModel('black-forest-labs/flux-1-kontext-dev'),
  prompt: 'Transform this into a cyberpunk style with neon lights',
  aspectRatio: '1:1',
  providerOptions: {
    runpod: {
      image: 'https://example.com/input-image.jpg',
    },
  },
});

// Example: Using base64 encoded image
const { image } = await generateImage({
  model: runpod.imageModel('black-forest-labs/flux-1-kontext-dev'),
  prompt: 'Make this image look like a painting',
  providerOptions: {
    runpod: {
      image: 'data:image/png;base64,iVBORw0KGgoAAAANS...',
    },
  },
});
// Example: Combine multiple images using Nano Banana edit
const { image } = await generateImage({
  model: runpod.imageModel('nano-banana-edit'),
  prompt:
    'Combine these four images into a single realistic 3D character scene.',
  // Defaults to 1:1; you can also set size: '1328x1328' or aspectRatio: '4:3'
  providerOptions: {
    runpod: {
      images: [
        'https://image.runpod.ai/uploads/0bz_xzhuLq/a2166199-5bd5-496b-b9ab-a8bae3f73bdc.jpg',
        'https://image.runpod.ai/uploads/Yw86rhY6xi/2ff8435f-f416-4096-9a4d-2f8c838b2d53.jpg',
        'https://image.runpod.ai/uploads/bpCCX9zLY8/3bc27605-6f9a-40ad-83e9-c29bed45fed9.jpg',
        'https://image.runpod.ai/uploads/LPHEY6pyHp/f950ceb8-fafa-4800-bdf1-fd3fd684d843.jpg',
      ],
      enable_safety_checker: true,
    },
  },
});

Check out our examples for more code snippets on how to use all the different models.

Advanced Configuration

// Full control over generation parameters
const { image } = await generateImage({
  model: runpod.imageModel('black-forest-labs/flux-1-dev'),
  prompt: 'A majestic dragon breathing fire in a medieval castle',
  size: '1328x1328',
  seed: 42, // For reproducible results
  providerOptions: {
    runpod: {
      negative_prompt: 'blurry, low quality, distorted, ugly, bad anatomy',
      enable_safety_checker: true,
      num_inference_steps: 50, // Higher quality (default: 28)
      guidance: 3.5, // Stronger prompt adherence (default: 2)
      output_format: 'png', // High quality format
      // Polling settings for long generations
      maxPollAttempts: 30,
      pollIntervalMillis: 4000,
    },
  },
});

// Fast generation with minimal steps
const { image } = await generateImage({
  model: runpod.imageModel('black-forest-labs/flux-1-schnell'),
  prompt: 'A simple red apple',
  aspectRatio: '1:1',
  providerOptions: {
    runpod: {
      num_inference_steps: 2, // Even faster (default: 4)
      guidance: 10, // Higher guidance for simple prompts
      output_format: 'jpg', // Smaller file size
    },
  },
});

Provider Options

Runpod image models support flexible provider options through the providerOptions.runpod object:

| Option | Type | Default | Description | | ------------------------ | ---------- | ------- | ------------------------------------------------------------------------ | | negative_prompt | string | "" | Text describing what you don't want in the image | | enable_safety_checker | boolean | true | Enable content safety filtering | | disable_safety_checker | boolean | false | Disable safety checker (Pruna models) | | image | string | - | Single input image: URL or base64 data URI (Flux Kontext) | | images | string[] | - | Multiple input images (e.g., for nano-banana-edit multi-image editing) | | aspect_ratio | string | "1:1" | Aspect ratio string (Pruna: "16:9", "match_input_image", etc.) | | resolution | string | "1k" | Output resolution (Nano Banana Pro: "1k", "2k") | | num_inference_steps | number | Auto | Number of denoising steps (Flux: 4 for schnell, 28 for others) | | guidance | number | Auto | Guidance scale for prompt adherence (Flux: 7 for schnell, 2 for others) | | output_format | string | "png" | Output image format ("png", "jpg", or "jpeg") | | enable_base64_output | boolean | false | Return base64 instead of URL (Nano Banana Pro) | | enable_sync_mode | boolean | false | Enable synchronous mode (some models) | | maxPollAttempts | number | 60 | Maximum polling attempts for async generation | | pollIntervalMillis | number | 5000 | Polling interval in milliseconds (5 seconds) |

About Runpod

Runpod is the foundation for developers to build, deploy, and scale custom AI systems.

Beyond some of the public endpoints you've seen above (+ more generative media APIs), Runpod offers private serverless endpoints / pods / instant clusters, so that you can train, fine-tune or run any open-source or private model on your terms.