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

# Bespoke Labs SDK

> Call Nimble with the bespokelabs Python SDK.

The [`bespokelabs`](https://pypi.org/project/bespokelabs/) package calls Nimble with no extra setup. Version 0.3.0 and later support Nimble. The SDK sends requests to `/v1/nimble/systemone`, which takes the same requests as `/v1/systemone`.

## Install

```bash theme={null}
pip install bespokelabs
```

## Ask questions

The client reads your key from `BESPOKE_API_KEY`. You can also pass `api_key=` to `BespokeLabs()`.

```python theme={null}
from bespokelabs import BespokeLabs

client = BespokeLabs()

response = client.nimble.system_one(
    state="The customer was charged twice and asks for a refund. The service still works.",
    questions={
        "refund": {
            "type": "noul",
            "instructions": "Does the customer request a refund?",
        },
    },
)

print(response.answers["refund"].noul)
```

`model` defaults to `nimble-latest`, the newest general model. Pass `model="nimble-v3"` to stay on the current model when a newer one comes out.

## Choose a model

Pass `model` to use fact check or code search. The request and the answers have the same shape.

```python theme={null}
response = client.nimble.system_one(
    model="nimble-factcheck",
    state="The board moved the vote to Tuesday because the CFO was travelling.",
    questions={
        "moved": {"type": "noul", "instructions": "The vote was moved to Tuesday."},
        "ceo": {"type": "noul", "instructions": "The CEO was travelling."},
    },
)

print(response.answers["moved"].noul)
```

A code search response has fields that other models do not return, e.g., `details`. You can read them as attributes of the response, e.g., `response.details`. The [code search guide](/nimble/codegrep) shows a full request.

## Async

```python theme={null}
import asyncio

from bespokelabs import AsyncBespokeLabs


async def main():
    client = AsyncBespokeLabs()
    response = await client.nimble.system_one(
        state="The service has been down for an hour.",
        questions={"outage": {"type": "noul", "instructions": "Is the service down?"}},
    )
    print(response.answers["outage"].noul)


asyncio.run(main())
```
