Skip to main content

Python SDK for the LiteFold API

Project description

LiteFold Python SDK

Python client for the LiteFold Rosalind API. Designed for programmatic access by OpenClaw agents running in parallel (10–100+).

Install

cd LiteFoldPythonSDK
pip install -e .

Dependencies: httpx, click.

Quick Start

from litefold import Client

client = Client(api_key="lf_...", base_url="https://agentsapi.litefold.ai")

Chat Lifecycle

Create and send (fire-and-forget)

client.rosalind.create_chat(
    project="Default", chat_name="run-1",
    description="KRAS study", device="cpu",
)

client.rosalind.send_message(
    project="Default", chat_name="run-1",
    message="Describe KRAS G12D in cancer.",
    mode="pro",       # "max" | "pro" | "lite"
    depth="balanced",  # "balanced" | "ultra"
)

send_message returns immediately — it does not block on the agent stream.

Check status

status = client.rosalind.chat_status(project="Default", chat_name="run-1")
status.is_running  # True while agent is working
status.status      # "running" | "completed" | "error" | "cancelled" | "unknown"

Wait until done

import time

while True:
    status = client.rosalind.chat_status(project="Default", chat_name="run-1")
    if not status.is_running:
        break
    time.sleep(5)

Reading Results

List chats

chats = client.rosalind.list_chats(project="Default", limit=5)
for c in chats:
    print(c.chat_name, c.total_cost_usd, c.device)

Blocks

Chat history is stored as an ordered list of blocks. Each block is one of:

content_type What it is Key fields
text Assistant response text .text, .assistant_message
thinking Model thinking .text
tool_use Tool invocation .tool_name, .tool_input
mcp_result Tool output .tool_name, .tool_result, .is_output_panel
total = client.rosalind.list_blocks(project="Default", chat_name="run-1")

blocks = client.rosalind.get_blocks(
    project="Default", chat_name="run-1",
    start=0, end=20,  # slice — omit for all blocks
)

for b in blocks:
    if b.assistant_message:
        print(b.assistant_message)
    elif b.content_type == "mcp_result":
        print(f"[{b.tool_name}] {b.tool_result}")

Bash outputs

bash = client.rosalind.get_bash_outputs(
    project="Default", chat_name="run-1",
    start=0, end=50,
)
for b in bash:
    print(f"$ {b.command}")
    print(f"  exit={b.exit_code}  output={b.output[:200]}")

Workspace files

ws = client.rosalind.workspace(project="Default", chat_name="run-1")

ws.list_folders()                          # ["scripts", "documents", "figures", ...]
ws.list_files(folder="scripts")            # [WorkspaceFile, ...]
ws.get_file_content("scripts/main.py")     # FileContent with .content

Files

Upload

# Upload from disk (single file or list)
result = client.files.upload("Default", "data/protein.pdb")
result = client.files.upload("Default", ["data/protein.pdb", "data/ligand.sdf"], folder="structure")

# Upload raw bytes
result = client.files.upload_bytes("Default", "notes.txt", b"Hello world")

print(result.completed, result.failed)  # 2, 0
for r in result.results:
    print(r.filename, r.status, r.format_type)

List

files = client.files.list("Default", folder="upload")
all_files = client.files.list_all("Default")
structures = client.files.list_by_format("Default", format_type="structure")

for f in files:
    print(f.file_name, f.folder, f.format_type)

Download

# Get text content
content = client.files.get_content("Default", "result.csv")

# Download as bytes
raw = client.files.download("Default", "protein.pdb")

# Download straight to disk
client.files.download_to("Default", "protein.pdb", "./output/")

Metadata

info = client.files.get_metadata("Default", "protein.pdb")
print(info.format_type, info.created_at, info.metadata)

client.files.update_metadata("Default", "protein.pdb", metadata={"notes": "cleaned"})

Projects

client.projects.create(name="MyProject", description="...")
client.projects.list()       # ProjectList
client.projects.get("MyProject")

CLI

The SDK ships with a litefold CLI so you can do everything from your terminal without writing a script.

export LITEFOLD_API_KEY=lf_...

All commands accept --json for machine-readable output. Use --help on any command for full options.

Projects

litefold projects list
litefold projects get MyProject
litefold projects create MyProject --description "KRAS study"

Files

# Upload
litefold files upload data/protein.pdb --project Default
litefold files upload data/protein.pdb data/ligand.sdf --project Default --folder structure

# List
litefold files list --project Default
litefold files list-all --project Default
litefold files list-by-format --project Default --format pdb

# Read / Download
litefold files get-content --project Default --file-name result.csv
litefold files download --project Default --file-name protein.pdb --dest ./output/

