Wiro AI Open Source

Wiro AI open source / LLM gateway and SDKs

Wiro-LLM

Wiro AI provider for the Vercel AI SDK, with examples for the Wiro LLM gateway (OpenAI and Anthropic compatible)

View on GitHub Docs

Wiro AI

Wiro AI provider for the AI SDK

Use Wiro AI models from the Vercel AI SDK: chat on the Wiro LLM gateway, plus image, speech, transcription and video models, and see what each call cost.

npm AI SDK 7 Node.js 22+ License: MIT

Website · LLM gateway · Models · Docs · Dashboard

Wiro AI runs 1,000+ AI models behind one API and one project key. @wiro-ai/wiro-llm brings them into the AI SDK:

Chat calls go to the gateway's OpenAI-compatible endpoint, https://llm.wiro.ai/v1. Image, speech, transcription and video calls go to the Wiro Run API: the provider starts a task, waits for it and downloads the result. Every result tells you what the call cost, in providerMetadata.wiro, and calls are paid from your Wiro wallet.

Install

npm install @wiro-ai/wiro-llm ai zod

The package needs Node.js 22 or later, the same as AI SDK 7. zod is used for tool inputs and structured output.

Create a project at wiro.ai/panel/project/new and put its credential in WIRO_API_KEY: the API key for an API Key Only project, or API_KEY:API_SECRET (both values joined with a colon) for a Signature project. For a Signature project, image, speech, transcription and video calls sign every request with the secret, and the secret itself is never sent. Call Wiro from server code so the key never reaches a browser.

export WIRO_API_KEY=your-api-key

Quick start

import { wiro } from '@wiro-ai/wiro-llm';
import { generateText } from 'ai';

const { text } = await generateText({
  model: wiro('openai/gpt-5-4-nano'),
  prompt: 'Explain what an API gateway does in one sentence.',
});

console.log(text);

wiro(modelId), wiro.chatModel(modelId) and wiro.languageModel(modelId) return the same chat model. On reasoning models, maxOutputTokens covers the reasoning as well as the answer, so leave room if you set it. If a reply comes back empty with finishReason length, raise it or lower the reasoning effort.

Settings

createWiro() makes a provider with your own settings. The default wiro instance is createWiro() with no options.

import { createWiro } from '@wiro-ai/wiro-llm';

const wiro = createWiro({
  apiKey: process.env.MY_WIRO_KEY,
});
Option Default What it does
apiKey WIRO_API_KEY Your project credential. Use API_KEY:API_SECRET for a Signature project.
baseURL https://llm.wiro.ai/v1 The LLM gateway URL, for chat models.
runBaseURL https://api.wiro.ai/v1 The Run API URL, for image, speech, transcription and video models.
poll see Tasks How image, speech and transcription calls wait for their task: intervalMs between checks and timeoutMs in all.
headers none Extra headers to send with every request.
fetch globalThis.fetch Your own fetch function, for example to log requests or in tests.

The key is read when a request is made, so importing wiro before WIRO_API_KEY is set is fine.

Streaming

import { streamText } from 'ai';

const result = streamText({
  model: wiro('deepseek/v4-1-flash'),
  prompt: 'Write a two-line poem about routing requests.',
});

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

console.log(await result.usage);

When a model thinks before it answers, its reasoning comes separately in reasoningText, and the token counts arrive at the end of the stream.

Tools

The model calls a tool, the AI SDK runs execute and sends the result back, and the model writes the answer. stopWhen caps the number of steps.

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

const { text } = await generateText({
  model: wiro('openai/gpt-5-4-nano'),
  tools: {
    getWeather: tool({
      description: 'Get the current weather for a city',
      inputSchema: z.object({ city: z.string() }),
      execute: async ({ city }) => ({ city, temperatureC: 21 }),
    }),
  },
  stopWhen: isStepCount(3),
  prompt: 'What is the weather in Istanbul right now?',
});

