Skip to main content

render-lab-tasks-llm

Provider-agnostic LLM tasks for Render Workflows. Version 0.1.1 implements all 13 registered tasks. Version 0.1.0 contained only classification and summarization.

Install from PyPI with Python 3.12+:

pip install render-lab-tasks-llm==0.1.1

Import app, classify, classify_impl, summarize, and summarize_impl from render_lab_tasks_llm.tasks. Combine pack apps with Workflows.from_workflows. Run wrapped tasks with await ctx.run(classify, input); inject LlmDeps(chat=...) into the raw implementations for tests or custom task wrappers.

Contracts

classify accepts text, labels (objects with name and optional description), optional maxLabels (default 3), model, and ledger. It returns labels, optional reasoning, resolved model, and optional usage. Unknown/non-string labels are removed, duplicates are removed before capping, and malformed model JSON yields an empty label list, matching TypeScript. This is prompt-based classification, not a guarantee of semantic correctness.

summarize accepts text, optional instructions, maxWords (default 120), model, and ledger. It returns trimmed summary, resolved model, and optional usage. The word limit is a prompt target, not hard truncation.

Missing or null optional defaults behave like the TS implementation. Python additionally rejects negative, boolean, and nonintegral maxLabels/maxWords before calling a provider. Zero is valid. Optional result keys are omitted when unavailable. Unknown model prices do not become zero-dollar estimates.

Providers and environment

Credentials and configuration are read when a task runs, never during imports.

Variable Purpose
LLM_MODEL Default provider-prefixed model; otherwise anthropic/claude-opus-4-8, matching the TS snapshot
OPENAI_API_KEY Direct openai/ models, such as openai/gpt-4o-mini
ANTHROPIC_API_KEY Direct anthropic/ models
GEMINI_API_KEY Direct google/ or gemini/ models through Google's OpenAI-compatible endpoint
GOOGLE_GENERATIVE_AI_API_KEY Fallback Google key; OpenAI keys are never used for direct Google requests
LLM_BASE_URL Explicit OpenAI-compatible gateway; preserves the full model identifier
LLM_API_KEY Preferred key for gateways and direct OpenAI; falls back to OPENAI_API_KEY
REDIS_URL Required only for a nonempty ledger without an injected cost-ledger port
LLM_PRICING JSON price overrides keyed by provider-prefixed model; values contain inputUsdPerMTok and optional outputUsdPerMTok
LLM_COST_LEDGER_TTL_SECONDS TTL of at least one second; default 172800, rounded down

The default model and estimated pricing table are copied from the pinned TS snapshot, not a claim of current pricing or availability. Override LLM_MODEL for your account. The example explicitly uses openai/gpt-4o-mini.

Retries, usage, and cost tracking

Provider calls stream internally and assemble their text before returning JSON. Direct OpenAI uses max_completion_tokens; gateways/Google use max_tokens. Official SDK and HTTP retries are disabled; Render owns five retries with a 2000 ms base delay and 2x backoff. Clients close after each call.

Usage includes available input/output token counts and an estimated dollar cost when known. Output accounting preserves the TS max(completion, total-prompt) rule. Estimates ignore caching discounts and price tiers; they are not invoices.

A nonempty ledger appends a JSON cost record to Redis list llm:cost:<ledger> with TTL, compatible with the TS format. Invalid ledger configuration fails before provider spend. Pricing failures without a ledger and append/cleanup failures after spend warn without failing the task, avoiding rebilling solely to repair observability. Inject CostLedgerPort to use another store. The default Redis adapter also disables client retries.

Complete task surface

The pack also exports chat_turn (llm.chat), complete, extract, extract_strict, translate, moderate, rerank, embed, load_skill, open_cost_ledger, and cost_report, with their injectable raw implementations. with_ledger(ctx, ledger) binds the ledger while dispatching durable child runs. Chat/completion preserve stopReason so callers can detect truncated output.

LLM_EMBED_MODEL overrides the embedding default. SKILLS_PATH changes installed skill search directories. Skills load text only from GitHub, URLs, vendored files, or installed names; they never execute scripts. REDIS_URL is required only for cost-ledger IO; LLM_COST_LEDGER_TTL_SECONDS controls record expiry. Structured output uses forced tools; OpenAI-compatible calls use a non-streaming request so Gemini tool calls survive its different finish-reason behavior. Google embeddings use Google credentials, fixing the TS adapter's accidental OpenAI-key selection (tracked as a deliberate difference in ADR-0019).

Metadata

Release files for render-lab-tasks-llm 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for render-lab-tasks-llm 0.1.1
File Size Uploaded Provenance Actions
render_lab_tasks_llm-0.1.1.tar.gz 20.9 kB With provenance Details for render_lab_tasks_llm-0.1.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for render-lab-tasks-llm 0.1.1
File Interpreter ABI Platform Actions
render_lab_tasks_llm-0.1.1-py3-none-any.whl Python 3 none any Details for render_lab_tasks_llm-0.1.1-py3-none-any.whl

Total release size: 51.1 kB

Release files / render_lab_tasks_llm-0.1.1.tar.gz

Download URL render_lab_tasks_llm-0.1.1.tar.gz
Size 20.9 kB
Tags Source
SHA-256 checksum
How to use checksums
c23632b8652f816aad86f7ee60e94457e3f38d5a4058ba95ee3091ea000e20af
BLAKE2b-256 checksum
How to use checksums
32dca4b968ea6d27968932a6a865a9a2c280420ce8134aec66220b37ff8f47e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Release files / render_lab_tasks_llm-0.1.1-py3-none-any.whl

Download URL render_lab_tasks_llm-0.1.1-py3-none-any.whl
Size 30.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2001ee4381e211c55fd729d22d933ca1d71838134b1c081566cbfbb8fbc98e38
BLAKE2b-256 checksum
How to use checksums
366bb7f470dd2870363f2d9ce2be5ef6fe13498a453c3e395230f055087c8e9b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

Security for render-lab-tasks-llm 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for render_lab_tasks_llm-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 7, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page