After this page an agent or a CI job can install @tutorflow/cli, give it a key, pick the classroom it works in, and script it with JSON output.
What the TutorFlow CLI Does
The TutorFlow CLI (@tutorflow/cli, executable tutorflow) wraps the Content API
and the Agent Platform account routes in shell commands. AI agents, CI jobs, and
local scripts can use it to generate courses, slide decks, tests, modules, videos,
games, and simulations, grade learner answers, manage learners and webhooks, and
handle registration and billing, without writing an HTTP client.
This page describes version 0.5.0. Content commands call
/v1/content/classrooms/{classroomId}/... with a tf_content_ key. Account and
discovery commands call /v1/platform/agent/*, /v1/platform/health,
/v1/platform/pricing-catalog, and /v1/platform/.well-known/agent.json.
Install @tutorflow/cli
The CLI needs Node.js 18 or later.
Run it without a global install:
Running tutorflow with no arguments prints the help and exits with status 1.
Authenticate the CLI
The CLI takes a tf_content_ key. You get one in either of two ways:
tutorflow agent registercreates an agent account and saves the returnedcontentApiKeyto the local config. See Agent Account and Billing CLI.- Create a key in the Agent Platform dashboard, then save it:
tutorflow auth login --api-key tf_content_...
tutorflow auth whoamiauth whoami makes no network call. It shows the masked key, its kind, the base
URL, and whether the key came from the environment or the config file. Use
tutorflow platform health to check that the API accepts the key.
| Key prefix | What it works with |
|---|---|
tf_content_ | Every command. Account commands (agent account, agent billing ...) need a live key with every classroom and every scope, like the one registration returns. |
tf_content_test_ | Content commands, in the sandbox classroom only. Nothing is charged. learner commands and account commands refuse it. |
tf_platform_ (legacy) | agent and platform commands only. Content commands, credits, classroom, and webhook refuse it with EPLATFORMKEY before calling the API. |
The CLI sends the key as Authorization: Bearer <apiKey>. auth login without
--api-key reads TUTORFLOW_API_KEY, or prompts for the key on a terminal.
auth logout deletes the config file; it asks for confirmation, or takes
--force in non-interactive mode.
Choose the Classroom
Every content command acts in one classroom. The CLI picks it in this order, first match wins:
- The global
--classroom <id>flag. TUTORFLOW_CLASSROOM_ID.classroomIdin the config file (tutorflow config set classroomId <id>).GET /v1/platform/agent/account:sandboxClassroomIdfor a test key,defaultClassroomIdotherwise.GET /v1/content/classrooms, when the account route refuses the key: the only classroom the key reaches, or the sandbox classroom for a test key. If the key reaches several, the command exits with status2and codeECLASSROOMand lists them.
tutorflow classroom list shows the classrooms the key can reach. Pinning a
classroom with --classroom or TUTORFLOW_CLASSROOM_ID also saves the account
lookup on every call.
Configuration
The config file is ~/.tutorflow/config.json, written with mode 0600.
tutorflow config get
tutorflow config get classroomId
tutorflow config set baseUrl https://api.tutorflow.io| Config key | Meaning |
|---|---|
apiKey | The API key. config get prints it masked. |
baseUrl | API origin. Default https://api.tutorflow.io. |
classroomId | Classroom for content commands. |
workspace | Left over from 0.3; unused. |
Environment variables win over the config file. An empty variable counts as unset.
| Variable | Description |
|---|---|
TUTORFLOW_API_KEY | API key for authenticated requests |
TUTORFLOW_BASE_URL | API origin, for example a staging host |
TUTORFLOW_CLASSROOM_ID | Classroom for content commands |
TUTORFLOW_JSON | Set to 1 for JSON output, like --json |
TUTORFLOW_DEBUG or DEBUG | Set to 1 to print stack traces on errors, like --debug |
TUTORFLOW_POLL_INTERVAL_MS | Poll interval for --wait, in milliseconds. Default 3000. |
Use JSON and Non-Interactive Mode
Put --json before or after the subcommand:
tutorflow --json platform pricing
tutorflow course list --jsonIn JSON mode:
- Each result is one JSON line on stdout. The examples in these docs are pretty-printed.
- Errors are one JSON line on stderr.
- Status and progress lines are not printed.
- The CLI never prompts. A missing argument fails with
ENOINTERACTIVE, anddeleteandremovecommands need--yes.
Without a terminal, the CLI does not prompt either.
Example error output in JSON mode:
{
"error": {
"message": "API error 402 content_payment_required: <message from the API>",
"code": "EHTTP_402",
"status": 402,
"apiCode": "content_payment_required",
"requestId": "req_...",
"hint": "Add credits: `tutorflow agent billing session` (needs a verified email) or `tutorflow agent billing x402-deposit --amount-usd <n>`. Check the balance with `tutorflow credits balance`."
}
}API errors use the code EHTTP_<status> and can carry apiCode, requestId,
retryAfterSeconds, requiredScope, validation, and hint. Other codes the CLI
sets itself include EAUTH (no key), EINVAL (a bad flag or argument),
ENETWORK, ECLASSROOM, EPLATFORMKEY, ETIMEOUT, and ERUNFAILED.
| Exit status | Meaning |
|---|---|
0 | Success |
1 | API, network, or authentication error, a failed run, or a --wait timeout |
2 | Usage error: unknown option, missing argument, invalid value, ENOINTERACTIVE, or ECLASSROOM |
130 | Cancelled at a prompt |
TutorFlow CLI Command Groups
| Command | Purpose | Page |
|---|---|---|
tutorflow course, slide, test, module | Generate and manage courses, slide decks, tests, and interactive modules | Content Generation CLI |
tutorflow video | Create videos, edit scenes, narrate, and render | Content Generation CLI |
tutorflow game, simulation | Create, plan, build, and revise games and simulations | Content Generation CLI |
tutorflow run | Follow, wait for, and resume generation runs | Content Generation CLI |
tutorflow evaluate, evaluation | Grade a learner answer; read past evaluations and mastery | Content Generation CLI |
tutorflow learner | List, invite, and remove classroom learners | Content Generation CLI |
tutorflow webhook | Manage Content API webhook endpoints | Content Generation CLI |
tutorflow classroom, credits | List classrooms; read the AI Credit balance and history | Content Generation CLI |
tutorflow agent | Register, read the account, verify email, billing, and checkout | Agent Account and Billing CLI |
tutorflow platform | Manifest, pricing, key health, and old share links | Platform Discovery CLI |
tutorflow auth, config | Store and inspect local credentials and settings | This page |
Changes in 0.5.0
- New on every content resource:
share <id>, which makes it open by link and printspublicUrl, andvisibility <id> <value>. See Commands Every Resource Shares. video create --visibilityalso takesUNLISTED.
Changes in 0.4.0
0.4.0 moved the content commands from the removed /v1/platform content routes to
the Content API. If you used 0.3.x:
- Content commands need a
tf_content_key; atf_platform_key fails withEPLATFORMKEY.agent registernow savescontentApiKey. course,slide,test, andmoduleusegenerate(aliascreate), which returns a run. Add--waitto get the finished resource.- Flags changed:
course generate --lessonsis now-n(-lis--language),slide generate --themetakes a theme id, andmoduleandtestlost the 0.3 options such as--title,--target,--locale,--private,--no-quiz,--classroom-id,--tier,--mode, and--time-limit. Use the global--classroominstead of--classroom-id. video createtakes--titleand one--scene <script>per scene instead of a prompt with--scenes,--ratio, and--duration. Render withvideo render --generate-missing-narration --wait.- Removed:
test edit-token, the--openflag on create, and--offsetand--statusonlist. Useopen <id>for the editor and public URLs, and--pageand--searchonlist. - New:
classroom,run,game,simulation,evaluation,learner,webhook,credits,video scene,video narrate,video render,deleteon every resource,agent billing x402-deposit,platform share-redirect, and the global--classroom.