Structured output

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

const { output } = await generateText({
  model: wiro('openai/gpt-5-4-nano'),
  output: Output.object({
    schema: z.object({ name: z.string(), country: z.string(), population: z.number() }),
  }),
  prompt: 'Give me the largest city in Turkey.',
});

The schema goes to the model as response_format of type json_schema. GET /v1/models lists the structured output modes of each model under capabilities.structured_output_modes.

Reasoning effort

providerOptions.wiro.reasoningEffort is sent as reasoning_effort:

const { text } = await generateText({
  model: wiro('openai/gpt-5-4-nano'),
  providerOptions: { wiro: { reasoningEffort: 'low' } },
  prompt: 'Is 97 a prime number? Answer yes or no.',
});

Use it with models that list reasoning_effort in their supported_parameters. The AI SDK's own reasoning option, such as reasoning: 'low', sends the same field. Keys under providerOptions.wiro that the AI SDK does not know, such as parallel_tool_calls: false, are added to the request body as they are.

Cost

Each response carries the amount the call was billed, in USD, and the provider puts it in providerMetadata.wiro.cost:

const result = await generateText({
  model: wiro('openai/gpt-5-4-nano'),
  prompt: 'Explain what an API gateway does in one sentence.',
});

console.log(result.providerMetadata?.wiro?.cost); // for example 0.0000482

With streamText, read it once the stream has finished: (await result.providerMetadata)?.wiro?.cost.

A call with tools can take several steps, and each step is a request with its own cost. Add them up for the total:

const total = result.steps.reduce(
  (sum, step) => sum + Number(step.providerMetadata?.wiro?.cost ?? 0),
  0,
);

Images

import { writeFile } from 'node:fs/promises';
import { wiro } from '@wiro-ai/wiro-llm';
import { generateImage } from 'ai';

const { image, providerMetadata } = await generateImage({
  model: wiro.image('pruna/p-image'),
  prompt: 'A red lighthouse on a rocky coast at dusk, warm light in the windows',
  aspectRatio: '16:9',
  seed: 42,
});

await writeFile(`lighthouse.${image.mediaType.split('/')[1]}`, image.uint8Array);
console.log(providerMetadata.wiro.images[0]); // { taskId, cost, url, mediaType }

wiro.image(modelId) and wiro.imageModel(modelId) return the same image model. Models name their settings in different ways, such as aspectRatio or ratio, samples or maxImages, width and height or resolution. The provider reads each model's settings from Wiro once and sends n, size, aspectRatio and seed in the form that model takes: a size becomes a width and height, or an aspect ratio and the closest resolution, and an aspect ratio becomes a width and height on models that take those. A value the model does not offer comes back as a warning in warnings, and the model's default is used instead.

With n above 1, a model with an image count setting makes all the images in one task, and other models get one task per image.

Image editing

Pass your pictures in prompt.images to a model that takes input images, such as google/nano-banana, openai/gpt-image-2 or wiro/flux-2-dev:

import { readFile } from 'node:fs/promises';

const { image } = await generateImage({
  model: wiro.image('google/nano-banana'),
  prompt: {
    text: 'Turn this photo into a soft watercolor painting',
    images: [await readFile('photo.jpg')],
  },
});

Images can be bytes, base64 text or URLs. Bytes are uploaded with the run, and URLs go to Wiro as they are, so they must be public. prompt.mask goes to models that take a mask, and a model without a prompt, such as wiro/remove-background, takes prompt: { images: [...] } alone.

Model settings

Every model has settings of its own, listed on its page in the model catalog. Pass them in providerOptions.wiro; they go to the model as they are and win over the settings the provider fills in:

await generateImage({
  model: wiro.image('openai/gpt-image-2'),
  prompt: 'A product photo of a ceramic mug on a linen tablecloth',
  aspectRatio: '3:2',
  providerOptions: { wiro: { quality: 'high', resolution: '2k' } },
});

