Skip to content

feat(cli): prompt for OpenAI API key in interactive mode#403

Open
AliaksandrNazaruk wants to merge 1 commit intothesysdev:mainfrom
AliaksandrNazaruk:feat/interactive-api-key
Open

feat(cli): prompt for OpenAI API key in interactive mode#403
AliaksandrNazaruk wants to merge 1 commit intothesysdev:mainfrom
AliaksandrNazaruk:feat/interactive-api-key

Conversation

@AliaksandrNazaruk
Copy link

Summary

When running create-chat-app interactively, prompt the user for their OpenAI API key instead of printing manual instructions. If a key is provided, the CLI creates the .env file automatically and simplifies the getting-started output. In non-interactive mode, behavior is unchanged.

Changes

  • packages/openui-cli/src/commands/create-chat-app.ts: After installing dependencies, prompt for the OpenAI API key using the existing resolveArgs helper. If provided, write .env and show a streamlined message. If skipped (blank input) or non-interactive, show the original instructions.

Closes #399

When running create-chat-app interactively, prompt the user for their
OpenAI API key, create the .env file automatically, and simplify the
getting-started instructions. In non-interactive mode, the behavior
remains unchanged.

Closes thesysdev#399
Copy link
Member

@rabisg rabisg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works great - just a minor change for simplifying the code


console.info(getStartedMessage(name, devCmd));
if (!options.noInteractive) {
const apiKeyArgs = await resolveArgs(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

resolveOne was meant as a utility for when the value can be passed from both the cli as flags and in interactive mode. Since we don't want this in non-interactive mode or a flag for this, you can directly use inquirer here

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Also, this can be reorganized into a fn in the lib/ folder to clean up the command and keep it as a high-level orchestrator.

Copy link
Contributor

@AbhinRustagi AbhinRustagi Mar 27, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's also a merge conflict to be resolved with the skill option.

I think it can be extended to a 3-step scenario

  • Ask for OpenAI SDK BaseUrl (read a comment/issue about someone using OpenRouter, I personally used Gemini) (default value can be something like "Use OpenAI")
  • (If they add a custom url) Ask for model name
  • Ask for Api Key

Wdyt?

Drawbacks: prolongs the setup process

@rabisg rabisg self-assigned this Mar 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ask for OpenAI key in interactive mode

4 participants