TutorFlow CLI Overview

Install and configure @tutorflow/cli to generate TutorFlow content, manage the agent account, and script it all with JSON output.

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 register creates an agent account and saves the returned contentApiKey to the local config. See Agent Account and Billing CLI.
  • Create a key in the Agent Platform dashboard, then save it:
bash
tutorflow auth login --api-key tf_content_...
tutorflow auth whoami

auth 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 prefixWhat 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:

  1. The global --classroom <id> flag.
  2. TUTORFLOW_CLASSROOM_ID.
  3. classroomId in the config file (tutorflow config set classroomId <id>).
  4. GET /v1/platform/agent/account: sandboxClassroomId for a test key, defaultClassroomId otherwise.
  5. 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 status 2 and code ECLASSROOM and 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.

bash
tutorflow config get
tutorflow config get classroomId
tutorflow config set baseUrl https://api.tutorflow.io
Config keyMeaning
apiKeyThe API key. config get prints it masked.
baseUrlAPI origin. Default https://api.tutorflow.io.
classroomIdClassroom for content commands.
workspaceLeft over from 0.3; unused.

Environment variables win over the config file. An empty variable counts as unset.

VariableDescription
TUTORFLOW_API_KEYAPI key for authenticated requests
TUTORFLOW_BASE_URLAPI origin, for example a staging host
TUTORFLOW_CLASSROOM_IDClassroom for content commands
TUTORFLOW_JSONSet to 1 for JSON output, like --json
TUTORFLOW_DEBUG or DEBUGSet to 1 to print stack traces on errors, like --debug
TUTORFLOW_POLL_INTERVAL_MSPoll interval for --wait, in milliseconds. Default 3000.

Use JSON and Non-Interactive Mode

Put --json before or after the subcommand:

bash
tutorflow --json platform pricing
tutorflow course list --json

In 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, and delete and remove commands need --yes.

Without a terminal, the CLI does not prompt either.

Example error output in JSON mode:

JSON
{
  "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 statusMeaning
0Success
1API, network, or authentication error, a failed run, or a --wait timeout
2Usage error: unknown option, missing argument, invalid value, ENOINTERACTIVE, or ECLASSROOM
130Cancelled at a prompt

TutorFlow CLI Command Groups

CommandPurposePage
tutorflow course, slide, test, moduleGenerate and manage courses, slide decks, tests, and interactive modulesContent Generation CLI
tutorflow videoCreate videos, edit scenes, narrate, and renderContent Generation CLI
tutorflow game, simulationCreate, plan, build, and revise games and simulationsContent Generation CLI
tutorflow runFollow, wait for, and resume generation runsContent Generation CLI
tutorflow evaluate, evaluationGrade a learner answer; read past evaluations and masteryContent Generation CLI
tutorflow learnerList, invite, and remove classroom learnersContent Generation CLI
tutorflow webhookManage Content API webhook endpointsContent Generation CLI
tutorflow classroom, creditsList classrooms; read the AI Credit balance and historyContent Generation CLI
tutorflow agentRegister, read the account, verify email, billing, and checkoutAgent Account and Billing CLI
tutorflow platformManifest, pricing, key health, and old share linksPlatform Discovery CLI
tutorflow auth, configStore and inspect local credentials and settingsThis page

Changes in 0.5.0

  • New on every content resource: share <id>, which makes it open by link and prints publicUrl, and visibility <id> <value>. See Commands Every Resource Shares.
  • video create --visibility also takes UNLISTED.

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; a tf_platform_ key fails with EPLATFORMKEY. agent register now saves contentApiKey.
  • course, slide, test, and module use generate (alias create), which returns a run. Add --wait to get the finished resource.
  • Flags changed: course generate --lessons is now -n (-l is --language), slide generate --theme takes a theme id, and module and test lost the 0.3 options such as --title, --target, --locale, --private, --no-quiz, --classroom-id, --tier, --mode, and --time-limit. Use the global --classroom instead of --classroom-id.
  • video create takes --title and one --scene <script> per scene instead of a prompt with --scenes, --ratio, and --duration. Render with video render --generate-missing-narration --wait.
  • Removed: test edit-token, the --open flag on create, and --offset and --status on list. Use open <id> for the editor and public URLs, and --page and --search on list.
  • New: classroom, run, game, simulation, evaluation, learner, webhook, credits, video scene, video narrate, video render, delete on every resource, agent billing x402-deposit, platform share-redirect, and the global --classroom.