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

# SDK

> Thin, typed JavaScript/TypeScript and Python clients for the Levanto Sage decision API.

Official SDKs for JavaScript/TypeScript and Python wrap the [Quickstart](/decision-model/quickstart) HTTP API in a single typed client with matching shortcuts for all five decision kinds.

## Install

<CodeGroup>
  ```bash npm theme={null}
  npm install levanto
  ```

  ```bash pip theme={null}
  pip install levanto
  ```
</CodeGroup>

<Columns cols={2}>
  <Card title="View on npm" icon="npm" horizontal href="https://www.npmjs.com/package/levanto" />

  <Card title="View on PyPI" icon="python" horizontal href="https://pypi.org/project/levanto/" />
</Columns>

JS/TS requires Node 18+ and has zero runtime dependencies (native `fetch`). Python requires 3.9+ and depends on `httpx`.

## Initialize the client

<Tabs>
  <Tab title="JavaScript / TypeScript">
    ```ts theme={null}
    import { LevantoClient, YesNo } from 'levanto';

    const client = new LevantoClient({ apiKey: process.env.LEVANTO_API_KEY! });
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from levanto import LevantoClient, YesNo

    client = LevantoClient(api_key="lv_live_...")
    ```
  </Tab>
</Tabs>

Need a key? See [Authentication](/decision-model/authentication).

## Make a decision

<Tabs>
  <Tab title="JavaScript / TypeScript">
    ```ts theme={null}
    const doc = 'Marketing email: "Risk-free, guaranteed 40% returns for accredited investors."';

    // One decision -> full envelope
    const env = await client.decide(doc, new YesNo('Needs compliance review?'));
    console.log(env.result.answer);        // 'yes' | 'no'
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    doc = 'Marketing email: "Risk-free, guaranteed 40% returns for accredited investors."'

    # One decision -> full envelope
    env = client.decide(doc, YesNo("Needs compliance review?"))
    print(env["result"]["answer"])        # 'yes' | 'no'
    ```
  </Tab>
</Tabs>

## Shortcuts

Each shortcut builds the matching question, makes one single decision, and returns just the result payload.

<Tabs>
  <Tab title="JavaScript / TypeScript">
    ```ts theme={null}
    const r = await client.yesno(doc, 'Needs compliance review?');
    console.log(r.probability, r.confidence, r.answer);
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    r = client.yesno(doc, "Needs compliance review?")
    print(r["probability"], r["confidence"], r["answer"])
    ```
  </Tab>
</Tabs>

## Batch requests

One document, many questions -> an aligned array/list. See [Batch requests](/decision-model/batch) for grouped multi-document batching.

<Tabs>
  <Tab title="JavaScript / TypeScript">
    ```ts theme={null}
    import { Scale } from 'levanto';

    const severity = ['none', 'low', 'moderate', 'high', 'severe'];
    const items = await client.decide(doc, [
      new YesNo('Urgent?'),
      new Scale('How severe?', severity),
    ]);
    if (items[0].ok) console.log(items[0].result);   // { probability, confidence, answer }
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from levanto import Scale

    severity = ["none", "low", "moderate", "high", "severe"]
    items = client.decide(doc, [YesNo("Urgent?"), Scale("How severe?", severity)])
    if items[0]["ok"]:
        print(items[0]["result"])   # {"probability": ..., "confidence": ..., "answer": ...}
    ```
  </Tab>
</Tabs>

<Info>
  Both SDKs expose the same client surface: one client object, five decision kinds, matching shortcuts, errors, and retry behavior. Python additionally ships an `AsyncLevantoClient` with an identical API, used with `await`:

  ```python theme={null}
  from levanto import AsyncLevantoClient, YesNo

  async with AsyncLevantoClient(api_key="lv_live_...") as client:
      env = await client.decide("...", YesNo("Needs review?"))
  ```
</Info>

## Full reference

Each README is a complete reference: every exported function and type, every default, and every behavior not obvious from the signatures.

<CardGroup cols={2}>
  <Card title="levanto-js README" icon="square-js" href="https://github.com/levantolabs/levanto-js">
    Full reference for the TypeScript/JavaScript client: every export, type, and behavior.
  </Card>

  <Card title="levanto-py README" icon="python" href="https://github.com/levantolabs/levanto-py">
    Full reference for the Python client: every export, type, and behavior.
  </Card>
</CardGroup>
