This is not the watsonx.ai CLI. This is the CLI for the Tech Preview program for IBM Foundation Models Studio. You can start a trial version or request a demo via https://www.ibm.com/products/watsonx-ai.
This project provides convenient access to the Generative AI API from the command line. For a full description of the API, please visit the Generative AI API Documentation.
Are you looking for an SDK?
If so, check out the NodeJS SDK and Python SDK.
- ⚡️ Performant - processes 1k of short inputs in under a minute
- ☀️ Fault-tolerant - retry strategies and overflood protection
- 🏖️ Worry-free parallel processing - just pass all the data, we take care of the parallel processing
- 🚦 Handles concurrency limiting - even if you have multiple parallel jobs running
- ⏩ Requests are always returned in the respective order
- ⌨️ Support stdin and stdout interaction
The CLI is distributed as an npm package. NodeJS runtime with sufficient version is required.
Preferred way of installing the CLI is the install script. If NodeJS is not detected, it is installed via nvm.
source <(curl -sSL https://raw.githubusercontent.com/IBM/ibm-generative-ai-cli/main/install.sh)
source <(wget -qO- https://raw.githubusercontent.com/IBM/ibm-generative-ai-cli/main/install.sh)
The CLI can also be installed directly using npm:
npm install -g @ibm-generative-ai/cli
Create default configuration:
genai config
One can also create profile-specific configuration:
genai --profile joe config
All the commands executed with --profile joe
argument will use that configuration (and default as a fallback).
The full commands have many segments due to alignment with the SDK and REST API. The CLI works best with autocompletion. Run the following to activate autocompletion, replace .zshrc
with the configuration file of your shell:
genai completion >> ~/.zshrc
source ~/.zshrc
You can choose default output format during genai config
or set it via --output-format
flag. Choices are json
and yaml
. Former can be piped into jq for further processing. Default is json
.
Certain commands (e.g. text generation create
or text tokenization create
) accept inputs from stdin
if positional arguments are omitted. The content of stdin
MUST follow JSONL format.
cat inputs.jsonl
# "foo"
# "bar"
# "baz"
cat inputs.jsonl moreInputs.jsonl | genai text generation create -m google/flan-ul2 | jq '.results[0].generated_text'
$ genai --help
genai <command>
Commands:
genai config Manage CLI configuration
genai text Text generation, tokenization and chat services
genai model Available models
genai file Upload, download and manage files
genai request Request history (for the past 30 days)
genai tune Train and manage tuned models
genai completion Generate completion script