TeepinDocs

Python SDK

The teepin package for Python 3.9 and newer, with sync and async clients.

pip install teepin

PyPI · Source

Configure

from teepin import Client, AsyncClient

client = Client()                     # reads TEEPIN_API_KEY and TEEPIN_BASE_URL
client = Client(api_key="tpk_...")    # or pass it
ArgumentEnvironmentDefault
api_keyTEEPIN_API_KEYnone
base_urlTEEPIN_BASE_URLhttps://api.teepin.com
timeout60 s for each call that is not a transfer
transfer_timeout300 s without a byte before a transfer is cut off
max_retries4 (storage)
inference_max_retries2 (inference)

AsyncClient has the same methods, awaited.

Inference

reply = client.chat.completions.create(
    model="teepin/glm-5.3",
    messages=[{"role": "user", "content": "What is TLS?"}],
    max_tokens=300,
    chat_template_kwargs={"enable_thinking": False},
)
print(reply.choices[0].message.content, reply.attestation)

with client.chat.completions.create(model="teepin/glm-5.3", messages=[...], stream=True) as stream:
    for chunk in stream:
        if chunk.choices:
            print(chunk.choices[0].delta.content or "", end="")

Storage

s = client.storage
s.create_bucket("my-bucket")
s.upload_file("my-bucket", "videos/launch.mp4", "launch.mp4")      # any size, in parts
s.download_file("my-bucket", "videos/launch.mp4", "copy.mp4")      # parallel, verified
link = s.presign_download("my-bucket", "videos/launch.mp4", ttl_seconds=900)

Errors

Every error is a teepin.TeepinError. API answers raise a subclass with status_code, code, message and request_id:

ErrorWhen
NoCreditError402 insufficient_credit: add credit
OnHoldError402 storage_on_hold
UnauthorizedError, ForbiddenError401, 403
NotFoundError404, for example model_not_found
ConflictError409, for example bucket_exists
RateLimitError429, with retry_after
StreamErrora stream failed or was cut off
APIConnectionErrorno answer: the network or a timeout

The full reference is in the README.

On this page