Skip to main content

Python Endpoints

This guide explains how to use the Tensor One Python SDK to run, monitor, and manage serverless endpoints using synchronous, asynchronous, and streaming methods.

Prerequisites

Before using the SDK:
  • Install the tensorone Python SDK
  • Set your API key
  • Initialize the endpoint

Setup Example


Run Synchronously

Use run_sync() to execute the endpoint and block until completion or timeout:

Run Asynchronously (Standard Python)


Run Asynchronously with asyncio


Health Check

Inspect worker and job status:

Streaming Output

Ensure your handler sets return_aggregate_stream: True:

Check Job Status


Cancel a Job


Timeout Handling

Cancel jobs if they exceed a specified timeout:

Purge Queue

Remove pending jobs from the queue (in-progress jobs are unaffected):