AI Gateways
One object knows where AI requests go and how to sign them. Agents, Choices, and your routes share it.
server/api/answer.get.ts
import { generateText } from 'ai'
import { defineEventHandler } from 'h3'
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')
export default defineEventHandler(async () => {
const { text } = await generateText({ model, prompt: 'What is a Server Primitive?' })
return { text }
})Use it with the AI SDK
languageModel() returns an AI SDK model that sends its requests through the gateway.Route Codex and Claude Code
Set
driver.gateway, and the Agent Driver sends its model requests through your proxy.Typed data from one call
ask(prompt, { model, schema }) returns data that your schema checked, without an Agent. Without schema, it returns text.