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.5.tar.gz
(4.5 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.5.tar.gz.
File metadata
- Download URL: 21st_sdk-0.0.5.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
07a2f3e50c86798f60a9af13d737e585b0eac568bbd0fb43dcf617153a3ba4eb
|
|
| MD5 |
5bfa9288bbcf7b63036e646b5334a9e3
|
|
| BLAKE2b-256 |
513f15fc3e2bbf88aa408af38f3b8bedf346961ba707aff8e246995921f728da
|
File details
Details for the file 21st_sdk-0.0.5-py3-none-any.whl.
File metadata
- Download URL: 21st_sdk-0.0.5-py3-none-any.whl
- Upload date:
- Size: 5.0 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 |
121d17095fd3a2df2f3181cb0467c2c39589872a7368b1a5393940eea3791f15
|
|
| MD5 |
6b1b2c6825519037cb370eea4220c1e3
|
|
| BLAKE2b-256 |
a143bf4789060cf58b04518fda48c4b8b11fba244282c1bb7349a438e487f188
|