AI:ssociate Python API Library
aissociate is a Python package that provides an interface for interacting with the AI:ssociate API.
It currently only supports asynchronous clients, making it suitable for a variety of use cases.
Installation
You can install aissociate using pip by creating a virtual environment and installing it with
pip install aissociate
Prerequisites
- Python >=3.8 installed
- A valid API key (request one by contacting sales@aissociate.at)
asynciolibrary installed (install usingpip install asyncio)
Asynchronous Client
AIssociate provides an AsyncAIssociateClient for interacting with the streaming API asynchronously.
from aissociate import AsyncAIssociateClient
client = AsyncAIssociateClient(
api_key="<AISSOCIATE_API_KEY>",
)
Note that instead of explicitly setting the API Key, we recommend setting the AISSOCIATE_API_KEY as an environment
variable either by exporting it export AISSOCIATE_API_KEY=<your-key> or by loading it from the .env file.
Parameters
api_key: Your API key for authentication.base_url: The base URL of the API server (The default ishttps://aissociate.at).
Usage
Questions
Asking questions works be iterating over the event responses from the ask(question: str, legal_area: LegalArea = LegalArea.CIVIL)
method of the client.
import asyncio
from aissociate import AsyncAIssociateClient, LegalArea
client = AsyncAIssociateClient()
async def main():
stream = client.ask(
"Fasse die Judikatur des OGH zur Mietzinsminderung in der Covid-Pandemie zusammen.",
legal_area=LegalArea.CIVIL
)
async for event in stream:
print(event.text, end="")
if __name__ == "__main__":
asyncio.run(main())
Explicitly set the area of law by selecting one of the available knowledge databases (civil, criminal, public and tax law) and passing it via the legal area parameter, e.g.
from aissociate import LegalArea
client.ask("Welche rechtlichen Bestimmungen gelten für die Untersuchungshaft in Österreich?", legal_area=LegalArea.CRIMINAL)
When selecting public law, our internal knowledge database is used and includes all federal laws. Optionally set the scope to also include austrian state laws (e.g. "Wien", "Tirol", "Steiermark", "Kärnten", "Niederösterreich", "Oberösterreich", "Vorarlberg", "Salzburg", "Burgenland").
All possible types are defined in models.shared. If no legal area is selected, AI:ssociate without querying our
knowledge databases, which can be helpful for general tasks like summarizing, translation, etc.
from aissociate import LegalArea, Scope
client.ask(
"Ich will meine Hausfassade neu streichen – muss ich dafür eine Bewilligung einholen?",
legal_area=LegalArea.PUBLIC,
scope="Tirol"
)
Conversations
To ask follow-up questions within the same conversation context, use a session object.
This ensures that the same thread_id is reused for each message, allowing the backend to
maintain conversational memory.
import asyncio
from aissociate import AsyncAIssociateClient
client = AsyncAIssociateClient()
async def main():
async with client.session() as chat:
async for event in chat.ask("Was ist Schadenersatz?"):
print(event.text, end="")
async for event in chat.ask("Fasse das stichpunktartig zusammen."):
print(event.text, end="")
if __name__ == "__main__":
asyncio.run(main())
You can still use client.ask(...) directly for single-turn, stateless queries.
Resetting the thread
If you want to start a new conversation within the same session, simply call chat.reset() to clear the
previous thread ID:
import asyncio
from aissociate import AsyncAIssociateClient
client = AsyncAIssociateClient()
async def main():
async with client.session() as chat:
async for event in chat.ask("Was ist Schadenersatz?"):
print(event.text, end="")
chat.reset()
async for event in chat.ask("Was ist ein Vertrag?"):
print(event.text, end="")
if __name__ == "__main__":
asyncio.run(main())
Encryption with Passphrases
AI:ssociate supports end-to-end encryption for your messages and files via a user-chosen passphrase.
- If you provide a
passphrase, all message and file content will be encrypted. - If you don’t set a passphrase, a secure system-managed passphrase will be used instead.
- The
passphraseis included as an HTTP header with each request to identify and unlock the corresponding encrypted data.
Example Usage
from aissociate import AsyncAIssociateClient
client = AsyncAIssociateClient(passphrase="correct-horse-battery-staple")
All requests made with this client instance will now include the passphrase and interact with encrypted data accordingly.
Security Note
- Keep your passphrase safe — AI:ssociate cannot recover encrypted content without it.
- Changing the passphrase later will prevent access to previously encrypted messages unless the original passphrase is reused.
Files
The AI:ssociate client supports uploading files to provide context for your legal questions. Files are processed asynchronously in the backend and may not be available immediately after upload.
Upload Method Parameters
The upload() method supports the following parameters:
| Parameter | Type | Default | Description |
|---|---|---|---|
files |
str | list[str] |
Required | File path(s) to upload |
wait_for_completion |
bool |
False |
Wait until all uploads are processed |
progress_callback |
callable |
None |
Function called with progress updates |
poll_interval |
float |
1.0 |
Seconds between status checks |
timeout |
float |
None |
Maximum wait time in seconds |
The progress callback receives three parameters:
- filename (str): Name of the file being processed
- progress (int): Progress percentage (0-100)
- status (str): Current status ("PENDING", "PROGRESS", "SUCCESS", "FAILURE")
def my_progress_handler(filename, progress, status):
if status == "PROGRESS":
print(f"Processing {filename}: {progress}%")
elif status == "SUCCESS":
print(f"{filename} completed")
elif status == "FAILURE":
print(f"{filename} failed")
Basic File Upload
Upload files and get task information immediately:
import asyncio
from aissociate import AsyncAIssociateClient
async def basic_upload():
async with AsyncAIssociateClient() as client:
# Upload files - returns immediately with task IDs
files = ["contract.pdf", "legal_document.docx"]
response = await client.upload(files)
print("Upload initiated:")
for task in response["tasks"]:
print(f"\tTask ID: {task['task_id']}")
print(f"\tFilename: {task['filename']}")
asyncio.run(basic_upload())
Upload and Wait for Completion
For simpler workflows, you can wait for uploads to complete before proceeding:
async def upload_and_wait():
async with AsyncAIssociateClient() as client:
# Upload files and wait until they're fully processed
files = ["document.pdf"]
response = await client.upload(files, wait_for_completion=True)
print("All files uploaded and processed!")
for task in response["tasks"]:
if task.get("file"):
print(f"File ready: {task['file']['filename']} (UUID: {task['file']['uuid']})")
asyncio.run(upload_and_wait())
Upload with Progress Tracking
Monitor upload progress in real-time with a progress callback:
async def upload_with_progress():
async with AsyncAIssociateClient() as client:
def progress_callback(filename, progress, status):
print(f"{filename}: {progress}% ({status})")
response = await client.upload(
["large_document.pdf"],
wait_for_completion=True,
progress_callback=progress_callback,
poll_interval=0.5, # Check every 500ms
timeout=300 # 5 minute timeout
)
print("Upload completed!")
asyncio.run(upload_with_progress())
Session-based Upload
Upload files within a session context:
async def session_upload():
async with AsyncAIssociateClient() as client:
async with client.session() as chat:
# Upload and wait for completion in session
await chat.upload(
["contract.pdf"],
wait_for_completion=True
)
# Now use the file in queries
async for event in chat.ask(
"Fasse diesen Vertrag zusammen.",
files=["contract.pdf"]
):
print(event.text, end="")
asyncio.run(session_upload())
Notes
The provided API key in the script is for demonstration purposes and should be replaced with a valid key. Ensure that your API key remains confidential and is not shared publicly.
Troubleshooting
If you receive a 401 Unauthorized response, ensure your API key is correct and active. If the request times out, check your internet connection and API availability.
Metadata
Release files for aissociate 0.2.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| aissociate-0.2.1.tar.gz | 21.8 kB | Without provenance | Details for aissociate-0.2.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| aissociate-0.2.1-py3-none-any.whl | Python 3 | none | any | Details for aissociate-0.2.1-py3-none-any.whl |
Total release size: 38.4 kB
Release files / aissociate-0.2.1.tar.gz
| Download URL | aissociate-0.2.1.tar.gz |
|---|---|
| Size | 21.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
9be0730fccb59e962a6faad81ac3dac57bbeea662fefe1d7184e77b2794aac6e
|
|
BLAKE2b-256 checksum How to use checksums |
8e89effc1091d8c89197c89099499e10c49a1afb9c2676d6bcd8083b9c1016f1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Release files / aissociate-0.2.1-py3-none-any.whl
| Download URL | aissociate-0.2.1-py3-none-any.whl |
|---|---|
| Size | 16.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
b87d420031e1d1f2eac0e3dedef40a4d7b66cd63dd84d477d05341a12e16c1d9
|
|
BLAKE2b-256 checksum How to use checksums |
65f41e01af7ad1584142ba83a781febc3ff4be76b62d8492f4f13f31ec2183f6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.12.3
|
Security for aissociate 0.2.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.