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.4.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.4.tar.gz.
File metadata
- Download URL: 21st_sdk-0.0.4.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 |
f475be20b8316ac4979b8ceee4fec121bb3dd63761b4cee00458b6b1819b4975
|
|
| MD5 |
685774da8ff533a29755424358e80bf0
|
|
| BLAKE2b-256 |
73ae871d49579789073ba34b25d4c8545be371f2746e988d9fb6be80e1fa8589
|
File details
Details for the file 21st_sdk-0.0.4-py3-none-any.whl.
File metadata
- Download URL: 21st_sdk-0.0.4-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 |
b3e8b85172b569a44a7daa5d214bb6eaf7ca6751c561ea2ce64c7c5457b15d3e
|
|
| MD5 |
f60c20b45f2e84741a08abd7b327eb38
|
|
| BLAKE2b-256 |
70e1c824a1fc8097f1f724ee2536563b182a87838571f958859d5c08a405db79
|