llmw2 adds a provider-agnostic execution pipeline for running large prompt sets across OpenAI, OpenRouter, and local OpenAI-compatible servers. It keeps on-disk caching, exposes the OpenAI Batch API, and supports multi-modal (vision) payloads while remaining simple to call from any Python project.
pip install -r requirements.txtSet credentials via environment variables or when instantiating LLMClient:
OPENAI(orLLMW2_OPENAI) for OpenAI keysOPENROUTERfor OpenRouter keysLOCALfor local server tokens (if required)
from llmw2 import LLMClient
client = LLMClient()
result = client.chat(
"gpt-4o",
prompt="Summarize the repo architecture in one paragraph.",
)
print(result.response)prompts = [f"Question #{i}: ..." for i in range(100)]
results = LLMClient().run_many(
"gpt-4o",
prompts,
concurrency=40,
)Caching is stored in ~/.cache/llmw2 by default; repeated calls with identical payloads reuse prior responses instantly.
client = LLMClient()
submission = client.batch.create_sync("gpt-4o", prompts)
status = client.batch.status_sync("gpt-4o", submission.batch_id)from llmw2 import Message, MessagePart
client = LLMClient()
resp = client.chat(
"local-qwen2.5vl",
messages=[
Message.from_text("system", "You describe charts."),
Message(
role="user",
content=[
MessagePart(type="image_url", image_url="https://example.com/chart.png"),
MessagePart(type="text", text="Explain the key trend."),
],
),
],
)Add a model entry in llmw2/models.yaml that points to your server:
my-local-model:
provider: openai_compatible
api_key: local
model: my-model-name
base_url: http://localhost:8000/v1
capabilities: [chat]Then call it like any other model: LLMClient().chat("my-local-model", prompt="...").
Detailed design decisions and component breakdown live in docs/llmw2_design.md.