Skip to main content
The Python SDK ships in the same package as the CLI.
It needs Python 3.11 or later. The key comes from SENSEI_API_KEY, or from the config file sensei login writes. To update, run pip install --upgrade senselab-sensei, or sensei update when the command is installed. sensei.__version__ says which version is installed, from 0.2.0 on. Batch, and the settings and secrets below, need 0.2.0 or later. say needs 0.3.0 or later.

Run something

run waits until the run has finished or has a question for a person. start takes the same arguments and returns at once. Input fields are keyword arguments, or a dictionary passed as input=.

Sensei

what is a saved agent’s name, a path to a definition file, or a definition as a dictionary. These keyword arguments are options of the run. Any other keyword argument is an input field. sensei.runs, sensei.agents, sensei.tools and sensei.schedules are the lower-level groups described under Client.

Result

Answer a waiting run

correct takes what to do instead, and the text is kept for the agent’s later runs. answer waits for what comes next unless you pass wait=False.

Record an outcome

On a run with steps, step="refund" names the step that was wrong.

Many at once

A run that asks a person comes back waiting, and the others are not held up by it.

Several changes to one repository

batch returns at once unless you pass wait=True. Its options are ref, instructions, parallel, together, deliver, limit, total, check and secrets. See Several changes at once.

Settings and secrets

See Services, settings and secrets.

Client

Client is the HTTP API with nothing added. Every method returns the API’s JSON.

Errors

A response that is not a success raises SenseiError, with the status, code and message the service sent.