Skip to Content
Python (3)

Last Updated: 4/8/2026


Python Client API

The Pie Python client library provides a simple interface for submitting and managing inferlets.

Installation

pip install pie-client

Quick Start

from pie_client import PieClient client = PieClient("http://localhost:8080") # Run an inferlet result = client.run( inferlet="std/text-completion", args={"prompt": "Once upon a time"} ) print(result)

API Reference

PieClient

Main client class for interacting with Pie server.

client = PieClient(base_url: str, api_key: Optional[str] = None)

Methods

run()

Run an inferlet with arguments:

result = client.run( inferlet: str, args: Dict[str, Any], timeout: Optional[int] = None )

submit()

Submit an inferlet for async execution:

job_id = client.submit( inferlet: str, args: Dict[str, Any] )

get_result()

Get result of submitted job:

result = client.get_result(job_id: str)

upload_inferlet()

Upload a custom inferlet:

client.upload_inferlet( name: str, wasm_path: str )

Examples

Basic Text Completion

from pie_client import PieClient client = PieClient("http://localhost:8080") result = client.run( inferlet="std/text-completion", args={ "prompt": "Explain quantum computing in simple terms:", "max_tokens": 100 } ) print(result)

Custom Inferlet

# Upload your custom inferlet client.upload_inferlet( name="my-inferlet", wasm_path="./my_inferlet.wasm" ) # Run it result = client.run( inferlet="my-inferlet", args={"input": "test"} )

Async Execution

import time # Submit job job_id = client.submit( inferlet="std/text-completion", args={"prompt": "Long running task..."} ) # Poll for result while True: result = client.get_result(job_id) if result.is_complete: print(result.output) break time.sleep(1)

Error Handling

from pie_client import PieClient, PieError try: result = client.run( inferlet="my-inferlet", args={"prompt": "test"} ) except PieError as e: print(f"Error: {e}")

Next Steps