Skip to content

Latest commit

 

History

History
65 lines (51 loc) · 1.32 KB

overview.mdx

File metadata and controls

65 lines (51 loc) · 1.32 KB
title OpenRouter TypeScript SDK
sidebarTitle Overview
description Type-safe TypeScript toolkit for building AI features against 400+ models through OpenRouter.

The OpenRouter TypeScript SDK is a type-safe toolkit for building AI-powered features in any JS or TS runtime, giving you access to 400+ models across providers through a single unified API.

Installation

npm add @openrouter/sdk
pnpm add @openrouter/sdk
bun add @openrouter/sdk
yarn add @openrouter/sdk
This package is published as an ES Module (ESM) only. For applications using CommonJS, use `await import("@openrouter/sdk")` to import and use this package.

Quickstart

import { OpenRouter } from "@openrouter/sdk";

const openRouter = new OpenRouter();

const result = await openRouter.chat.send({
  messages: [
    {
      role: "user",
      content: "Hello, how are you?",
    },
  ],
  model: "openai/gpt-5",
  provider: {
    zdr: true,
    sort: "price",
  },
  stream: true,
});

for await (const chunk of result) {
  console.log(chunk.choices[0].delta.content);
}

API reference

Browse the API reference for each resource in the sidebar. Type definitions for every request, response, model, and operation are linked inline from each resource page.