Skip to main content
Version: PromptQL

Python SDK

Introduction

The Python SDK is available here.

The Python SDK currently supports the Natural Language API

Support for the Execute Program API will be released soon.

Install

The SDK can be installed using pip:
pip install promptql-api-sdk
Or Poetry:
poetry add promptql-api-sdk

Connect

You'll connect to an instnace by creating a client:
from promptql_api_sdk import PromptQLClient
from promptql_api_sdk.types.models import HasuraLLMProvider

# Initialize the client
client = PromptQLClient(
api_key="your-promptql-api-key",
ddn_url="your-ddn-url",
llm_provider=HasuraLLMProvider(),
timezone="America/Los_Angeles",
)

Query the Natural Language API

Then, use your client to query the Natural Language API:
# Send a simple query
response = client.query("What is the average temperature in San Francisco?")
print(response.assistant_actions[0].message)

# Use streaming for real-time responses
for chunk in client.query("Tell me about the weather in New York", stream=True):
if hasattr(chunk, "message") and chunk.message:
print(chunk.message, end="", flush=True)