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

@llm-ports/adapter-vercel

v0.1.0-alpha.20

Published

Vercel AI SDK adapter for llm-ports. Migration path for users already on @ai-sdk/*. Bring your own Vercel-configured models; the adapter handles the LLMPort plumbing.

Readme

@llm-ports/adapter-vercel

Vercel AI SDK adapter for llm-ports. Migration helper for users already using @ai-sdk/*.

Why this adapter exists

If you've already wired your project around @ai-sdk/anthropic, @ai-sdk/openai, etc., you can adopt llm-ports without rewriting that integration. This adapter takes your pre-configured Vercel LanguageModel instances and routes LLMPort calls through Vercel's generateText, streamText, embed, and embedMany helpers. You get cost gating, fallback chains, and capability factories on top of the stack you already have.

For new projects, prefer the direct adapters (@llm-ports/adapter-anthropic, @llm-ports/adapter-openai, @llm-ports/adapter-google) — fewer layers, more control.

Install

pnpm add @llm-ports/core @llm-ports/adapter-vercel ai @ai-sdk/anthropic

Configure

import { anthropic } from "@ai-sdk/anthropic";
import { openai } from "@ai-sdk/openai";
import { createRegistryFromEnv } from "@llm-ports/core";
import { createVercelAdapter } from "@llm-ports/adapter-vercel";

const registry = createRegistryFromEnv({
  adapters: {
    vercel: createVercelAdapter({
      models: {
        "claude-sonnet-4-6": anthropic("claude-sonnet-4-6"),
        "gpt-5": openai("gpt-5"),
      },
      embeddingModels: {
        "text-embedding-3-small": openai.textEmbeddingModel("text-embedding-3-small"),
      },
      // pricing is optional in alpha.8+ — bundled VERCEL_PRICING covers common
      // @ai-sdk/* models. Supply pricingOverrides only for missing entries.
    }),
  },
});

const llm = registry.getPort();

.env:

LLM_PROVIDER_FAST=vercel|claude-sonnet-4-6|cost:50/day
LLM_PROVIDER_GPT=vercel|gpt-5|cost:100/day
LLM_TASK_ROUTE_TRIAGE=fast,gpt

Adapter options

interface VercelAdapterOptions {
  models?: Record<string, LanguageModel>;             // pre-configured @ai-sdk/* instances
  embeddingModels?: Record<string, EmbeddingModel<string>>;
  pricing?: Record<string, ModelPricing>;             // optional; merges over VERCEL_PRICING
  validationStrategy?: ValidationStrategy;
  imageSizeLimitBytes?: number;                       // default 20 MB
  onRetry?: OnRetry;                                  // observability hook
}

Browser execution

This adapter does NOT expose its own dangerouslyAllowBrowser option, because the underlying provider client is constructed by you when you build the LanguageModel instance. For browser execution, pass the SDK's flag at LanguageModel construction time:

import { createOpenAI } from "@ai-sdk/openai";

const openai = createOpenAI({
  apiKey: ephemeralUserKey,
  dangerouslyAllowBrowser: true,        // ← set this on the @ai-sdk/* client
});

const adapter = createVercelAdapter({
  models: { default: openai("gpt-5") },
});

The same pattern applies to @ai-sdk/anthropic (and any other browser-restricted SDK). The adapter-openai and adapter-anthropic packages expose the flag directly because they construct the SDK client internally.

Bundled pricing

VERCEL_PRICING (alpha.8+) covers the common OpenAI / Anthropic / Google models used via @ai-sdk/*. Values mirror the direct adapters' bundled tables. For uncommon @ai-sdk/* providers (LMStudio, OpenRouter, perplexity-ai, custom routes), supply pricing entries yourself.

Supported features

| Feature | Status | |---------|--------| | generateText | ✓ | | generateStructured (Zod schemas) | ✓ (prompted JSON + retry-with-feedback + alpha.5 repair pass) | | streamText | ✓ | | streamStructured (partial JSON) | ✓ (best-effort partial parse) | | runAgent (multi-turn) | ✓ (alpha.8+; via Vercel's native tools + maxSteps loop) | | generateEmbedding / generateEmbeddings | ✓ | | Multimodal content blocks | ✓ (alpha.8+; via Vercel MessagePart[] shape) | | AbortSignal cancellation | ✓ entry + in-flight (alpha.6) |

Content blocks supported

text, image (base64 → data URI; URL → passthrough), audio (base64 → Vercel file part), tool_use, tool_result. Throws for URL-form audio (Vercel routes audio via file-data; pass base64 + mediaType instead).

Cancellation

Full AbortSignal support shipped in 0.1.0-alpha.6. The signal is passed through to Vercel's abortSignal field on generateText / streamText, so controller.abort() cancels the in-flight provider HTTP request (the cancellation propagates from Vercel to the underlying provider SDK). See the Cancellation guide.

Known limitations

  • No reasoning-model headroom-multiplier. Unlike adapter-openai, the Vercel adapter doesn't apply a 10× headroom for OpenAI o-series / gpt-5-nano / Cerebras gpt-oss when called with small maxOutputTokens. The Vercel adapter does retry on finishReason: "length" with empty text + reasoning signal (alpha.1 fix #4), but it doesn't pre-seed the multiplier. Workaround: set maxOutputTokens 5-10× higher than your visible-output budget, or use @llm-ports/adapter-openai directly for reasoning models in v0.1.

When to use this vs the direct adapters

| Scenario | Choose | |---|---| | Already on @ai-sdk/* and want to add llm-ports | This adapter | | New project | adapter-anthropic / adapter-openai / adapter-google directly | | Need full multimodal richness (Anthropic prompt-caching, Gemini context-caching, etc.) | Direct adapters expose those; Vercel abstracts them away |

Reading next