@vite-hub/gateways weekly downloads statistics
By vite-hub (2 listings) · npm · AI SDKs
One AI gateway object for every consumer: route Codex, Claude Code, the Gemini CLI, and AI SDK models, and ask TypeSafe Jev typed questions, through Vercel AI Gateway, Cloudflare AI Gateway, OpenRouter, LiteLLM, CLIProxyAPI, Ollama, OpenAI, Anthropic, Goo
@vite-hub/gateways has 6,388 recorded weekly downloads on npm, an increase of 295% over the past 30 days, ranking #1438 of 3,247 tracked listings.
About @vite-hub/gateways
@vite-hub/gateways
An AI gateway is one object that knows where AI requests go and how to sign them. A gateway has three capabilities:
- Driver routes. It routes Codex and Claude Code model requests, for example through Vercel AI Gateway or CLIProxyAPI.
- AI SDK models.
languageModel(gateway, modelId)from@vite-hub/gateways/ai-sdkreturns an AI SDK model that sends its requests through the gateway. gateway.ask(). It answers typed TypeSafe Jev questions, such as "which category fits this transaction". Only gateways that can reach Jev haveask().
ask(prompt, { model, schema }) sends one model request and returns typed data that a schema checked. Without schema, it returns the answer text.
The package has no Agent, Vite, or Nitro code. It works in a plain Node script, a Worker, or another framework, and its only dependency is nostics. ViteHub applications import it as vite-hub/gateways. User docs: AI Gateways.
Install
languageModel(), ask(), and gateway.ask() load optional peer dependencies only when you use them. gateway.ask() needs advocaat, the TypeSafe client. languageModel() needs the AI SDK provider package of its model API, usually @ai-sdk/openai-compatible (@ai-sdk/openai with openai()), and ask(prompt, { model, schema }) needs ai:
pnpm add @vite-hub/gateways advocaat
pnpm add @vite-hub/gateways ai @ai-sdk/openai-compatible
Use a model with the AI SDK
import { generateText } from 'ai'
import { openrouter } from '@vite-hub/gateways'
import { languageModel } from '@vite-hub/gateways/ai-sdk'
// Reads OPENROUTER_API_KEY when it sends the request.
const model = languageModel(openrouter(), 'google/gemini-3.8-flash')
const { text } = await generateText({ model, prompt: 'What is a Server Primitive?' })
Change the preset to change the provider. The model ID is the ID that the gateway uses. The api option selects the model API, and the type accepts only the APIs that the gateway serves:
api | Request | URL | Package |
|---|---|---|---|
'chat' | OpenAI Chat Completions | openai-compatible | @ai-sdk/openai-compatible, or @ai-sdk/openai with openai() |
'responses' | OpenAI Responses | openai-compatible, else codex; zai() uses codex | @ai-sdk/openai |
'messages' | Anthropic Messages | claude-code | @ai-sdk/anthropic |
The default is 'chat' when the gateway has an openai-compatible URL, else 'messages', else 'responses'. Use api: 'responses' for OpenAI reasoning models that call tools. The gateway resolves its URL, key, and headers for each request from the values that you passed or from process.env. Pass fetch to use a custom fetch implementation.
Put providerOptions under the gateway name for compatible Chat (such as { openrouter: { ... } }), openai for openai() Chat and Responses, and anthropic for Messages. Compatible Chat passes request fields to the gateway. openai() Chat reads native SDK options and still sends raw Chat Completions fields such as parallel_tool_calls. A raw field takes precedence over its SDK option.
Chat keeps JSON mode for schema output. It adds the JSON schema to the system instructions if you supply them, or to the user message if you do not. ask() validates the result locally and accepts schemas with optional fields. emulate() sends the schema as a structured output instead.
Get typed data from one call
ask(prompt, { model, schema }) sends one request to an AI SDK model and returns the answer that the schema validated, as [error, data]. It needs the ai package. Use languageModel(gateway, modelId) to send it through any gateway:
import { z } from 'zod'
import { ask, openrouter } from '@vite-hub/gateways'
import { languageModel } from '@vite-hub/gateways/ai-sdk'
const [error, receipt] = await ask('MERCADONA 23.10 -34.90 EUR', {
model: languageModel(openrouter(), 'google/gemini-3.8-flash'),
schema: z.object({ merchant: z.string(), amount: z.number() }),
})
if (error) throw error
receipt.merchant // string
schema is a Standard Schema that converts to JSON Schema: Zod 4, ArkType, or Valibot wrapped with toStandardJsonSchema() from @valibot/to-json-schema. Leave out schema to get the answer as a string: const [error, summary] = await ask(log, { model }). Options: instructions (system instructions), signal, and onUsage. error is GATEWAYS_ASK_MODEL_FAILED when the request fails and GATEWAYS_ASK_OUTPUT_INVALID when the answer does not match the schema or has no text. Setup errors, such as a missing key or a schema without JSON Schema, throw. Use an Agent when the model must call tools or keep a conversation.
Ask your first question
Pick the builder by the answer that you want. The answer types come from the questions.
| You want | Write | You get |
|---|---|---|
| Yes or no | ask.if(instructions, { threshold? }) | boolean. true when the probability of yes is above threshold. The default is 0.5. |
| The probability of yes | ask.chance(instructions, { true?, false? }) | { chance }, from 0 to 1. |
| One label | ask.switch(instructions, criteria) | The label, such as 'groceries'. |
| One label, with how sure the model is | ask.choice(instructions, criteria) | { choice, confidence, probabilities }. |
| A rating on an ordered scale | ask.score(instructions, levels) | { score, ratio, confidence, legend, probabilities }, for 2 to 10 levels. |
| The same question for each item of a list | ask.each(items, { key, question }) | One question for each item, under the key that key(item) returns. Pass the map to gateway.ask(), or spread it into your questions. |
For ask.switch() and ask.choice(), criteria maps labels to descriptions, or is a list of 2 to 255 labels.…
Description from the npm listing.
- ai
- ai-gateway
- ai-sdk
- anthropic
- cloudflare
- deepseek
- gateway
- gemini
- glm
- jev
- kimi
- litellm
- llm
- minimax
- ollama
- openai
- openrouter
- qwen
- typesafe
- typescript
README badge
Show your rank in a README or on your website. The badge updates automatically.
Charts
Images: 30d · 1y · all time · 1600×900 dark
Adoption over time
7/30/90-day growth
Ranking history
Listing placement
Listing placement
Filled points are observed values; hollow points come from Internet Archive snapshots of the listing page. Dashed segments span periods with no observations — values between points are not interpolated.
Each band is one page of 20. Weekly downloads on a linear scale. Placement is projected from weekly downloads, so it can differ from the marketplace's own sort order. Hover a dot to see the listing.
Recent observations
Full history (135)Similar npm AI SDKs plugins
All 20 @vite-hub/gateways alternativesData source
Weekly downloads (trailing 7 complete days) come from the official npm downloads API. Downloads include CI and mirrors and are not equivalent to installs or users. npm publishes no ratings.
Listing: https://www.npmjs.com/package/@vite-hub/gateways. First seen Nov 19, 2026; last successful collection Dec 6, 2026. See the methodology.