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.

Licensed under Apache-2.0.

Metadata

Release files for contextgem 1.2.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.2.1
File Size Uploaded Provenance
contextgem-1.2.1.tar.gz 264.9 kB With provenance Details

Built distribution (wheel)

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

Total release size: 570.7 kB

Release files / contextgem-1.2.1.tar.gz

Download URL contextgem-1.2.1.tar.gz
Size 264.9 kB
Tags Source
SHA-256 checksum
How to use checksums
5d2b9c819ab9e06f987e69cc722ae8f617f828a5ef298183879b7565ff967657
BLAKE2b-256 checksum
How to use checksums
92b70fb4d62586b422229719a812771982af7748806f6bd7c29414771823ef15
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 Oct 22, 2026.

Transparency log

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

Download URL contextgem-1.2.1-py3-none-any.whl
Size 305.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5e4de683a0bd6b54828120f111f7069d7c994ca051d576313f4b7ffd66f5a8b9
BLAKE2b-256 checksum
How to use checksums
864d068680c158d5c751641fda23986466fad20e7518dbc538d99741e34ba8ff
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 Oct 22, 2026.

Transparency log

Security for contextgem 1.2.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 contextgem-1.2.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 Oct 22, 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.2.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