> ## Documentation Index
> Fetch the complete documentation index at: https://docs.reygrid.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> From npm install to your first ReyGrid chat reply with the TypeScript SDK.

<Steps>
  <Step title="Install">
    ```bash theme={"system"}
    npm install reygrid
    ```
  </Step>

  <Step title="Create the client">
    ```typescript theme={"system"}
    import { ReyGrid } from "reygrid";

    const client = new ReyGrid({ apiKey: process.env.REYGRID_API_KEY });
    ```
  </Step>

  <Step title="Check the API and your key">
    ```typescript theme={"system"}
    const { status } = await client.ping();
    console.log("API status:", status); // "UP"

    const usage = await client.getUsage();
    console.log(`Usage: ${usage.total} / ${usage.quotaLimit}`);
    ```
  </Step>

  <Step title="Chat with an agent">
    ```typescript theme={"system"}
    const res = await client.chat("{AgentId}", "Hello!", { userId: "user-42" });
    console.log(res.output.reply.content);
    ```
  </Step>
</Steps>

## Complete example

Save as `index.mjs` (or use ESM in your project) and run `node index.mjs`:

```typescript theme={"system"}
import { ReyGrid, ReyGridAuthError, ReyGridNetworkError } from "reygrid";

const client = new ReyGrid({ apiKey: process.env.REYGRID_API_KEY });

try {
  const usage = await client.getUsage();
  console.log(`Usage: ${usage.total} / ${usage.quotaLimit}`);

  const res = await client.chat("{AgentId}", "Hello!", { userId: "user-42" });
  console.log(res.output.reply.content);
} catch (err) {
  if (err instanceof ReyGridAuthError) console.error("Invalid API key");
  else if (err instanceof ReyGridNetworkError) console.error("Network problem:", err.message);
  else throw err;
}
```

<CardGroup cols={2}>
  <Card title="Usage" icon="book" href="/integrations/typescript/usage">Every client method.</Card>
  <Card title="Streaming" icon="bolt" href="/integrations/typescript/streaming">Stream replies with SSE.</Card>
</CardGroup>


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.