21st-sdk Python
Server-side Python SDK for 21st Agents. Manage sandboxes, threads, and tokens programmatically.
Method arguments use Python-style snake_case, but SDK responses keep the relay's camelCase field names.
Install
pip install 21st-sdk
Quick Start
import os
from twentyfirst_sdk import AgentClient
client = AgentClient(api_key=os.environ["API_KEY_21ST"]) # an_sk_...
# Create a sandbox for your agent
sandbox = client.sandboxes.create(agent="my-agent")
# Create a thread
thread = client.threads.create(sandbox_id=sandbox.id, name="Review PR #42")
# Generate a short-lived token for browser clients
token = client.tokens.create(agent="my-agent", expires_in="1h")
print(token.expiresAt)
API
AgentClient(api_key, base_url=...)
AgentClient(
api_key="...", # Your an_sk_ API key
base_url="...", # Optional, default: "https://relay.an.dev"
)
client.sandboxes
| Method | Description |
|---|---|
create(agent=...) |
Create a new sandbox for an agent |
get(sandbox_id) |
Get sandbox details (status, threads, agent info) |
delete(sandbox_id) |
Delete a sandbox |
exec(sandbox_id, command, ...) |
Run a command in a sandbox |
files.write(sandbox_id, files) |
Write files into a sandbox |
files.read(sandbox_id, path) |
Read a file from a sandbox |
git.clone(sandbox_id, url, ...) |
Clone a repository into a sandbox |
client.threads
| Method | Description |
|---|---|
list(sandbox_id) |
List all threads in a sandbox |
create(sandbox_id, name=...) |
Create a new thread |
get(sandbox_id, thread_id) |
Get thread with messages |
delete(sandbox_id, thread_id) |
Delete a thread |
run(agent, messages, ...) |
Run a thread and return the raw streaming response |
client.tokens
| Method | Description |
|---|---|
create(agent=..., user_id=..., expires_in=...) |
Create a short-lived JWT (default: "1h") |
License
MIT
Metadata
Release files for 21st-sdk 0.0.5
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| 21st_sdk-0.0.5.tar.gz | 4.5 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| 21st_sdk-0.0.5-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 9.5 kB
Release files / 21st_sdk-0.0.5.tar.gz
| Download URL | 21st_sdk-0.0.5.tar.gz |
|---|---|
| Size | 4.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
07a2f3e50c86798f60a9af13d737e585b0eac568bbd0fb43dcf617153a3ba4eb
|
|
BLAKE2b-256 checksum How to use checksums |
513f15fc3e2bbf88aa408af38f3b8bedf346961ba707aff8e246995921f728da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Release files / 21st_sdk-0.0.5-py3-none-any.whl
| Download URL | 21st_sdk-0.0.5-py3-none-any.whl |
|---|---|
| Size | 5.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
121d17095fd3a2df2f3181cb0467c2c39589872a7368b1a5393940eea3791f15
|
|
BLAKE2b-256 checksum How to use checksums |
a143bf4789060cf58b04518fda48c4b8b11fba244282c1bb7349a438e487f188
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.2
|
Security for 21st-sdk 0.0.5
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.