# SDK quickstart for TypeScript

> Install the typed Agent Router TypeScript SDK from the local pack and make a first read-only identity (whoami) call against the gateway.

# SDK quickstart for TypeScript

  This quickstart installs the typed Agent Router SDK for TypeScript, then makes a first read-only identity lookup (whoami) against the gateway. The lookup resolves the identity behind an API key with a <code>GET /v1/me</code> call and is safe to run as-is, so it confirms that the SDK, the key, and the base URL are wired together correctly before any billable request is sent.

## Prerequisites

Two values and a runtime are required before starting:

- **An Agent Router API key.** Keys are minted in the Console or with the `tare` CLI. The secret is shown once, in the form `<keyid>.<secret>`, so it must be copied immediately. See [Make an API call](/agent-router-service/quickstarts/make-an-api-call) for the key-minting steps.
- **The gateway base URL** for the deployment, in the form `https://api.<your-domain>`. For the hosted service this is `https://api.tetrate.ai`.
- **Node.js 18 or later**, which provides the `npm` and `npx` commands used below.

The SDK reads both values from the environment:

```bash
export AGENTROUTER_BASE_URL=https://api.<your-domain>
export AGENTROUTER_API_KEY=<keyid>.<secret>
```

## Install the SDK

The TypeScript SDK is distributed as an npm pack (`.tgz`) from the public stable channel and is recorded as a local `file:` dependency rather than installed from the public npm registry. Replace `<version>` with the version shown on the [SDKs](/reference/sdk/) page.

Download the pack into the project directory:

```bash
curl -fLO https://tare.tetrate.ai/tools/sdks/stable/agentrouter-typescript-<version>.tgz
```

Create `package.json` and `tsconfig.json` alongside it. The SDK is referenced as a `file:` dependency, and `tsx` is included to run the example without a separate build step:

```json title="package.json"
{
  "name": "agentrouter-quickstart",
  "version": "0.1.0",
  "private": true,
  "type": "module",
  "dependencies": {
    "@tetrate/agentrouter-sdk": "file:agentrouter-typescript-<version>.tgz"
  },
  "devDependencies": {
    "@types/node": "^20.0.0",
    "tsx": "^4.0.0",
    "typescript": "^5.4.0"
  }
}
```

```json title="tsconfig.json"
{
  "compilerOptions": {
    "target": "ES2020",
    "module": "ESNext",
    "moduleResolution": "bundler",
    "strict": true,
    "esModuleInterop": true,
    "skipLibCheck": true
  }
}
```

Install the dependencies:

```bash
npm install
```

## Make the first call

Save the program below as `index.ts`. It constructs a client from the two environment variables, calls `client.me.get()` (the read-only `GET /v1/me` endpoint), and prints the resolved identity.

```typescript title="index.ts"
// Runnable example for the Agent Router TypeScript SDK.
// Set AGENTROUTER_BASE_URL and AGENTROUTER_API_KEY in the environment, then run `npx tsx index.ts`.
import { Client } from '@tetrate/agentrouter-sdk'

const client = new Client({
  baseUrl: process.env.AGENTROUTER_BASE_URL,
  apiKey: process.env.AGENTROUTER_API_KEY,
})

try {
  const result = await client.me.get()
  console.log(result)
} catch (err) {
  console.error('Error:', err)
}
```

Run the program from the project directory:

```bash
npx tsx index.ts
```

A successful run prints the identity associated with the API key. Because `GET /v1/me` only reads identity metadata, the call incurs no model usage and can be repeated freely while verifying setup.

Related references

  <Link to="/reference/sdk/" className="tare-nav-card">
    SDK Reference
    Download the SDK archives and API specifications, with versions and checksums.
  </Link>
  <Link to="/agent-router-service/quickstarts/make-an-api-call" className="tare-nav-card">
    Make an API call
    Mint a key with the tare CLI and make a first routed request across languages.
  </Link>
  <Link to="/reference/api/" className="tare-nav-card">
    Management API reference
    The HTTP endpoints the SDK calls, including the identity and inference APIs.
  </Link>
