Skip to content

About

to save cost latency

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Batch-LLM-calls

A small demo showing how to batch multiple queries into a single LLM request to save cost and reduce latency.

The script assigns a unique ID to each query, sends them in a single request, and expects the model to respond with ID:answer lines.

Setup

  1. Install dependencies:
pip install -r requirements.txt
  1. Configure the LLM endpoint URL in .env (or via the URL env var):
URL=

If your endpoint requires an API key, set it via one of:

  • OPENAI_API_KEY
  • API_KEY

Usage

Run the script with one or more --query arguments:

python main.py --query "What is the capital of France?" --query "What is the largest mammal?"

Or run the built-in example:

python main.py --example

Or load queries from a file (one query per line):

python main.py --file queries.txt

Notes

  • The script assumes the endpoint supports an OpenAI-compatible chat completions API (/chat/completions).
  • The output is printed twice: raw model output first, then parsed ID:answer pairs.

About

to save cost latency

Topics

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages