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

# Quickstart

> Make your first AskWithAI decision in minutes using the TypeScript SDK, CLI, or Decision API, and adopt safely with parity and shadow modes.

Get a working Decision Runtime wired into your app or agent in a few minutes. You can start with the TypeScript SDK, the `askwithai` CLI, or a plain HTTP call to the Decision API.

> [!TIP]
>
> **Using an AI coding agent?** You can let Claude Code, Cursor, or Codex set this up for you. See [Connect your agent](https://docs.askwith.ai/connect-your-agent.md) to install the AskWithAI skills with `npx skills add https://docs.askwith.ai`.

## Make your first decision

**1. Create an API key**

Sign in to the [AskWithAI Platform](https://askwith.ai), create a workspace (or start from the **Payment Refund** template in the guided start), and generate an API key in **Settings → API keys**.

Export it in your shell or `.env.local` file:

```bash theme={null}
export ASKWITHAI_API_KEY="wai_..."
```

> [!NOTE]
>
> Keep your API key on the server. Never commit it to Git or ship it in client-side browser code.

**2. Install the SDK (optional for HTTP)**

If you use TypeScript or JavaScript (Node.js 22+), install `@askwithai/sdk` — it includes both the typed client and the `askwithai` CLI:

```bash pnpm theme={null}
pnpm add @askwithai/sdk
```

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

```bash yarn theme={null}
yarn add @askwithai/sdk
```

**3. Call your Decision Runtime**

Ask your runtime for a decision on a sample refund request:

> [tab] TypeScript SDK
>
> ```ts theme={null}
> import { AskWithAI, createDecision, formatReceipt } from "@askwithai/sdk";
> import { z } from "zod";
>
> const askwithai = new AskWithAI({
>   apiKey: process.env.ASKWITHAI_API_KEY!,
> });
>
> const checkRefund = createDecision(askwithai, {
>   runtime: "acme/payment-refund",
>   schema: z.object({
>     approve_refund: z.enum(["approve", "deny"]),
>   }),
> });
>
> const { answers, decision } = await checkRefund(
>   {
>     order_id: "ord-10",
>     item: "27-inch 4K monitor",
>     amount: 240,
>     days_since_purchase: 34,
>     reason: "Factory defect: power supply failed under 1-year warranty.",
>   },
>   { idempotencyKey: "ord-10" }
> );
>
> console.log("Answer:", answers.approve_refund);
> console.log(formatReceipt(decision).join("\n"));
> ```

> [tab] CLI
>
> ```bash theme={null}
> npx askwithai decide acme/payment-refund \
>   --input '{"order_id":"ord-10","item":"27-inch 4K monitor","amount":240,"days_since_purchase":34,"reason":"Factory defect: power supply failed under 1-year warranty."}'
> ```

> [tab] cURL (Decision API)
>
> ```bash theme={null}
> curl -s "https://api.askwith.ai/v1/decide/acme/payment-refund" \
>   -H "Authorization: Bearer $ASKWITHAI_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "input": {
>       "order_id": "ord-10",
>       "item": "27-inch 4K monitor",
>       "amount": 240,
>       "days_since_purchase": 34,
>       "reason": "Factory defect: power supply failed under 1-year warranty."
>     }
>   }'
> ```

**4. Report the real outcome later**

Once you know what actually happened (for example, a return was verified or a chargeback arrived), report the outcome back to AskWithAI. Real outcomes become verified test cases that improve future versions of your runtime.

```ts TypeScript SDK theme={null}
await askwithai.reportOutcome(decision.id, {
  labels: { approve_refund: "approve" },
});
```

```bash CLI theme={null}
npx askwithai outcome <decisionId> --labels '{"approve_refund":"approve"}'
```

## Roll out safely with serving modes

You never have to switch production traffic to routed decisions overnight. Every Decision Runtime supports three **serving modes** so you can verify behavior before it changes a single live answer.

> [card] 1. Parity mode
>
> Returns your fast model's answer unchanged while recording every call and receipt. Zero behavioral change for your users.

> [card] 2. Shadow mode
>
> Still returns the parity answer to your app, while AskWithAI runs full routing in the background so you can compare what it would have done.

> [card] 3. Active mode
>
> Serves routed decisions live — fast answers for routine cases, automatic second opinions when expected mistake cost is high.

Switch modes from the Platform or in one command with the CLI:

```bash theme={null}
npx askwithai mode acme/payment-refund shadow
# Once shadow comparisons look good:
npx askwithai mode acme/payment-refund active
```


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