# AI use cases for Type LLM (TypeLLM/TypeLLM)

Repo: [TypeLLM/TypeLLM](https://github.com/TypeLLM/TypeLLM) | Use cases: 4 | Page: https://dedupedai.com/use-cases/typellm-typellm/

TypeLLM is a Python library that makes open autoregressive LLMs return type-safe answers (strings, numbers, booleans, enum choices, objects and arrays) by constraining generation with JSON Schema, either through the hosted TypeLLM API or a model you serve with SGLang.

This file holds every use case of this repo. Each one starts with a "## " heading and ends with its URL.

- Extract typed fields from receipts into structured data: https://dedupedai.com/use-cases/typellm-typellm/extract-receipt-fields-as-typed-data/
- Route support tickets to the right team with fixed choices: https://dedupedai.com/use-cases/typellm-typellm/route-support-tickets-to-a-team/
- Pull every line item from a document into a typed list: https://dedupedai.com/use-cases/typellm-typellm/extract-line-items-from-documents/
- Run typed extraction on your own GPU to keep data in-house: https://dedupedai.com/use-cases/typellm-typellm/run-typed-extraction-on-your-own-gpu/

## How to extract typed fields from receipts into structured data with Type LLM

Repo: [TypeLLM/TypeLLM](https://github.com/TypeLLM/TypeLLM) | Difficulty: Intermediate | Time: 15 minutes | Basis: From the README

Turn receipt text or images into merchant, total, expense type and reimbursable flags as typed values.

**Who it is for:** An finance or operations analyst who must turn many receipts into rows for expense reports and needs every field in the right type.

**The problem:** Free-text model output is hard to load into a spreadsheet or database because amounts, categories and yes/no answers arrive in inconsistent formats.

**The outcome:** Each receipt returns a dict with a string merchant, a float total, one enum expense type, and a boolean reimbursable value, ready to load.

### Steps

1. Run `pip install -U typellm`
2. Run `export TYPELLM_API_KEY="tl-sk-..."` with your key from the API keys page
3. Create a TypeLLMClient with your key and call generate() with the receipt text as context
4. Define questions with type string, number and boolean, and an enum of expense types such as meal, travel and equipment
5. Read the typed values from response.result and write them to your expense table

### Prompt to paste into your agent

```text
Use the Python package typellm in the repo TypeLLM/TypeLLM to extract merchant, total, expense_type and reimbursable from the receipt text at <receipt_path>. Call TypeLLMClient.generate() with an enum for expense_type and return response.result as JSON. Verify that expense_type is one of the enum values and total is a number.
```

### Caveat

The README example uses a text receipt; for scanned receipts, the README shows image input with a vision-language model, so check that your chosen model supports images before you rely on it.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/typellm-typellm/extract-receipt-fields-as-typed-data/

## How to route support tickets to the right team with fixed choices with Type LLM

Repo: [TypeLLM/TypeLLM](https://github.com/TypeLLM/TypeLLM) | Difficulty: Intermediate | Time: 15 minutes | Basis: From the README

Assign each incoming ticket to one team from a fixed list, with a description for each choice.

**Who it is for:** A support lead whose tickets arrive unsorted and who needs each one assigned to billing, technical, shipping or another queue without invented team names.

**The problem:** Model answers can name teams that do not exist, which sends tickets to queues nobody watches.

**The outcome:** Each ticket gets exactly one queue value from the list you define, so the routing step only sees valid teams.

### Steps

1. Run `pip install -U typellm`
2. Run `export TYPELLM_API_KEY="tl-sk-..."` or start your SGLang server and pass its URL to TypeLLMClient
3. Define a queue question with type string and a choices list where each item has a value and a description
4. Call generate() with the ticket text as context for each ticket
5. Send each ticket to the queue named in response.result

### Prompt to paste into your agent

```text
In the TypeLLM/TypeLLM repo, call TypeLLMClient.generate() on each ticket in <tickets_file> with a queue field whose choices are billing, technical, shipping and other, each with a description. Return a list of ticket IDs with their queue. Verify that every queue value is one of the four choices.
```

### Caveat

The README says choices take optional descriptions and that enum allows 2 to 26 values, so keep your team list inside that range.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/typellm-typellm/route-support-tickets-to-a-team/

## How to pull every line item from a document into a typed list with Type LLM

Repo: [TypeLLM/TypeLLM](https://github.com/TypeLLM/TypeLLM) | Difficulty: Intermediate | Time: 30 minutes | Basis: From the README

Return a variable-length array of typed objects, such as one object per invoice line.

**Who it is for:** A data engineer who must load invoices or order forms where the number of line items changes from document to document.

**The problem:** Fixed-field extraction cannot handle a document with an unknown number of rows, and parsing free text into rows is fragile.

**The outcome:** One call returns a list where each item is a dict with the fields you defined, one item per line in the document.

### Steps

1. Run `pip install -U typellm`
2. Create a TypeLLMClient for the Type LLM API or for your SGLang server
3. Define a question with type array and items that describe each line's typed properties
4. Call generate() with the document text as context
5. Load the returned list of dicts into your table

### Prompt to paste into your agent

```text
Using the TypeLLM/TypeLLM package, extract every line item from <document_path> as an array of objects with description, quantity and unit_price. Return the list from response.result. Verify the count of items matches the number of line rows you can see in the document.
```

### Caveat

The README gives different item limits for the hosted API (200 items a call) and self-hosted use (50 items a call in its comparison table), so split very long documents into batches.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/typellm-typellm/extract-line-items-from-documents/

## How to run typed extraction on your own GPU to keep data in-house with Type LLM

Repo: [TypeLLM/TypeLLM](https://github.com/TypeLLM/TypeLLM) | Difficulty: Advanced | Time: 2 hours | Basis: From the README

Serve Qwen3.8-27B with SGLang and point Type LLM at it so documents never leave your server.

**Who it is for:** A team that cannot send internal documents to a hosted API and already has a GPU server.

**The problem:** Hosted services may not be acceptable for confidential records, but free-text output still needs schema guarantees.

**The outcome:** Type LLM sends the same typed requests to a local SGLang endpoint and returns typed results from your own model.

### Steps

1. Follow the Qwen3.8-27B SGLang deployment guide linked in the README to start the server with prefix caching enabled
2. Run `pip install -U typellm`
3. Create TypeLLMClient("http://127.0.0.1:30000", model="Qwen/Qwen3.8-27B") with your server URL
4. Call generate() with your questions and context as in the README example
5. Check response.result against a few documents you already know the answers to

### Prompt to paste into your agent

```text
Set up TypeLLM/TypeLLM against an SGLang server at <server_url> serving Qwen/Qwen3.8-27B. Run TypeLLMClient.generate() on <document_path> with the questions in <questions_file> and return response.result. Verify that the model returned values for every field and no value falls outside its enum.
```

### Caveat

The README notes that on your own server no service limits apply, and a thinking field without a thinking_budget may reason until the context is full, so set a budget for thinking fields.

Disclaimer: Third-party repos we don't own or vouch for. AI-generated use cases can be wrong: review everything and run at your own risk. Full text: https://dedupedai.com/disclaimer/

URL: https://dedupedai.com/use-cases/typellm-typellm/run-typed-extraction-on-your-own-gpu/
