Skip to content

AI & LLM Integration


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.txt file at a known URL gives any AI a one-page orientation to the API's conventions, authentication, and common pitfalls.
  • A high-level Python library, t3api-utils, that handles auth, license selection, pagination, and parallel loading — meaning the model can write a 20-line script instead of a 200-line one.
  • A public examples repository that the model can browse for working patterns.

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).
  • How to discover endpoints, parameters, and schemas via the OpenAPI spec.
  • Authentication and the licenseNumber requirement.
  • How to build report URLs for Google Sheets IMPORTDATA().
  • A worked Python example using t3api-utils.

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 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 and are case-insensitive. 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 curl or requests and 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:

  • Authenticationget_authenticated_client_or_error() handles credential prompts and session refresh.
  • License selectionpick_license() shows an interactive picker.
  • Parallel loadingload_all_data_sync() paginates through any collection endpoint in parallel and returns the full list.
  • Interactive outputinteractive_collection_handler() gives the user a CLI menu to inspect, filter, or export the result.

A typical AI-generated script ends up being ~20 lines because the library absorbs the boilerplate. Point the model at the docs URL above and it will pick up the patterns.

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


Which AI models can actually load these URLs?

A URL is only useful if the model can fetch it. Behavior depends on the surface, not just the model:

Surface Can fetch URLs? Notes
ChatGPT (chatgpt.com) Yes Built-in browsing is on by default for current models.
Claude.ai Yes Has a built-in web fetch / search tool.
Gemini (gemini.google.com) Yes Grounded via Google Search.
Claude Code (CLI) Yes Has WebFetch and WebSearch tools.
Cursor, Windsurf, Copilot Chat Usually yes Agentic modes can fetch URLs; ask the agent to read the URL explicitly.
Bare API calls (no tool use configured) No A raw call to the Claude / OpenAI / Gemini API will not fetch URLs unless you wire up a fetch tool yourself, or you fetch the content and include it in the prompt.

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/ to learn how to use the T3 API and the t3api-utils library.

Write me a single Python script, using PEP 723 inline dependencies, that:

  1. Authenticates to the T3 API.
  2. Lets me pick a license interactively.
  3. Loads all [active packages] for that license.
  4. [Writes them to a CSV file with columns label, item.name, quantity, unitOfMeasureName.]

Use t3api-utils for the auth, license picker, and parallel data loading. Keep the script short.

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 uv script 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:

  1. Accepts a licenseNumber and an optional date range.
  2. Calls [/v2/packages/active] with the appropriate query parameters.
  3. 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/active and 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 Packages endpoint.

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&parameter=LicenseNumber

3. https://classvsoftware.github.io/t3api-python-utils/
   For Python scripts, use the `t3api-utils` library — it handles auth,
   license selection, pagination, and parallel loading.

4. https://github.com/classvsoftware/t3-api-examples
   Working example scripts. Look here for patterns before writing new code.

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.
- 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 licenseNumber requirement.
  • See API Scripts for the broader list of T3 Python libraries (t3api, t3api-utils, t3py).
  • 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.