Skip to main content

ContextGem

Describe, don't prompt. ContextGem is a free, open-source framework that does the work around the models for you: you describe what to extract, and it handles the prompts, the data models, the source references and the justifications, with minimal code.

Upgrading from 0.x? ContextGem 1.0 renames and removes classes and parameters, changes some defaults and drops Python 3.10, so code and serialized data written for 0.x may need changes. Follow the migration guide.

uv add contextgem

Or, with pip: pip install -U contextgem. To convert PDF, DOCX and other files with Docling: uv add "contextgem[docling]".

  • Generates the prompts from your descriptions of what to extract: there are no prompts to write.
  • Returns typed, validated values: text, numbers, dates, booleans, labels, ratings and JSON objects.
  • Maps each extracted item back to the paragraphs or sentences of the document that it came from, and can give the reasoning behind it.
  • Takes files converted with Docling, e.g. PDF, DOCX, PPTX, XLSX and HTML, with their structure and the page of each paragraph.
  • Extracts in context: aspects, sub-aspects and concepts focus the model on the text that matters.
  • Runs as one declarative pipeline, reusable and serializable, with model routing, fallbacks and cost tracking.
  • Uses the right model for each question: cloud and local LLMs through LiteLLM where it takes reasoning, and decision models where a fast, low-cost answer is enough.
  • Gives the probability of each possible answer of a decision model, so that you set the threshold.
  • Fits into agentic workflows: extracts the metadata of documents at ingestion, runs as a tool that an agent calls, and decides the next step of a workflow, or the tools that an agent gets, with probabilities.
  • Is built for in-depth analysis of individual documents, not for cross-document querying or corpus-wide retrieval.

See the documentation for the quickstart, how it works, decision models and agentic workflows, the repository for the overview and the source, and the changelog for the version history.

For coding agents and LLMs, llms.txt indexes the documentation, with a Markdown copy of each page.

Licensed under Apache-2.0.

Metadata

Release files for contextgem 1.5.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 contextgem 1.5.1
File Size Uploaded Provenance Actions
contextgem-1.5.1.tar.gz 295.4 kB With provenance Details for contextgem-1.5.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for contextgem 1.5.1
File Interpreter ABI Platform Actions
contextgem-1.5.1-py3-none-any.whl Python 3 none any Details for contextgem-1.5.1-py3-none-any.whl

Total release size: 633.3 kB

Release files / contextgem-1.5.1.tar.gz

Download URL contextgem-1.5.1.tar.gz
Size 295.4 kB
Tags Source
SHA-256 checksum
How to use checksums
c93f372ceb1437d72e189e7febb3d722ab5ffea25a87059590a57b303e83d820
BLAKE2b-256 checksum
How to use checksums
772661d2c220fa25bb7d2cf5631e6576bb35de4d0d098d3f6bc499a85ee0e6fd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

Release files / contextgem-1.5.1-py3-none-any.whl

Download URL contextgem-1.5.1-py3-none-any.whl
Size 337.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ab665a4b5cb225f228d16d4d769f780ead67c63176b6ea7a9cd821741fb2a153
BLAKE2b-256 checksum
How to use checksums
79998b474ab3ea5f54c2dfbaf907291e882c85bb56f046240015f6ffdfaf8036
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

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 Nov 9, 2026.

Transparency log

Security for contextgem 1.5.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

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for contextgem-1.5.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 Nov 9, 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

1.5.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