# Metadata
litefold files get-metadata --project Default --file-name protein.pdb
litefold files update-metadata --project Default --file-name protein.pdb --metadata '{"notes": "cleaned"}'

Rosalind (Agent Chats)

# Chat lifecycle
litefold rosalind create-chat --project Default --chat-name run-1 --description "KRAS study"
litefold rosalind send-message --project Default --chat-name run-1 --message "Describe KRAS G12D in cancer."
litefold rosalind chat-status --project Default --chat-name run-1
litefold rosalind cancel-chat --project Default --chat-name run-1

# List / read
litefold rosalind list-chats --project Default --limit 5
litefold rosalind list-blocks --project Default --chat-name run-1
litefold rosalind get-blocks --project Default --chat-name run-1 --start 0 --end 20
litefold rosalind get-bash-outputs --project Default --chat-name run-1

Workspace

litefold rosalind workspace list-folders --project Default --chat-name run-1
litefold rosalind workspace list-files --project Default --chat-name run-1 --folder scripts
litefold rosalind workspace get-file-content --project Default --chat-name run-1 --file-path scripts/main.py

JSON Output

Append --json to any command for machine-readable output:

litefold --json projects list
litefold --json rosalind get-blocks -p Default -n run-1

Short Flags

Flag Meaning
-p --project
-n --chat-name
-m --message
-f --folder
-d --description
-o --dest
-l --limit

Multi-Agent Usage

The SDK is designed for 10–100+ agents running concurrently:

  • One client per process — the connection pool (200 sockets) handles all threads.
  • One client per agent — also fine; each gets its own pool.
  • Fire-and-forgetsend_message returns instantly, agents check chat_status at their own pace.
  • Retry built-in — transient errors (429, 5xx, connection resets) are retried automatically with exponential backoff.
# Tune for your workload
client = Client(
    api_key="lf_...",
    base_url="https://agentsapi.litefold.ai",
    timeout=60.0,
    max_retries=3,
    retry_backoff=1.0,
    pool_max_connections=200,
    pool_max_keepalive=40,
)

Error Handling

from litefold import (
    LiteFoldError,          # base
    LiteFoldAPIError,       # HTTP error (has .status_code, .message)
    LiteFoldAuthError,      # 401/403
    LiteFoldNotFoundError,  # 404
    LiteFoldRateLimitError, # 429
    LiteFoldTimeoutError,   # timeout
)

try:
    client.rosalind.send_message(...)
except LiteFoldRateLimitError:
    print("Out of credits")
except LiteFoldAuthError:
    print("Bad API key")
except LiteFoldAPIError as e:
    print(f"HTTP {e.status_code}: {e.message}")

All Models

Model Fields
ChatInfo chat_name, description, created_at, last_activity_at, total_input_tokens, total_output_tokens, total_cost_usd, device
ChatStatus chat_name, is_running, task_id, status
Block index, content_type, role, text, tool_name, tool_input, tool_result, where_to_show, .assistant_message, .is_output_panel, .is_bash
BashOutput index, command, output, exit_code
UploadResponse success, message, project, folder, total_files, completed, failed, results
UploadResult filename, status, storage_key, format_type, error
FileInfo file_name, folder, storage_key, format_type, parent_file_name, created_at, metadata, alias
WorkspaceFile name, location, folder, size
FileContent location, content, size
Project job_name, description, created_at, jobs
ProjectList total, projects

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

litefold_sdk-0.1.8.tar.gz (26.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

litefold_sdk-0.1.8-py3-none-any.whl (35.1 kB view details)

Uploaded Python 3

File details

Details for the file litefold_sdk-0.1.8.tar.gz.

File metadata

  • Download URL: litefold_sdk-0.1.8.tar.gz
  • Upload date:
  • Size: 26.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for litefold_sdk-0.1.8.tar.gz
Algorithm Hash digest
SHA256 4a38de7bd3e4bbe835aeae6ed35d7c10be41347123aa4d3a2b1712da4a659513
MD5 8f81e81bb20d658663d64fbfcb2ba68e
BLAKE2b-256 16b7136e1c494de2344ca5dbba3a4d726be27731689e1dfbde2467f1ae460579

See more details on using hashes here.

File details

Details for the file litefold_sdk-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: litefold_sdk-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 35.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for litefold_sdk-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 8ea7be06ee2a6584c89a89bfaaa365f2ba251e0aaaacfec4c7bf5e39017a2977
MD5 5a848a92831a841052b0a57ddd67237c
BLAKE2b-256 286cec25416d7be52e95852eae7b563c75c3d1d00c3775cb03e7b8def0126b47

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page