{"id":35180949,"url":"https://github.com/openrouterteam/typescript-sdk","last_synced_at":"2026-06-08T22:00:37.653Z","repository":{"id":319147187,"uuid":"1042282551","full_name":"OpenRouterTeam/typescript-sdk","owner":"OpenRouterTeam","description":null,"archived":false,"fork":false,"pushed_at":"2026-06-03T14:58:58.000Z","size":13608,"stargazers_count":201,"open_issues_count":18,"forks_count":54,"subscribers_count":4,"default_branch":"main","last_synced_at":"2026-06-03T16:17:39.008Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/OpenRouterTeam.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null}},"created_at":"2025-08-21T19:07:26.000Z","updated_at":"2026-06-02T03:58:14.000Z","dependencies_parsed_at":null,"dependency_job_id":"0c1c2204-bea5-4537-9a06-53f316497d04","html_url":"https://github.com/OpenRouterTeam/typescript-sdk","commit_stats":null,"previous_names":["openrouterteam/typescript-sdk"],"tags_count":158,"template":false,"template_full_name":null,"purl":"pkg:github/OpenRouterTeam/typescript-sdk","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenRouterTeam%2Ftypescript-sdk","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenRouterTeam%2Ftypescript-sdk/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenRouterTeam%2Ftypescript-sdk/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenRouterTeam%2Ftypescript-sdk/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/OpenRouterTeam","download_url":"https://codeload.github.com/OpenRouterTeam/typescript-sdk/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/OpenRouterTeam%2Ftypescript-sdk/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34082130,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-08T02:00:07.615Z","response_time":111,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-12-29T01:49:24.873Z","updated_at":"2026-06-08T22:00:37.631Z","avatar_url":"https://github.com/OpenRouterTeam.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![hero illustration](./assets/banner.png)\n\n# OpenRouter SDK (Beta)\n\nThe [OpenRouter SDK](https://openrouter.ai/docs/sdks/typescript) is a TypeScript toolkit designed to help you build AI-powered features and solutions in any JS or TS based runtime. Giving you easy access to over 300 models across providers in an easy and type-safe way.\n\nTo learn more about how to use the OpenRouter SDK, check out our [API Reference](https://openrouter.ai/docs/sdks/typescript/reference) and [Documentation](https://openrouter.ai/docs/sdks/typescript).\n\n\u003c!-- No Summary [summary] --\u003e\n\n\u003c!-- No Table of Contents [toc] --\u003e\n\n\u003c!-- Start SDK Installation [installation] --\u003e\n## SDK Installation\n\nThe SDK can be installed with either [npm](https://www.npmjs.com/), [pnpm](https://pnpm.io/), [bun](https://bun.sh/) or [yarn](https://classic.yarnpkg.com/en/) package managers.\n\n### NPM\n\n```bash\nnpm add @openrouter/sdk\n```\n\n### PNPM\n\n```bash\npnpm add @openrouter/sdk\n```\n\n### Bun\n\n```bash\nbun add @openrouter/sdk\n```\n\n### Yarn\n\n```bash\nyarn add @openrouter/sdk\n```\n\n\u003e [!NOTE]\n\u003e This package is published as an ES Module (ESM) only. For applications using\n\u003e CommonJS, use `await import(\"@openrouter/sdk\")` to import and use this package.\n\u003c!-- End SDK Installation [installation] --\u003e\n\n## Migrating `callModel` to `@openrouter/agent`\n\n\u003e [!IMPORTANT]\n\u003e `callModel` and its associated types have moved to the [`@openrouter/agent`](https://www.npmjs.com/package/@openrouter/agent) package. If you are using `callModel`, tool definitions, or related types from `@openrouter/sdk`, you should migrate to `@openrouter/agent`.\n\u003e\n\u003e To assist with the migration, run:\n\u003e\n\u003e ```bash\n\u003e npx skills add OpenRouterTeam/skills --skill openrouter-agent-migration\n\u003e ```\n\n\u003c!-- Start Requirements [requirements] --\u003e\n## Requirements\n\nFor supported JavaScript runtimes, please consult [RUNTIMES.md](RUNTIMES.md).\n\u003c!-- End Requirements [requirements] --\u003e\n\n\u003c!-- No SDK Example Usage [usage] --\u003e\n## SDK Usage\n\n```typescript\nimport { OpenRouter } from \"@openrouter/sdk\";\n\nconst openRouter = new OpenRouter();\n\nconst result = await openRouter.chat.send({\n  messages: [\n    {\n      role: \"user\",\n      content: \"Hello, how are you?\",\n    },\n  ],\n  model: \"openai/gpt-5\",\n  provider: {\n    zdr: true,\n    sort: \"price\",\n  },\n  stream: true\n});\n\nfor await (const chunk of result) {\n  console.log(chunk.choices[0].delta.content)\n}\n\n```\n\n\u003c!-- No Authentication [security] --\u003e\n\n\u003c!-- No Available Resources and Operations [operations] --\u003e\n\n\u003c!-- No Standalone functions [standalone-funcs] --\u003e\n\n\u003c!-- No React hooks with TanStack Query [react-query] --\u003e\n\n\u003c!-- No Server-sent event streaming [eventstream] --\u003e\n\n\u003c!-- No Retries [retries] --\u003e\n\n\u003c!-- No Error Handling [errors] --\u003e\n\n\u003c!-- No Server Selection [server] --\u003e\n\n\u003c!-- No Custom HTTP Client [http-client] --\u003e\n\n\u003c!-- Start Pagination [pagination] --\u003e\n## Pagination\n\nSome of the endpoints in this SDK support pagination. To use pagination, you\nmake your SDK calls as usual, but the returned response object will also be an\nasync iterable that can be consumed using the [`for await...of`][for-await-of]\nsyntax.\n\n[for-await-of]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/for-await...of\n\nHere's an example of one such pagination call:\n\n```typescript\nimport { OpenRouter } from \"@openrouter/sdk\";\n\nconst openRouter = new OpenRouter({\n  httpReferer: \"\u003cvalue\u003e\",\n  appTitle: \"\u003cvalue\u003e\",\n  appCategories: \"\u003cvalue\u003e\",\n  apiKey: process.env[\"OPENROUTER_API_KEY\"] ?? \"\",\n});\n\nasync function run() {\n  const result = await openRouter.byok.list();\n\n  for await (const page of result) {\n    console.log(page);\n  }\n}\n\nrun();\n\n```\n\u003c!-- End Pagination [pagination] --\u003e\n\n\u003c!-- Start Debugging [debug] --\u003e\n## Debugging\n\nYou can setup your SDK to emit debug logs for SDK requests and responses.\n\nYou can pass a logger that matches `console`'s interface as an SDK option.\n\n\u003e [!WARNING]\n\u003e Beware that debug logging will reveal secrets, like API tokens in headers, in log messages printed to a console or files. It's recommended to use this feature only during local development and not in production.\n\n```typescript\nimport { OpenRouter } from \"@openrouter/sdk\";\n\nconst sdk = new OpenRouter({ debugLogger: console });\n```\n\nYou can also enable a default debug logger by setting an environment variable `OPENROUTER_DEBUG` to true.\n\u003c!-- End Debugging [debug] --\u003e\n\n\u003c!-- Placeholder for Future Speakeasy SDK Sections --\u003e\n\n# Development\n\n## Running Tests\n\nTo run the test suite, you'll need to set up your environment with an OpenRouter API key.\n\n### Local Development\n\n1. Copy the example environment file:\n\n   ```bash\n   cp .env.example .env\n   ```\n\n2. Edit `.env` and add your OpenRouter API key:\n\n   ```bash\n   OPENROUTER_API_KEY=your_api_key_here\n   ```\n\n3. Run the tests:\n\n   ```bash\n   npx vitest\n   ```\n\n## Maturity\n\nThis SDK is in beta, and there may be breaking changes between versions without a major version update. Therefore, we recommend pinning usage\nto a specific package version. This way, you can install the same version each time without breaking changes unless you are intentionally\nlooking for the latest version.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenrouterteam%2Ftypescript-sdk","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fopenrouterteam%2Ftypescript-sdk","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fopenrouterteam%2Ftypescript-sdk/lists"}