Menu

Type safety is the feature: notes on nRouter's TypeScript / Node.js SDK
πŸ“°

Type safety is the feature: notes on nRouter's TypeScript / Node.js SDK

DEV Community: typescriptΒ·nRouterΒ·6 days ago
#K3VZfY9A
#devtotypescript#devto#dev#error#client
Reading 0:00
15s threshold

Disclosure: I work on nRouter. This post was drafted with AI assistance and reviewed by me before publishing.

JavaScript SDKs for LLM APIs usually fail in the same place: everything is any until production teaches you otherwise. So when I read our own TypeScript / Node.js SDK guide, the parts I checked first weren't the happy path β€” they were the types, the metadata, and what an error looks like when it lands in a catch block. Here's what the guide actually specifies.

One package, more runtimes than you'd expect

npm install @nrouter_ai/sdk

Enter fullscreen mode

Exit fullscreen mode

The client bindings cover Node.js, Bun, Deno and edge runtimes against the same gateway, https://api.nrouter.ai/v1 . Setup is deliberately boring:

export NROUTER_API_KEY = "sk-nrouter-xxxxxxxxxxxx"

Enter fullscreen mode

Exit fullscreen mode

import { nRouter } from "@nrouter_ai/sdk" ;

// Reads NROUTER_API_KEY and targets https://api.nrouter.ai/v1 const client = new nRouter ( ) ;

const response = await client . chat .…

Continue reading β€” create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.