OctoAI Python SDK at a glance

The OctoAI Python SDK is intended to help you use OctoAI endpoints. At its simplest form, it allows you to run inferences against an endpoint by providing a dictionary with the necessary inputs.

Python
import time
from octoai.client import OctoAI

octoai = OctoAI()

# It allows you to run inferences
output = octoai.infer(endpoint_url="your-endpoint-url", inputs={"keyword": "dictionary"})

# It also allows for inference streams for LLMs
for token in octoai.infer_stream("your-endpoint-url", inputs={"keyword": "dictionary"}):
    if token.get("object") == "chat.completion.chunk":
        # Do stuff with the token
        pass

# And for server-side asynchronous inferences
future = octoai.infer_async("your-endpoint-url", {"keyword": "dictionary"})
# Typically, you'd collect additional futures then poll for status, but for the sake of example...
while not octoai.is_future_ready(future):
    time.sleep(1)
# Once the results are ready, you can use them in the same way as you
# typically do for demo endpoints
result = octoai.get_future_result(future)

# And includes healthChecks
if octoai.health_check("your-healthcheck-url") == 200:
	# Run some inferences
    pass