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.completions:
First Output Elapsed Time: 7.10s
Total Elapsed Time (500 requires): 7.10s
ParallaxOpenAIClient.icompletions:
First Output Elapsed Time: 2.85s
Total Elapsed Time (500 requires): 6.99s
ParallaxOpenAIClient.chat_completions:
First Output Elapsed Time: 7.32s
Total Elapsed Time (500 requires): 7.32s
ParallaxOpenAIClient.ichat_completions:
First Output Elapsed Time: 2.85s
Total Elapsed Time (500 requires): 7.09s
Vanilla OpenAI Client:
First Output Elapsed Time: 1.78s
Total Elapsed Time (500 requires): 672.02s
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.2.1.tar.gz
(7.8 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.1.tar.gz.
File metadata
- Download URL: parallax_ai-0.2.1.tar.gz
- Upload date:
- Size: 7.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2646a84bb7679495f80866eb1d22d214d5cf2a2eb43678fe94721cab4948d0aa
|
|
| MD5 |
95954cfaa1096935f788a43629cb232e
|
|
| BLAKE2b-256 |
1c73e39b819f235302456f37633058837c855f1fde1557445b2e64944fb06637
|
File details
Details for the file parallax_ai-0.2.1-py3-none-any.whl.
File metadata
- Download URL: parallax_ai-0.2.1-py3-none-any.whl
- Upload date:
- Size: 8.7 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 |
25421d8fb190d2ffcbe3822c61d405e6464679b781329d4e0cb1f17b49490969
|
|
| MD5 |
29b776b3e7776bc1e6be77738ef4c7cd
|
|
| BLAKE2b-256 |
f06f700d51b0fe41f9e4ea482467996ada6b2a0fce0af3a4f0f5f315b1ca505d
|