Skip to main content

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


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.3.2.tar.gz (6.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

parallax_ai-0.3.2-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file parallax_ai-0.3.2.tar.gz.

File metadata

  • Download URL: parallax_ai-0.3.2.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

Hashes for parallax_ai-0.3.2.tar.gz
Algorithm Hash digest
SHA256 11124e69bc1150fd22635ae3c2ad129b734f7f6b2fe9e9508fc17e7971c0ced1
MD5 d97d71f30d5084c6b6f9477673ce857f
BLAKE2b-256 c8747b925d75c043c0c6801e78661d66de5f1f92f337b556940ed9e5be6300a2

See more details on using hashes here.

File details

Details for the file parallax_ai-0.3.2-py3-none-any.whl.

File metadata

  • Download URL: parallax_ai-0.3.2-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.5

File hashes

Hashes for parallax_ai-0.3.2-py3-none-any.whl
Algorithm Hash digest
SHA256 3d90dafb20d2236505561d38284ff8aaa1c8da379d010905ee3839d693b863e8
MD5 7cde0b77e39d89787c455e980d1a89f8
BLAKE2b-256 9d10b2a4fafe27a631a302943144980fd4fd2806580b4060d1bd3fdfefd0e66e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page