# What Is ContextGem? Free Library, You Pay the LLM

By Halvor Kristiansen · 2026-10-27 · Source: https://www.activepieces.com/blog/what-is-contextgem-free-library-you-pay-the-llm

---
<aside class="tldr"><p class="tldr-label">Summary</p><p>ContextGem is a free, open source Python library that extracts structured data from documents through an LLM, with you paying the model provider's bills.</p><ul><li>Model costs vary 40-fold: Haiku $0.10 to Claude Opus $4 per million tokens. -</li><li>Extraction accuracy unproven on real documents; young library with unestablished track record.</li></ul></aside>

## Extract documents as structured data with ContextGem

### What ContextGem is in brief

ContextGem is a **free, open source Python library** that sends a document to a large language model (LLM) and returns the fields you asked for as structured data. It's new, and it runs inside your own code rather than as a hosted service.

Unlike [Activepieces](https://www.activepieces.com), which gives you a visual builder for workflows across its 746 integrations, ContextGem gives you no interface. You import it, define what to extract, and supply a model key, and **you pay the model bill**.

![A bare engine part beside a big unused control panel.](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/c555a329-6ee8-42b3-a28b-08aaf1b741af/what-is-contextgem-free-library-you-pay-the-llm-94c26b07.webp)

The author hosts the documentation on their own domain, [contextgem.shcherbak.ai](https://contextgem.shcherbak.ai/optimizations/optimization_long_docs).

The maker's pages gave no release date that could be confirmed, so none is stated here.

Read the facts below as a snapshot, because a young library changes quickly. They were checked on 2026-10-27 against the maker's documentation.

- ContextGem is a library for extracting structured data from documents with an LLM, described in the [documentation home](https://contextgem.shcherbak.ai/optimizations/optimization_long_docs).
- The documentation version reviewed was 1.4.1, shown on the [same documentation site](https://contextgem.shcherbak.ai/optimizations/optimization_long_docs). If your installed version differs, parts of what follows may not match your setup.
- The docs include configuration options for processing lengthy documents, on the [long-documents page](https://contextgem.shcherbak.ai/optimizations/optimization_long_docs).
- Facts checked on: 2026-10-27.

## What ContextGem does with documents, concepts and LLMs

Hand ContextGem a document and a list of concepts you want from it, and it passes both to an LLM you choose and returns a structured record with those fields filled in.

![Document and concept list going into an LLM box, structured record coming out](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/11655365-7363-4e1a-a285-717a6d3d18d7/what-is-contextgem-free-library-you-pay-the-llm-14e3dd40.webp)

The document and the labelled concept cards, such as party name and payment term, go into the LLM, and a filled-in record comes out.

The [Document class in the API docs](https://contextgem.shcherbak.ai/api/documents) represents a structured or unstructured file with written or visual content, which the library processes to extract information and analyse content. In practice, the document is the container you build once and pass through the extraction.

A concept is a declared piece of information you want out of the document: a party name, a payment term, a date. The [concepts API](https://contextgem.shcherbak.ai/api/concepts) is where you define these, and the [repository](https://github.com/shcherbak-ai/contextgem) hosts the code.

Because concepts are declared up front, the output shape is fixed before any model runs. Downstream code can rely on field names rather than parsing free text.

### Long documents and tool-using models

You pick which model plays the extraction role, and that choice is where your cost sits, because the library's free and the model provider bills you per call.

For long documents and for models that use tools, the maker's pages describe handling. The mechanics of either aren't confirmed here, so check the documentation for the version you install (the docs show 1.4.1) and test on one real file before planning around them.

## How to get ContextGem and what it costs

Whichever model provider you connect bills you for every document you run through it, and you also carry the cost of hosting the code. No fee is listed for the library.

The constraint first: ContextGem is a code library, so the machine running it needs a route to your chosen model provider. The install runs in four steps:

1. Check your Python version against the one the maker's install page requires, so you don't find the mismatch mid-install.
2. Run `pip install contextgem`.
3. Set your model provider's API key in the environment, which keeps it out of your source files.
4. Run the maker's quickstart example on one document.

Stop after step 4 and read the usage figures on your provider's dashboard. That gives you a measured cost per document instead of a guess.

Nothing is listed for the library itself. The maker publishes no per-document price, no hosting estimate and no support tier, so any monthly total has to be built from your own usage.

### LLM costs of running ContextGem

Set against the cheapest rate of $0.10, which is the floor for a high-volume job, the models below cost this much per million input tokens, according to [llmprice.io](https://llmprice.io/pricing), which means you can immediately see which models exceed this minimum.

Input rates vary far more than the library does.

| Model | Input price per million tokens | Multiple of the floor |
|---|---|---|
| [Gemini](https://gemini.google/subscriptions) 2.5 Flash-Lite | $0.10 | 1x |
| [Claude](https://claude.com/pricing) Haiku 5.5 | $0.10 | 1x |
| Mistral Small 4 | $0.15 | 1.5x |
| Gemini 3.5 Flash-Lite | $0.30 | 3x |
| Gemini 4 Argon | $2 | 20x |
| Claude Opus 5.5 | $4 | 40x (double Gemini 4 Argon) |

_Prices and plan limits checked against [contextgem.shcherbak.ai](https://contextgem.shcherbak.ai/api/documents) and [contextgem.shcherbak.ai](https://contextgem.shcherbak.ai/api/concepts) and [contextgem.shcherbak.ai](https://contextgem.shcherbak.ai/optimizations/optimization_long_docs) and [contextgem.shcherbak.ai](https://contextgem.shcherbak.ai/llms/chat_with_tools) and [docs.claude.com](https://docs.claude.com/en/docs/about-claude/models/overview) and [claude.com](https://claude.com/pricing) and [openai.com](https://openai.com/chatgpt/pricing) and [gemini.google](https://gemini.google/subscriptions) on October 27, 2026._

The practical consequence: **pick the model before you pick a budget.** Run your quickstart document on a cheap model first, and move up only if the extraction misses fields.

## Where ContextGem excels and remains unproven

On paper ContextGem looks strong, and **in practice it is unproven**: the strengths below come from the maker's own pages, and we haven't run the library ourselves.

The maker documents extraction of structured fields from documents through an LLM, driven from your own Python code. That's a design claim, not a result.

Whether it extracts your invoices or contracts accurately is something only your own test document will settle, which is why the cheap-model quickstart run comes first.

### Risks of adopting a new ContextGem project

Per [Sergii Shcherbak on LinkedIn](https://www.linkedin.com/posts/sergii-shcherbak-10068866_contextgem-has-just-crossed-100000-pypi-activity-7490387024726773760-p1LT), ContextGem's PyPI **downloads passed 10K, then 100K, and reached 131,044**. The chart shows those milestones arriving in bursts.

![How ContextGem's PyPI downloads have built up](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/a593ad85-2306-4f54-8a96-ed534cd4caf6/what-is-contextgem-free-library-you-pay-the-llm-68f353d6.svg "Source: Sergii Shcherbak on LinkedIn")

So the library has found real users, but a burst can come from a single mention or from automated installs and mirrors.

Downloads say people tried it; they say nothing about extraction quality.

With a short track record, interfaces may change between releases, and fewer people have hit and reported your edge cases. Pin the version you test and re-run your sample document before any upgrade.

![A new signpost moved from an earlier hole, few footprints.](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/77533add-842c-4104-b257-8177bc3ff5d5/what-is-contextgem-free-library-you-pay-the-llm-b7c9338e.webp)

Take from the table that every row is either the maker's word or an open question; none is verified by us. It sets each claim against where it comes from.

| Claim | Source or status |
|---|---|
| Handles structured extraction with an LLM | Maker's documentation |
| Short track record | Download milestones above |
| Code library only | Maker's documentation |
| Hosted option | None stated by the maker |
| Accuracy on your documents | Not tested by us |

## ContextGem compared with the established extraction options

For ContextGem, the Comparable options run inside your own code: hand-written prompts, LangChain and LlamaIndex, rather than hosted document-AI services.

### ContextGem and alternatives compared in a table

Since licence cost is zero for every code option, the table shows that the choice turns on who operates the pipeline and how much track record you need.

| | Licence and cost | Where it runs | Setup effort | Maturity | Model control |
|---|---|---|---|---|---|
| ContextGem | Free, open source; you pay your model provider | Your code and infrastructure | Moderate: install, define what to extract | New | You choose the model |
| Prompts plus structured-output API | No library fee; you pay the provider | Your code | Highest: you write prompts, schemas and validation | Rests on the provider's API | Full |
| LangChain | Free, open source; model fees apply | Your code | Moderate, with a broad framework to learn | Older, widely used | You choose the model |
| LlamaIndex | Free, open source; model fees apply | Your code | Moderate | Older, widely used | You choose the model |
| Hosted document-AI | Per-page fees | Vendor's cloud | Lowest | Established | Limited to what the vendor offers |

Only the hosted row has a per-page meter. [Horus Tech](https://www.horustech.dev/blog/intelligent-document-processing-cost.html) lists AWS Textract at $15 per 1,000 pages for forms up to the first million, so a 10,000-page batch costs $150.

Past one million pages that drops to $10 per 1,000, making high-volume processing cost-effective, so processing more pages doesn't escalate the per-page cost.

For expenses the rate is also $10 per 1,000 pages. Plain text is $1.50 per 1,000 for the first million, so the same 10,000 pages cost $15.

Over a million, text falls to $0.60 per 1,000, which makes plain OCR cheap at volume and form extraction the expensive line.

A rival is the better choice in three cases:

1. Choose hosted document-AI if nobody on your team will maintain extraction code. You pay per page, and the vendor carries the operations.
2. Choose LangChain or LlamaIndex if you already use one and need a track record more than a new interface.
3. Choose plain prompts with a structured-output API if your schema is one or two fields and a dependency is not worth it.

## Connect ContextGem to a workflow with Activepieces

You connect the two yourself, because Activepieces, an MIT-licensed open source tool for building automated workflows from triggers and steps, has no native ContextGem integration: none of the 746 integrations in its open source monorepo is one (checked 2026-10-27).

![Activepieces workflow builder with HTTP request step selected and its settings panel open showing method, URL, headers, and…](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/9e36e973-de4a-435f-8912-12e666216b2d/self-host-mistral-ai-enterprise-deployment-guide-3f7fe28d.webp)

Every route needs either code or hosting. The routes below are ordered from most dependable to most experimental, and each states what you must supply.

Constraint first: **ContextGem is a Python library, not a service**. Nothing among Activepieces' 746 integrations can import it. Whatever you choose, a process running ContextGem must exist somewhere you control, and it will call your model provider, so that traffic needs outbound access.

1. HTTP request step to a service you host
2. AI step with an OpenAI-compatible provider
3. MCP server for agent use

### Call ContextGem through a self-hosted HTTP service

You write a small web service that wraps ContextGem, with one endpoint that accepts a document and returns the extracted fields as JSON. Then the workflow's HTTP request step posts to it. This needs code and hosting, and you own both.

![Activepieces workflow builder showing a five-step automation flow for expense tracking with web form input, data…](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/7eded66e-07c4-4cee-80dc-00ab5cb668e6/what-is-contextgem-free-library-you-pay-the-llm-978d7ca3.webp)

You get extraction logic that stays in version-controlled Python, and the workflow only sees a request and a response.

It's also the route you can test without Activepieces at all, and on the free plan (unlimited flows, 1,000 credits a month) a run costs 1 credit however many steps the flow has.

### AI step with an OpenAI-compatible provider

Point Activepieces' AI step at a custom or OpenAI-compatible provider, and it could reach a gateway you host.

Activepieces takes your own AI keys from the Plus plan ($20 a month, 10,000 credits), and with your own key every AI step counts as 1 credit, against 2, 10 or 20 credits for a fast, smart or frontier model run on Activepieces' own allowance, while the model cost lands on your provider bill, the same bill ContextGem's calls already run up, which means you're paying both the monthly subscription and your provider's model costs.

But the step then talks to a chat-style endpoint, and ContextGem's extraction pipeline is not that.

You would still write and host the adapter that translates between them. This needs code and hosting, and it's the most indirect of the three, so I wouldn't start here.

### MCP server for agent use

You can expose ContextGem through an MCP server, a standard way to offer tools to an AI agent, and let an agent step in the workflow call it. This needs code and hosting too. It suits cases where an agent decides when to extract.

For a fixed, repeatable pipeline it adds a decision point you don't need, and I'd choose route 1.

## What to test when evaluating ContextGem

Run one document type through it on your own provider key, and judge the result against what you do today. Because the cost is your model bill and not a licence, the test is cheap and the order below keeps it that way:

1. Pick one document type, such as supplier contracts or invoices, so every result is comparable.
2. Define the fields you need from it, written down before you run anything.
3. Run 20 sample documents on your own provider key. That's few enough to read every output by hand, and enough to show whether a failure repeats or was a one-off.
4. Check the changelog and repository activity. For a young library, recent releases and answered issues tell you more than the feature list.
5. Compare accuracy and cost with your current method, using the same 20 documents.

Each step maps onto one of ContextGem's building blocks.

Step 1 becomes a document object holding the text of one file. Mixing formats makes a wrong answer impossible to attribute to the library, the model or the scan, so keep the sample to a single layout.

Step 2 becomes concepts: each field you want, with a description of what counts as a correct value.

Write the descriptions as you would for a new colleague. If your first result is poor, vague descriptions are the most likely cause, and that's your wording to fix, not a defect in the library.

If some of your 20 files are long, note how they behave separately. The [ContextGem documentation](https://contextgem.shcherbak.ai/llms/chat_with_tools) describes tool calling, where the model invokes Python functions during a conversation.

Leave that out of the first pass. It adds a moving part, and you want a baseline you can reproduce before adding one.

Whatever the five steps show, write it down; the decision rests on those numbers, not on the README, so if they conflict, the numbers win.

## Frequently asked questions

Where the maker's pages are silent, the answer says unknown; otherwise the answers below rest on the maker's own pages, the project's GitHub repository and its documentation.

### Cost and API keys

Is ContextGem free to use? Yes, the library is open source and carries no licence fee, according to the repository.

That covers the code only. Every extraction still runs through a model, so the bill comes from your model provider, and the repository can't tell you what that will be for your documents.

![Configuration panel for extracting structured data from invoices using AI in an Activepieces workflow.](https://ap-marketing-media.fra1.cdn.digitaloceanspaces.com/uploads/bd219e2f-1023-44ed-89be-dcf491f56e21/zap-vs-scenario-vs-workflow-choosing-the-right-a-00a26d13.webp)

Does ContextGem need an API key from an LLM provider? For hosted models, yes. The library calls the model you configure, so a cloud model needs that provider's key and is billed to that account.

The maker runs no hosted ContextGem service that supplies the model for you, and the documentation describes a code library you install and call.

### Local models and production readiness

Can ContextGem run with local models? The documentation describes support for local models alongside cloud ones, so a machine with no outbound internet isn't ruled out.

Whether extraction quality holds up on the local model you would choose is unknown. Test it on your own documents with the network disconnected before you commit.

Is ContextGem ready for production use? Unknown. The maker's pages don't offer a production guarantee, a support commitment or a long track record, and the project is new.

Treat it as a candidate to prove in a pilot, using the numbers you recorded, rather than as a settled choice.

### Workflow tools

Does Activepieces have a ContextGem integration? No. None of the 746 integrations in Activepieces' open source monorepo is one (checked 2026-10-27), and the ContextGem pages don't mention one either.

Because ContextGem is a code library, any connection to a workflow tool would be code you write and maintain yourself.

## Related reading

- [Migrating Your Prompt Library Out of Vellum With Automation](https://www.activepieces.com/blog/migrating-your-prompt-library-out-of-vellum-with-automation)

## References

- [Horus Tech](https://www.horustech.dev/blog/intelligent-document-processing-cost.html)
- [Sergii Shcherbak on LinkedIn](https://www.linkedin.com/posts/sergii-shcherbak-10068866_contextgem-has-just-crossed-100000-pypi-activity-7490387024726773760-p1LT)
- [llmprice.io](https://llmprice.io/pricing)
