img-cli

Authentication

Each provider has its own API key, from that vendor's dashboard. img-cli stores it in its config file and sends it only to that provider.

Save a key

Install the provider first, then log in:

img-cli provider add vibetoken
img-cli provider login vibetoken

Paste the key at the hidden prompt. To pass it from a script, pipe it in:

echo "$KEY" | img-cli provider login vibetoken

The key goes into the config file, config.json in the directory listed in Using providers, readable only by you (mode 0600). This works the same on a desktop, a server, and in a container. img-cli provider logout <name> deletes it.

Earlier versions (v0.2.3 and before) saved keys in the system keychain, which img-cli no longer reads; run provider login again to save them in the config file.

Where keys come from

For each request img-cli looks for the provider's key in this order:

  1. IMG_CLI_<NAME>_KEY, such as IMG_CLI_GRSAI_KEY; for my-vendor it is IMG_CLI_MY_VENDOR_KEY.
  2. The variable the plugin names in auth.env, if any. LaoZhang reads LAOZHANG_API_KEY.
  3. The config file.

img-cli provider list shows where each provider's key comes from:

NAME         TITLE         BASE URL                 KEY
grsai        Grsai         https://grsaiapi.com     file
laozhang     LaoZhang API  https://api.laozhang.ai  env
vibetoken *  VibeToken     https://vibetoken.cn     file

In CI

Set the environment variable from your CI secrets instead of logging in:

export IMG_CLI_VIBETOKEN_KEY="$VIBETOKEN_API_KEY"
img-cli image -m vibetoken:bytedance/seedream-5.0-flash "a fox" -o out/

See Scripts and CI.

With an AI assistant

Log in yourself, in your own terminal. Don't paste an API key into a chat with an assistant; the setup prompt on the home page tells the assistant to ask you to run provider login instead.

Remove a key

img-cli provider logout vibetoken

img-cli provider remove <name> also deletes the key, along with the plugin.

Errors

A missing or rejected key exits with code 3:

error: no API key for vibetoken: run `img-cli provider login vibetoken` or set $IMG_CLI_VIBETOKEN_KEY