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

# Python and TypeScript

> Use the source SDKs or plain HTTP without depending on unpublished packages.

The workbench repository includes a Python SDK and a single-file TypeScript client. They are **not published to PyPI or npm**. If you have repository access, use the sources below; otherwise start with the HTTP [quickstart](/quickstart) and the generated API reference.

## Python

From your local `decisionone-workbench` clone, with Python 3.11 or newer:

```bash theme={null}
python -m pip install -e sdks/python
```

Then run this with `D1_API_KEY` set:

```python theme={null}
import os
from decisionone_sdk import DecisionOne

with DecisionOne("https://console.sqwish.ai", api_key=os.environ["D1_API_KEY"]) as client:
    result = client.decide(
        model="sqwish-d1-core",
        context="Please refund the duplicate charge.",
        decisions=[{"id": "refund", "kind": "binary", "question": "Is a refund requested?"}],
    )
    print(result["decisions"]["refund"]["p_yes"])
```

`AsyncDecisionOne` has the same methods with `async with` and `await`. Close clients so their HTTP connections are released. Responses are typed dictionaries.

## TypeScript

Copy `sdks/typescript/decisionone.ts` from your clone into your application. The client uses the standard `fetch` API without dependencies. This example runs under Node 24:

```typescript theme={null}
import { DecisionOne } from "./decisionone.ts";

const client = new DecisionOne("https://console.sqwish.ai", {
  apiKey: process.env.D1_API_KEY,
});
const result = await client.decide({
  model: "sqwish-d1-core",
  context: "Please refund the duplicate charge.",
  decisions: [{ id: "refund", kind: "binary", question: "Is a refund requested?" }],
});
console.log(result.decisions.refund.p_yes);
```

Use a `.js` import in a project that compiles TypeScript to JavaScript. Wire fields keep their `snake_case` names; TypeScript methods use camelCase.

## Workflows and errors

The clients provide resource groups for datasets, models, fine-tuning, prompt tuning, labelling and accounts. `list` returns one page, `iter` follows cursors, and job `wait` polls to completion. A wait timeout stops waiting, not the server's job.

API failures raise `APIError`, with an HTTP status, code, request ID, retryability and validation details. Failed or cancelled jobs raise `JobFailed` from wait helpers and retain the job document.

The default retry budget is two retries for eligible operations. Supported creates keep one idempotency key within a call. Persist and pass your own `idempotency_key` (Python) or `idempotencyKey` (TypeScript) to survive a process restart. Inference uses a stable operation key too, including retries while waiting for a cold model. Successful replay responses remain available for 24 hours; terminal failed or expired operations are not rerun. Mutations such as model promotion and rollback require their own state checks; see [reliable retries](/examples/reliable-retries).

The backend OpenAPI is the contract. SDK types are convenience views and may not expose every newly added field or endpoint; use HTTP for anything the source client does not yet wrap.
