@openuidev/cli
v0.1.1
Published
CLI for OpenUI — scaffold generative UI chat apps and generate LLM system prompts from component libraries
Maintainers
Readme
@openuidev/cli
Command-line tools for starting OpenUI projects and generating model instructions from component libraries.
Links: CLI docs | GitHub repo
It currently supports two workflows:
- scaffolding a new OpenUI app from one of two templates:
- OpenUI Chat — a Next.js app where you bring your own model key (OpenAI)
- OpenUI Cloud — a Next.js app backed by OpenUI Cloud for managed conversations, artifacts, and streaming
- generating a system prompt or JSON Schema from a
createLibrary()export
Install
Run the CLI with your package manager of choice:
npx @openuidev/cli@latest --help
pnpm dlx @openuidev/cli@latest --help
bunx @openuidev/cli@latest --helpQuick Start
Create a new app (you'll be prompted to pick a template):
npx @openuidev/cli@latest createSkip the prompt and pick a template directly:
npx @openuidev/cli@latest create --template openui-self-hosted
npx @openuidev/cli@latest create --template openui-cloudGenerate a prompt from a library file:
npx @openuidev/cli@latest generate ./src/library.tsGenerate JSON Schema instead:
npx @openuidev/cli@latest generate ./src/library.ts --json-schemaCommands
openui create
Scaffolds a new Next.js app from the OpenUI Chat or OpenUI Cloud template.
openui create [options]Options:
-n, --name <string>: Project name-t, --template <template>: Template to scaffold —openui-self-hostedoropenui-cloud--skill: Install the OpenUI agent skill for AI coding assistants--no-skill: Skip installing the OpenUI agent skill--no-install: Scaffold without running the package install--no-interactive: Fail instead of prompting for missing required input--api-key <key>: (cloud template) OpenUI Cloud API key; skips sign-in--auth <method>: (cloud template) How to obtain the key —oauth,manual, orskip
What it does:
- prompts for the project name if you do not pass
--name - prompts for the template if you do not pass
--template - copies the bundled template into a new directory
- rewrites monorepo-local dependencies (
workspace:,file:,catalog:) in the generatedpackage.jsontolatest - installs dependencies automatically using the detected package manager (unless
--no-install) - optionally installs the OpenUI agent skill for AI coding assistants
- writes a
.envfile tailored to the template (see below)
Template-specific .env
- OpenUI Chat — prompts for your OpenAI API key and writes
OPENAI_API_KEYto.env(interactive mode only). Leave blank to skip. - OpenUI Cloud — obtains an OpenUI Cloud API key and writes
THESYS_API_KEYplusDEMO_USER_ID=demo-userto.env. The key is resolved by, in order:--api-key <key>if provided- the
--authmethod, otherwise an interactive prompt offering:oauth— sign in with Thesys in the browser and mint a key for your orgmanual— paste an existing keyskip— leaveTHESYS_API_KEYempty and add it later (get one at https://console.thesys.dev/keys)
- in non-interactive mode without
--api-key, the cloud template fails because a key is required
Examples:
openui create
openui create --name my-app --template openui-self-hosted
openui create --name my-app --template openui-cloud --auth oauth
openui create --name my-app --template openui-cloud --api-key tk_your_key
openui create --name my-app --no-skill --no-install
openui create --no-interactive --name my-app --template openui-cloud --api-key tk_your_keyopenui generate
Generates a system prompt or JSON Schema from a file that exports a createLibrary() result.
openui generate [options] [entry]Arguments:
entry: Path to a.ts,.tsx,.js, or.jsxfile that exports a library
Options:
-o, --out <file>: Write output to a file instead of stdout--json-schema: Output JSON Schema instead of the system prompt--export <name>: Use a specific export name instead of auto-detecting the library export--prompt-options <name>: Use a specificPromptOptionsexport name (auto-detected by default)--no-interactive: Fail instead of prompting for a missingentry
What it does:
- prompts for the entry file path if you do not pass one
- bundles the entry with
esbuildbefore evaluating it in Node - supports both TypeScript and JavaScript entry files
- stubs common asset imports such as CSS, SVG, images, and fonts during bundling
- auto-detects the exported library by checking
library,default, and then all exports - auto-detects a
PromptOptionsexport (withexamples,additionalRules, orpreamble) and passes it tolibrary.prompt()
Examples:
openui generate ./src/library.ts
openui generate ./src/library.ts --json-schema
openui generate ./src/library.ts --export library
openui generate ./src/library.ts --out ./artifacts/system-prompt.txt
openui generate ./src/library.ts --prompt-options myPromptOptions
openui generate --no-interactive ./src/library.tsHow generate resolves exports
openui generate expects the target module to export a library object with both prompt() and toJSONSchema() methods.
If --export is not provided, it looks for exports in this order:
librarydefault- any other export that matches the expected library shape
PromptOptions auto-detection
If --prompt-options is not provided, the CLI looks for a PromptOptions export in this order:
promptOptionsoptions- any export whose name ends with
PromptOptions(case-insensitive)
A valid PromptOptions object has at least one of: examples (string array), additionalRules (string array), or preamble (string).
Local Development
Build the CLI locally:
pnpm run buildRun the built CLI:
node dist/index.js --help
node dist/index.js create --help
node dist/index.js generate --helpTelemetry
The CLI sends anonymous usage analytics. Disable it with the global --no-telemetry flag or by setting DO_NOT_TRACK=1 in the environment.
openui create --no-telemetryNotes
- interactive prompts can be cancelled without creating output
createrequires the selected template's files to be present in the built packagegenerateexits with a non-zero code if the file is missing or no valid library export is found