Required settings you leave out get the default the model shows in the catalog. Model parameters explains the setting types.

Speech

import { writeFile } from 'node:fs/promises';
import { wiro } from '@wiro-ai/wiro-llm';
import { generateSpeech } from 'ai';

const { audio, providerMetadata } = await generateSpeech({
  model: wiro.speech('elevenlabs/eleven-v4-turbo'),
  text: 'Hello from Wiro AI. This sentence was turned into speech.',
  voice: 'alice',
  language: 'en',
  outputFormat: 'mp3',
});

await writeFile('hello.mp3', audio.uint8Array);
console.log(providerMetadata.wiro); // { taskId, cost, elapsedSeconds, url, mediaType }

voice matches a model's voices by ID or by name, so nova picks af_nova on wiro/kokoro-tts. language takes ISO 639-1 codes such as en or tr and matches them to the model's own language list, whether it holds codes, names or letters. outputFormat picks the model's format of that kind (mp3 gives mp3_44100_128 on ElevenLabs models), and instructions and speed go to models that have them.

Transcription

import { readFile } from 'node:fs/promises';
import { wiro } from '@wiro-ai/wiro-llm';
import { transcribe } from 'ai';

const { text, segments, providerMetadata } = await transcribe({
  model: wiro.transcription('openai/whisper-large-v3'),
  audio: await readFile('meeting.mp3'),
});

console.log(text);
console.log(segments); // [{ text, startSecond, endSecond }, ...]

Audio can be bytes, base64 text or a URL. A public URL goes straight to Wiro, which downloads it, so a long recording never passes through your server:

await transcribe({
  model: wiro.transcription('elevenlabs/speech-to-text'),
  audio: new URL('https://example.com/interview.mp3'),
});

segments holds the timings a model writes, and timestampGranularities: ['segment'] turns them on for models with a timestamp setting, such as nvidia/parakeet-tdt-0-6b-v3. Language and speaker settings go in providerOptions.wiro, for example { language: 'English', numSpeakers: 2 } on openai/whisper-large-v3.

Video

import { writeFile } from 'node:fs/promises';
import { wiro } from '@wiro-ai/wiro-llm';
import { experimental_generateVideo as generateVideo } from 'ai';

const { video, providerMetadata } = await generateVideo({
  model: wiro.video('bytedance/seedance-v1-pro-fast'),
  prompt: 'A paper boat drifting on a calm pond, soft morning light',
  resolution: '864x480',
  duration: 5,
});

await writeFile('boat.mp4', video.uint8Array);
console.log(providerMetadata.wiro.videos[0]); // { taskId, cost, url, mediaType }

A start image goes in prompt: { image, text }, and frameImages with a last_frame sets the end frame on models that take one. aspectRatio, resolution, duration, fps, seed and generateAudio go to the model's matching settings: 1280x720 becomes 720p, and a duration the model does not offer becomes the closest one it does, with a warning. inputReferences go to models that take reference images or videos.

Video calls use the AI SDK's start and status flow. poll sets how often the SDK checks the task and how long it waits (every 5 seconds, up to 10 minutes, by default). With webhook, Wiro posts to your URL when the video is done, and the SDK waits for that instead of checking. To start a video in one process and collect it in another, use experimental_startVideo and experimental_getVideoStatus:

import {
  experimental_getVideoStatus as getVideoStatus,
  experimental_startVideo as startVideo,
} from 'ai';

const model = wiro.video('klingai/kling-v2-5-turbo');
const { operation } = await startVideo({ model, prompt: 'A fox walking through fresh snow' });
// Store `operation` ({ taskId, taskToken }) and check it later:
const status = await getVideoStatus(model, { operation });
if (status.status === 'completed') console.log(status.videos[0].url);

Tasks, costs and errors

Image, speech, transcription and video calls run as Wiro tasks, and each result names its task and what it cost, in USD:

