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

# TypeScript quickstart

> Install @amika/sdk and create your first rig from TypeScript.

The TypeScript SDK wraps the hosted Amika API. This page gets you from
install to a running agent in a few lines.

The source lives in the `amika` repo under
[`sdk/typescript`](https://github.com/gofixpoint/amika/tree/main/sdk/typescript).

## Install

The SDK requires Node 18 or later.

```bash theme={null}
npm install @amika/sdk
```

## Get an API key

Create an Amika API key in the web UI at
[app.amika.dev/settings/api-keys](https://app.amika.dev/settings/api-keys).
From the CLI, `amika auth api-key create --name <name> --out <file>` writes a
new key to a file without printing it.

The SDK does not read the key from your environment automatically. You pass
it to the client.

## Create a client

```ts theme={null}
import { AmikaClient } from "@amika/sdk";

const client = new AmikaClient({ apiKey: process.env.AMIKA_API_KEY! });
```

`baseUrl` is optional and defaults to `https://app.amika.dev`. If you set it,
pass only the origin. The client appends the `/api/v0beta1` prefix for you.

> [!NOTE]
>
> Provide exactly one of `apiKey`, `accessToken`, or `tokenSource`. Use a
> `tokenSource` for tokens that need to be fetched or refreshed. See
> [Token sources](https://docs.amika.dev/sdks/typescript/token-sources.md).

## Create a rig and run an agent

```ts theme={null}
// 1. Create a rig. It returns before setup finishes.
const rig = await client.rigs.create({
  name: "dev-box",
  repoUrl: "https://github.com/your-org/your-repo",
  agentCredentials: [{ kind: "claude" }],
});

// 2. Wait until the rig is running and its setup succeeded.
await rig.wait();

// 3. Send a prompt. The call resolves when the agent turn finishes.
const turn = await rig.send({
  agent: "claude",
  message: "Add unit tests for the auth module",
});
if (turn.isError) throw new Error(turn.response);
console.log(turn.response);

// 4. Tear down.
await rig.delete();
```

`agentCredentials: [{ kind: "claude" }]` asks the server to pick your stored
Claude credential. Omitting `agentCredentials` injects no agent credentials.
See [Inject credentials](https://docs.amika.dev/guides/inject-credentials.md).

An agent failure returns `isError: true` with details in `response`, even when
the HTTP request succeeds. Check it before using the reply.

## Timeouts and polling

* Ordinary requests time out after **30 seconds**.
* Agent sends (`send` and `sendStream`) time out after **10 minutes**.
* `rig.wait()` polls every **3 seconds** with a **15-minute** total deadline.
  It throws `AmikaWaitError` if provisioning or setup fails, or the deadline
  passes. Pass `{ pollMs, maxWaitMs }` to change either.

## Next steps

> [card] [Client reference](https://docs.amika.dev/sdks/typescript/client.md)
>
> Every collection and method on `AmikaClient`.

> [card] [Types](https://docs.amika.dev/sdks/typescript/types.md)
>
> Request and response interfaces.

> [card] [Errors](https://docs.amika.dev/sdks/typescript/errors.md)
>
> `AmikaError`, `AmikaHTTPError`, and `AmikaWaitError`.

> [card] [Token sources](https://docs.amika.dev/sdks/typescript/token-sources.md)
>
> Static keys and custom token providers.


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