0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

nRouter Quick Start in Practice: Key, Environment Variable, One Request

0
Posted at

Getting to a first working LLM API call with nRouter takes three steps, and each one removes a failure mode teams usually meet later.

Step 1: Create a virtual key

In the nRouter dashboard (app.nrouter.ai), create a virtual API key. If the account balance is empty, add credits first. That is the entire setup on the account side.

Step 2: Set NROUTER_API_KEY

Every example reads the key from the environment:

export NROUTER_API_KEY=<your key>

In PowerShell, use $env:NROUTER_API_KEY. The rule that comes with it: keep the key on your server — never in browser code, never in source control.

Step 3: Send one chat completions request

All examples send the same request to https://api.nrouter.ai/v1/chat/completions, by one of three paths:

  • REST (cURL) — no install; best for testing and scripts.
  • nRouter SDK (TypeScript / Python) — one install; a typed client.
  • OpenAI SDK — keep your existing code; change only the base URL to https://api.nrouter.ai/v1 and the key.

For the first request, the examples use the model value nrouter/auto, which lets nRouter choose the model per request. A specific model can be chosen later from the live model catalog without changing the request shape.

Verify it worked

A successful call returns a chat completion JSON — and the request shows up in the dashboard's request logs within seconds, with the model that answered and the request's exact cost. First call, first log entry, no separate instrumentation step.

Walkthrough: https://nrouter.ai/docs/getting-started/quick-start

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?