AI & LLM Integration¶
The T3 API is designed to be consumed by AI models and coding agents as easily as it is consumed by humans. This page is for users who want a programmatic solution, have access to an AI model (ChatGPT, Claude, Gemini, Cursor, Claude Code, Copilot, etc.), and want to know how to point it at the T3 API and get useful output.
You do not need to know how the API works in detail. You just need to tell the model where to look.
Why the T3 API works well with AI¶
- A published OpenAPI spec describes every endpoint, parameter, and response. An AI model can read this and write correct code against any endpoint without guessing.
- A spec-pruning endpoint lets you (or the model) fetch only the slice of the spec that is relevant to the task, keeping prompts small and cheap.
- An
llms.txtfile at a known URL gives any AI a one-page orientation to the API's conventions, authentication, and common pitfalls. - This wiki, as Markdown. Every page has a Markdown copy, indexed by the wiki's own
llms.txt, so a model can read the docs without paying for HTML. - A high-level Python library,
t3api-utils, that handles auth, license selection, pagination, and safe writes, meaning the model can write a 10-line script instead of a 200-line one. - A public examples repository that the model can browse for working patterns, with a style guide written for coding assistants as well as people.
Which approach do you need?¶
There are two common goals. The resources below serve both; the difference is in how you prompt the model.
| Goal | Audience | Typical prompt | Best fit |
|---|---|---|---|
| One-off Python script, "dump all my active packages to CSV", "pull tomorrow's incoming transfers" | Operators, analysts, anyone who can run uv run script.py | "Write me a Python script that does X" | t3api-utils + llms.txt |
| Direct HTTP integration, building an app, an internal service, or a workflow that talks to T3 from a non-Python stack | Developers, agents working in a real codebase (Cursor, Claude Code, etc.) | "Add a function that calls T3's /v2/packages/active endpoint" | OpenAPI spec + llms.txt |
Resources the API publishes for AI consumption¶
llms.txt, the quickstart for agents¶
https://api.trackandtrace.tools/llms.txt
llms.txt is an emerging convention (see llmstxt.org) for giving AI agents a single plain-text orientation file. T3's llms.txt covers:
- What the T3 API is (and what it is not; it's not the Metrc 3rd party API).
- Rules for agents: fetch a pruned spec instead of guessing, authenticate, pass
licenseNumber, and remember that writes are a dry run unlesssubmit=true. - The spec's pruning filters.
- A short Python script using
t3api-utils2.1, and links to its guides. - Links into this wiki.
This file is the single most useful URL to give an AI model that has never seen the T3 API before. Many agents will fetch and follow it automatically when you mention it.
The wiki, as Markdown¶
https://wiki.trackandtrace.tools/llms.txt
Every page of this wiki is also published as Markdown, which costs a model far fewer tokens than the HTML page. Add index.md to a page's URL to get it, for example https://wiki.trackandtrace.tools/t3-api/openapi/index.md. The wiki's llms.txt lists every page. llms-full.txt holds the whole wiki in one file, which is too large for most prompts.
The OpenAPI spec, the source of truth¶
https://api.trackandtrace.tools/v2/spec/openapi.json
The full spec describes every endpoint, every parameter, every request/response schema. It is large, feeding the entire document into an AI prompt wastes tokens and buries the signal.
Instead, use the pruning filters to fetch just the slice you need:
?path=/v2/packages/active Single endpoint + its referenced schemas
?tag=Packages Every endpoint with a given tag
?schema=MetrcPackage A specific data model + its dependencies
?parameter=LicenseNumber A specific reusable query parameter
Filters combine; path must match exactly, and the others ignore case. Full filter reference and examples are on the OpenAPI Spec page.
When you prompt an AI, you can either:
- Hand it the URL and let it fetch the pruned spec itself (works in Claude, ChatGPT with browsing, Cursor, Claude Code, etc.).
- Fetch it yourself with
curlorrequestsand paste the JSON into the prompt.
t3api-utils, the high-level Python helper¶
Docs: https://classvsoftware.github.io/t3api-python-utils/ Repo: https://github.com/classvsoftware/t3api-python-utils
t3api-utils is the recommended library for AI-generated scripts. It handles the parts of the API that are tedious to write from scratch:
- Authentication:
t3api loginsaves a secret key once, andt3.connect()finds it and returns a client. - License selection:
client.pick_license()shows an interactive picker, orclient.licenseuses the saved default. - Parallel loading:
client.collect()loads every page of any collection in parallel and returns the full list. - Safe writes: writes are a dry run unless
submit=True, andclient.bulk()checks every row before sending any. - Reports:
client.report()downloads a server-side report, andclient.report_url()builds a Google SheetsIMPORTDATA()URL.
A typical AI-generated script ends up being ~10 lines because the library absorbs the boilerplate. Point the model at the docs URL above and it will pick up the patterns.
Version 2 is a rewrite that shares no code with 1.x. A model trained on older examples may write 1.x calls such as get_authenticated_client_or_error(). Tell it to use 2.1 or later.
t3-api-examples, a corpus of working scripts¶
https://github.com/classvsoftware/t3-api-examples
A public repo of working, runnable example scripts. Agents that can browse GitHub (Cursor, Claude Code, ChatGPT with browsing) will often find the closest example here and adapt it rather than writing from scratch. Useful to drop into a prompt as "here's a similar example, follow this pattern."
Style guide: https://github.com/classvsoftware/t3-api-examples/blob/master/STYLE_GUIDE.md
The repo's style guide is written for AI coding assistants as well as people. It sets the rules every example follows: standard flags such as --license and --sandbox, checking input before writing, a dry run and a confirmation before anything reaches Metrc, and a results log for every write. It ends with copy-ready templates. Give it to a model writing a script that other people will run or schedule.
Will the model load these URLs?¶
A URL is only useful if the model can fetch it. Rule of thumb: if you are using a chat UI or a coding agent, paste the URL and ask the model to read it. If you are calling a model API directly in your own code, fetch the URL yourself with curl or requests and include the response body in the prompt.
If a model refuses or fails to fetch a URL, the fallback is always the same: curl the URL into a file and paste the contents.
Sample prompts¶
These are starting points. Adapt the bracketed parts.
Track 1, "Write me a one-off Python script"¶
For an operator who wants a single script to run with uv run script.py.
Read https://api.trackandtrace.tools/llms.txt and https://classvsoftware.github.io/t3api-python-utils/getting-started/ to learn how to use the T3 API and the
t3api-utils2.1 library.Write me a single Python script, using PEP 723 inline dependencies, that:
- Authenticates to the T3 API.
- Lets me pick a license interactively.
- Loads all [active packages] for that license.
- [Writes them to a CSV file with columns
label,item.name,quantity,unitOfMeasureName.]Use
t3api-utilsfor the auth, license picker, and parallel data loading. Keep the script short.
For a script that changes Metrc data, or that someone else will run or schedule, add:
Follow the conventions in https://github.com/classvsoftware/t3-api-examples/blob/master/STYLE_GUIDE.md, starting from its templates.
Tighter variant (when you know the exact endpoint):
Read https://api.trackandtrace.tools/llms.txt and the pruned spec at https://api.trackandtrace.tools/v2/spec/openapi.json?path=/v2/transfers/incoming/active
Write a
uvscript that pulls all incoming active transfers and prints the manifest number and ETA for each one.
Track 2, "Integrate the T3 API into my app"¶
For a developer adding T3 calls to an existing service. Best run inside a coding agent (Cursor, Claude Code, etc.) so the model can edit your codebase directly.
The T3 API is documented at https://api.trackandtrace.tools/v2/docs and the OpenAPI spec is at https://api.trackandtrace.tools/v2/spec/openapi.json. Read https://api.trackandtrace.tools/llms.txt for an overview of conventions and authentication.
Add a function to [
src/integrations/t3_client.ts] that:
- Accepts a
licenseNumberand an optional date range.- Calls [
/v2/packages/active] with the appropriate query parameters.- Returns a typed list of packages.
Before writing the function, fetch the pruned spec for just that endpoint:
https://api.trackandtrace.tools/v2/spec/openapi.json?path=/v2/packages/activeand use it to derive the exact parameter names and the response type.
Spec-driven code generation:
Fetch https://api.trackandtrace.tools/v2/spec/openapi.json?tag=Packages and generate [TypeScript] type definitions for every schema referenced, plus a thin fetch wrapper for each
Packagesendpoint.
Reusable system prompt / agent instructions¶
Drop this into a Cursor .cursorrules file, a Claude Code CLAUDE.md, an OpenAI system prompt, or any equivalent, anywhere your agent reads project-level instructions.
This project integrates with the T3 API (https://api.trackandtrace.tools).
Authoritative resources, in order of preference:
1. https://api.trackandtrace.tools/llms.txt
One-page orientation: what the API is, auth model, conventions.
2. https://api.trackandtrace.tools/v2/spec/openapi.json
Full OpenAPI 3.0.2 spec. Always fetch a PRUNED subset, not the whole
document. Use ?path=, ?tag=, ?schema=, or ?parameter= filters.
Filters are combinable. Example:
?path=/v2/packages/active¶meter=LicenseNumber
3. https://classvsoftware.github.io/t3api-python-utils/getting-started/
For Python scripts, use the `t3api-utils` library, version 2.1 or later;
it handles auth, license selection, pagination, and safe writes. Do not
write 1.x code.
4. https://github.com/classvsoftware/t3-api-examples/blob/master/STYLE_GUIDE.md
How T3 example scripts are written: flags, input checks, dry run and
confirmation before any write. The repo's scripts are working examples.
5. https://wiki.trackandtrace.tools/llms.txt
Every T3 wiki page as Markdown: the API, reports, labels, and more.
Rules:
- Never guess endpoint paths, parameter names, or response shapes. Fetch the
pruned OpenAPI spec for the endpoint first.
- Almost every data endpoint requires a `licenseNumber` query parameter.
- Writes to Metrc are a dry run unless `submit=true` is passed.
- This is NOT the Metrc 3rd party API. Do not use Metrc API keys.
Next Steps¶
- Read the full OpenAPI Spec page for the complete pruning filter reference.
- Walk through Getting Started to understand authentication and the
licenseNumberrequirement. - See API Scripts for running scripts with uv, trying them in the Metrc sandbox, and the example scripts.
- Browse Supercollections and Reports; both are well-suited to AI-generated scripts because they collapse multi-step workflows into single calls.
- If you're not subscribed to T3+, start your 30-day free trial here.