Call Task and cost
generateImage providerMetadata.wiro.images[i] has taskId, cost (the image's share of its task), url and mediaType. calls[i].providerMetadata.wiro has each task's taskId, cost and elapsedSeconds.
generateSpeech providerMetadata.wiro has taskId, cost, elapsedSeconds, url and mediaType.
transcribe providerMetadata.wiro has taskId, cost and elapsedSeconds.
experimental_generateVideo providerMetadata.wiro.videos[i] has taskId, cost, url and mediaType.

url is the file on Wiro's CDN, so you can hand a result to another model, such as an image to a video model, without uploading it again.

The provider checks a task every 2 seconds at first, then less often, and waits up to 10 minutes. createWiro({ poll: { intervalMs, timeoutMs } }) changes both for image, speech and transcription calls. abortSignal ends the wait.

A task that ends without a result throws a WiroTaskError with the taskId and a reason: failed, cancelled, timeout, no-output, status or download. A run Wiro refuses, such as one without the prompt a model requires, throws an APICallError with Wiro's reason.

import { WiroTaskError } from '@wiro-ai/wiro-llm';

try {
  await generateImage({ model: wiro.image('pruna/p-image'), prompt: 'A red lighthouse' });
} catch (error) {
  if (WiroTaskError.isInstance(error)) console.log(error.reason, error.taskId);
  else throw error;
}

Models

Model IDs are lowercase owner/model, such as openai/gpt-6-sol, claude/sonnet-5, google/gemini-3-pro, xai/grok-4-5, deepseek/v4-pro or qwen/qwen3-32b. The WiroChatModelId type lists the models the gateway served when this version was published, so your editor can complete them, and any other ID works as well. Browse them in the model catalog or with GET https://llm.wiro.ai/v1/models, which also shows each model's tools, modalities and limits.

Image, speech, transcription and video models use the IDs of the model catalog: browse text to image, image editing, text to speech, speech to text, text to video and image to video. WiroImageModelId, WiroSpeechModelId, WiroTranscriptionModelId and WiroVideoModelId list the catalog's models for autocomplete, and new models work without an update.

Responses and Messages routes

Besides Chat Completions, which this package uses, the gateway serves OpenAI Responses at /v1/responses and Anthropic Messages at /v1/messages. The AI SDK's own providers reach them with the same base URL and key:

import { createAnthropic } from '@ai-sdk/anthropic';
import { createOpenAI } from '@ai-sdk/openai';

const openai = createOpenAI({
  baseURL: 'https://llm.wiro.ai/v1',
  apiKey: process.env.WIRO_API_KEY,
});

const anthropic = createAnthropic({
  baseURL: 'https://llm.wiro.ai/v1',
  apiKey: process.env.WIRO_API_KEY,
});

const viaResponses = openai.responses('openai/gpt-5-4-nano');
const viaMessages = anthropic('claude/sonnet-5');

@ai-sdk/anthropic caps the output at 4,096 tokens for model IDs it does not know, so pass maxOutputTokens for longer answers.

Examples

examples/ has a short, runnable file for each part of this package, and for the other SDKs the gateway works with:

File Shows
ai-sdk.mjs This package with generateText
image.mjs generateImage with an aspect ratio and a seed
image-edit.mjs Image editing from a local picture
speech.mjs generateSpeech with a voice and a language
transcription.mjs transcribe with timings
video.mjs experimental_generateVideo from text, or from a start image
openai-sdk.mjs The OpenAI SDK for JavaScript
openai_sdk.py The OpenAI SDK for Python
anthropic-sdk.mjs The Anthropic SDK for JavaScript, on the Messages route
langchain.mjs LangChain's ChatOpenAI with configuration.baseURL
llamaindex_llm.py LlamaIndex's OpenAILike
pydantic_ai_agent.py Pydantic AI with its OpenAI provider and base_url

Each file starts with the commands to install and run it. npm install in examples/ installs everything the JavaScript ones need.

Documentation

Agent skill

This repository includes an agent skill, wiro-llm, in skills/wiro-llm/SKILL.md. It shows coding agents such as Claude Code and Cursor how to call the Wiro LLM gateway: pick a model, use it from the OpenAI, Anthropic or AI SDK clients, and read what each call cost. Add it to your agent with:

npx skills add wiroai/Wiro-LLM --skill wiro-llm

Development

npm install
npm run lint
npm run typecheck
npm test
npm run build

The tests use a mocked fetch and make no network calls. Two scripts check the built package against the live API, billed to the project behind WIRO_API_KEY, and are not part of CI. scripts/smoke.mjs makes five small chat calls on openai/gpt-5-4-nano, and scripts/smoke-media.mjs runs one image, one speech, one transcription and one video task on low-cost models:

npm run build
WIRO_API_KEY=your-api-key npm run smoke
WIRO_API_KEY=your-api-key npm run smoke:media

node scripts/update-media-model-ids.mjs refreshes the image, speech, transcription and video model ID lists from the public catalog.

Support, terms and privacy

Email support@wiro.ai or open an issue in this repository. Use of Wiro AI through this package is covered by the Wiro AI Terms of Service and Privacy Policy.

More from Wiro AI

Repository What it is
Wiro-Plugin Wiro AI plugin for Cursor, Claude Code, Gemini CLI, Devin, Antigravity and Kiro
Wiro-Skills Agent skills for images, image edits, video, music, speech, transcripts, 3D and model search
Wiro-MCP Official MCP server for Wiro AI, @wiro-ai/wiro-mcp on npm
Wiro-Chromium-Extension Wiro AI extension for Chrome, Edge, Opera and Brave
Wiro-Firefox-Extension Wiro AI add-on for Firefox
Wiro-Safari-Extension Wiro AI extension for Safari on the Mac
Swift-QuickStart WiroKit, the Wiro AI SDK for iOS
Kotlin-QuickStart WiroKit, the Wiro AI SDK for Android
Dart-QuickStart Wiro AI SDK for Dart and Flutter, wiro on pub.dev
ReactNative-QuickStart Wiro AI SDK for React Native and Expo, @wiro-ai/wiro-react-native on npm
Swift-Realtime Realtime voice AI example for iOS
Kotlin-Realtime Realtime voice AI example for Android
Dart-Realtime Realtime voice AI example for Flutter
ReactNative-Realtime Realtime voice AI example for React Native
n8n-nodes-wiro One Wiro AI node for n8n with a searchable model picker, @wiro-ai/n8n-nodes-wiro on npm
Wiro-Dify-Plugin Wiro AI plugins for Dify: the LLM gateway as a model provider, plus image, video, speech and music tools
Wiro-ComfyUI Wiro AI nodes for ComfyUI
Wiro-Hermes Wiro AI plugins for Hermes Agent: image, video, audio and 3D tools, plus the LLM gateway as a model provider
Wiro-Zed Wiro AI MCP server extension for Zed
Wiro-Action GitHub Action for Wiro AI models and the LLM gateway, on the GitHub Marketplace
Wiro-Raycast Wiro AI extension for Raycast: image and video generation, LLM chat and model search
Wiro-WordPress Wiro AI plugin for WordPress: featured images, image edits, alt text, narration and SEO suggestions
Wiro-Obsidian Wiro AI plugin for Obsidian: images, video, speech, music, transcription and text tools
Wiro-Blender Wiro AI add-on for Blender: text to 3D, image to 3D and textures
Wiro-Figma Wiro AI plugin for Figma: images, vectors, image edits and text
Wiro-Next-Starter Next.js starter for Wiro AI: Playground, image, video and audio tools, and LLM chat, ready for Vercel and Railway
Wiro-Docs Source of the Wiro AI API docs
wiroai.github.io Every open-source project from Wiro AI on one page, with a page for each repository

Website · Models · Docs · X

License

MIT, see LICENSE.