rom ai21 import AI21Client
client = AI21Client()
# Option 1: Upload a local file
file_from_disk = client.library.files.create(
labels=["label1", "label2"],
)
# Option 2: Upload a file from a public URL
file_from_url = client.library.files.create(
public_url="https://www.example.com/file.pdf",
labels=["label1", "label2"],
)
# Retrieve uploaded file metadata (example)
uploaded_file = client.library.files.get(file_from_disk.id)