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.chat_completions:
First Output Elapsed Time: 7.32
Total Elapsed Time (500 requires): 7.32
ParallaxOpenAIClient.ichat_completions:
First Output Elapsed Time: 2.85
Total Elapsed Time (500 requires): 7.09
Vanilla OpenAI Client:
First Output Elapsed Time: 1.78
Total Elapsed Time (500 requires): 672.02
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": "..."}],
]
chat_completions: Returns a list of outputs in order (waits until all are finished)
outputs = parallax_client.chat_completions(list_of_messages, model="gpt-3.5-turbo")
for output in outputs:
# PROCESS OUTPUT
pass
ichat_completions: Returns outputs one by one in order (yields as soon as each finishes)
for output in parallax_client.ichat_completions(list_of_messages, model="gpt-3.5-turbo"):
# PROCESS OUTPUT
pass
ichat_completions_unordered: Returns outputs as they finish (order not guaranteed)
for output, index in parallax_client.ichat_completions_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.1.3.tar.gz
(7.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.1.3.tar.gz.
File metadata
- Download URL: parallax_ai-0.1.3.tar.gz
- Upload date:
- Size: 7.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 |
8328a50e27a047f827f21aa016892d66328f0ae8af857a3da239676085edbd5b
|
|
| MD5 |
9cdf02781bd6c1b1a0ea054413b87a13
|
|
| BLAKE2b-256 |
0a5632bdcac3bb2cc38c7118417bc8df3a00ac9616b4a8e133060b801ec7e174
|
File details
Details for the file parallax_ai-0.1.3-py3-none-any.whl.
File metadata
- Download URL: parallax_ai-0.1.3-py3-none-any.whl
- Upload date:
- Size: 8.4 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 |
73d53578bb670241277003850b2f64b2f996f37aad4fe38a37ff34c34a5551f6
|
|
| MD5 |
2bc4909eb7bb000035f8901c62084783
|
|
| BLAKE2b-256 |
e2b8043946216c16e003b81748e389ae9b58fcfc2266f2fe1e31d75b70822bf7
|