Lightweight parallel AI API calls in Python.
Project description
Parallax-AI
Lightweight parallel AI API calls in Python.
Installation
You can install Parallax using pip:
pip install parallax-ai
Testing
vllm serve google/gemma-3-27b-it
python -m parallax_ai.test
>>>
ParallaxOpenAIClient.run:
First Output Elapsed Time: 4.40s
Total Elapsed Time (500 requires): 4.40s
ParallaxOpenAIClient.irun:
First Output Elapsed Time: 1.95s
Total Elapsed Time (500 requires): 3.51s
Vanilla OpenAI Client:
First Output Elapsed Time: 0.72s
Total Elapsed Time (500 requires): 95.70s
Usage (Compatible with any OpenAI-API–compatible server, e.g., vLLM)
Initialize Client
from parallax_ai import ParallaxOpenAIClient
# Initialize Client
parallax_client = ParallaxOpenAIClient(
api_key=YOUR_API_KEY,
base_url=YOUR_API_BASE_URL,
)
list_of_messages = [
[{"role": "user", "content": "..."}],
[{"role": "user", "content": "..."}],
[{"role": "user", "content": "..."}],
.
.
.
[{"role": "user", "content": "..."}],
]
run: Returns a list of outputs in order (waits until all are finished)
outputs = parallax_client.run(list_of_messages, model="gpt-3.5-turbo")
for output in outputs:
# PROCESS OUTPUT
pass
irun: Returns outputs one by one in order (yields as soon as each finishes)
for output in parallax_client.irun(list_of_messages, model="gpt-3.5-turbo"):
# PROCESS OUTPUT
pass
irun_unordered: Returns outputs as they finish (order not guaranteed)
for output, index in parallax_client.irun_unordered(list_of_messages, model="gpt-3.5-turbo"):
# PROCESS OUTPUT
pass
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
parallax_ai-0.2.3.tar.gz
(6.5 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file parallax_ai-0.2.3.tar.gz.
File metadata
- Download URL: parallax_ai-0.2.3.tar.gz
- Upload date:
- Size: 6.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c29d14a02bc5b2c445d64850933e45389bc86be8da77192525d6a23672c5893e
|
|
| MD5 |
754ff5587899ad15781fd5f47730052c
|
|
| BLAKE2b-256 |
f787f6fe68143ac9eb206a1e058777ed041b6eeeea400c7fb87efe67c3a86e3a
|
File details
Details for the file parallax_ai-0.2.3-py3-none-any.whl.
File metadata
- Download URL: parallax_ai-0.2.3-py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3d520925eafba52f0fc224f7e28f87e4fe79f8c1d4ca2cdb1433f1de7261861e
|
|
| MD5 |
737802c7ac9d02a856ee06145afa5b87
|
|
| BLAKE2b-256 |
92fced2d5c2333c722af41a50a89783c455e8c28ddbf3020aa75fe254e2fa8db
|