Server-side Python SDK for 21st Agents
Project description
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
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
21st_sdk-0.0.3.tar.gz
(4.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file 21st_sdk-0.0.3.tar.gz.
File metadata
- Download URL: 21st_sdk-0.0.3.tar.gz
- Upload date:
- Size: 4.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9b39c43b49fbc9a9a2df69d6190d9b475239b5ac2e4684170cef5e85a13c280e
|
|
| MD5 |
fe2d54ab032b7b497b49af92eb1a50cf
|
|
| BLAKE2b-256 |
21b8908a77f79b87012fe53ed92000ceef23a01c81f2a4370857dc8a15338237
|
File details
Details for the file 21st_sdk-0.0.3-py3-none-any.whl.
File metadata
- Download URL: 21st_sdk-0.0.3-py3-none-any.whl
- Upload date:
- Size: 4.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7dabbf88d8c4c18cfe311460a14aaf008ff0c47a0b9ccef9daa21699d41dcb02
|
|
| MD5 |
06840c964b46d8b2cc12dd4602ad561f
|
|
| BLAKE2b-256 |
6fb39c7bf27550ac2a33843e2a106e333c0d5409dc1df9cf508fdc36236323c3
|