Skip to main content

LangChain tools for ZeroGPU: A compute-efficient inference provider for apps and agents — purpose-built small and nano language models on an edge network that run the repeatable tasks frontier models shouldn’t, ~10x faster and 50%+ cheaper. Auto-scaling, with zero GPU infrastructure. Plug in and you’re live.

Project description

ZeroGPU

langchain-zerogpu

LangChain tools for ZeroGPU.

ZeroGPU is a compute-efficient inference provider for apps and agents. We run purpose-built small and nano language models across an edge network for the high-volume tasks you run constantly — classification, extraction, moderation, routing, summarization — at ~10x lower latency and 50%+ lower cost than frontier-model workflows. Auto-scaling, with zero GPU infrastructure to manage. Plug in and you're live.

This package exposes those models as first-class LangChain BaseTool subclasses, so any LangChain agent — including create_agent and LangGraph graphs — can offload these repeatable NLP tasks (classification, summarization, entity / JSON extraction, PII redaction, and short chat) to ZeroGPU instead of spending frontier-model tokens.

All calls go through the official zerogpu-api Python SDK.

Install

pip install langchain-zerogpu

Authenticate

Every request needs a ZeroGPU API key (starts with zgpu-api-) and a project id. Provide them via environment variables:

export ZEROGPU_API_KEY="zgpu-api-..."
export ZEROGPU_PROJECT_ID="your-project-id"

…or pass them directly to any tool or the toolkit:

from langchain_zerogpu import ZeroGPUSummarizeTool

tool = ZeroGPUSummarizeTool(api_key="zgpu-api-...", project_id="your-project-id")

The API key is stored as a pydantic.SecretStr and is never logged.

The tools

Tool class ZeroGPU model Purpose
ZeroGPUChatTool LFM2.5-1.2B-Instruct Short single-turn chat reply
ZeroGPUChatThinkingTool LFM2.5-1.2B-Thinking Chat with a visible reasoning trace
ZeroGPUSummarizeTool llama-3.1-8b-instruct-fast Condense a passage
ZeroGPUClassifyIABTool zlm-v1-iab-classify-edge IAB taxonomy classification
ZeroGPUClassifyIABEnrichedTool zlm-v1-iab-classify-edge-enriched IAB + topics / keywords / intent
ZeroGPUClassifyZeroShotTool deberta-v3-small Zero-shot vs. custom labels
ZeroGPUClassifyStructuredTool gliner2-base-v1 Multi-axis schema classification
ZeroGPUExtractEntitiesTool gliner2-base-v1 Custom-label NER
ZeroGPUExtractPIITool gliner-multi-pii-v1 Extract PII entities (JSON)
ZeroGPURedactPIITool gliner-multi-pii-v1 Mask PII inline with [LABEL]
ZeroGPUExtractJSONTool gliner2-base-v1 Schema-driven JSON extraction

Quick start

from langchain_zerogpu import ZeroGPUClassifyZeroShotTool

tool = ZeroGPUClassifyZeroShotTool()  # reads creds from the environment

print(tool.invoke({
    "text": "The new GPU smashes every benchmark we threw at it.",
    "labels": ["tech", "politics", "sports"],
}))

Tools work asynchronously too:

result = await tool.ainvoke({"text": "...", "labels": ["a", "b"]})

Bind the tools to an agent

Use the toolkit to get all eleven tools — wired to a single shared client — and bind them to an agent:

from langchain.agents import create_agent
from langchain_zerogpu import ZeroGPUToolkit

toolkit = ZeroGPUToolkit()  # reads ZEROGPU_API_KEY / ZEROGPU_PROJECT_ID
tools = toolkit.get_tools()

agent = create_agent("anthropic:claude-sonnet-4-6", tools=tools)

agent.invoke({
    "messages": [
        {"role": "user", "content": "Redact the PII in: 'Call Jane at 555-0100.'"}
    ]
})

Or bind a single tool to a chat model directly:

from langchain.chat_models import init_chat_model
from langchain_zerogpu import ZeroGPUExtractPIITool

llm = init_chat_model("anthropic:claude-sonnet-4-6")
llm_with_tools = llm.bind_tools([ZeroGPUExtractPIITool()])

Errors

Failures surface as clear, typed exceptions instead of raw stack traces:

  • ZeroGPUAuthError — missing / malformed credentials, 401, or 403.
  • ZeroGPUError — rate limits (429), server errors (5xx), and network failures.

Development

make install            # uv sync --all-groups
make lint               # ruff check + format --check
make mypy               # mypy (disallow_untyped_defs)
make test               # unit tests, sockets disabled
make integration_test   # integration tests (needs real ZeroGPU creds)

License

MIT — see LICENSE.

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

langchain_zerogpu-0.2.3.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

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

langchain_zerogpu-0.2.3-py3-none-any.whl (16.4 kB view details)

Uploaded Python 3

File details

Details for the file langchain_zerogpu-0.2.3.tar.gz.

File metadata

  • Download URL: langchain_zerogpu-0.2.3.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for langchain_zerogpu-0.2.3.tar.gz
Algorithm Hash digest
SHA256 433c72a7b9bfd7a3d7faa239835045de115ae5c17758cbdb45df325c8462f3e4
MD5 66b64ff26db9b6cfefcfeb4a16b4f4e1
BLAKE2b-256 ec3a6ed5a3268ecf034965f9c27b6265b16db31ee1f7d97bfd5a166398e6a17c

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_zerogpu-0.2.3.tar.gz:

Publisher: release.yml on zerogpu/langchain-zerogpu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file langchain_zerogpu-0.2.3-py3-none-any.whl.

File metadata

File hashes

Hashes for langchain_zerogpu-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 a45cf4cb1a849a2d031daea4097e4a54bf98e56efb91a9bc0950152a4122deda
MD5 57c327b859c8dabe2ea2f34516a629c6
BLAKE2b-256 515c00273e620b5088f574f1e8689d7c39115a3c2d9576453985147557a600cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for langchain_zerogpu-0.2.3-py3-none-any.whl:

Publisher: release.yml on zerogpu/langchain-zerogpu

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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