Usage
$ curl -s https://acme.com/pricing | \
npx ai "extract pricing tiers" --schema '{
"tiers": [{
"name": "string",
"price": "number",
"bandwidth_gb": "number",
"team_members": "number"
}]
}'Output:
{
"tiers": [
{"name": "Starter", "price": 0, "bandwidth_gb": 50, "team_members": 1},
{"name": "Growth", "price": 29, "bandwidth_gb": 500, "team_members": 5},
{"name": "Scale", "price": 99, "bandwidth_gb": 2000, "team_members": 20},
{"name": "Enterprise", "price": -1, "bandwidth_gb": -1, "team_members": -1}
]
}Advanced usage – solving harder problems with AI as an API blackbox
Ex: Installing the latest version of a github release is trickier than it may seem, but it could become something like:
#!/bin/bash
# install-latest.sh - Install any GitHub CLI tool with one command
REPO=$1 # e.g., "junegunn/fzf"
# Get latest release data
curl -s "https://api.github.com/repos/$REPO/releases/latest" | \
npx ai "find download URL for $(uname -s) $(uname -m)" --schema '{
"download_url": "string",
"binary_name": "string",
"extract_command": "string"
}' > release.json
# Extract the info
URL=$(jq -r .download_url release.json)
BINARY=$(jq -r .binary_name release.json)
EXTRACT=$(jq -r .extract_command release.json)
# Download and install
curl -L "$URL" -o /tmp/download
eval "$EXTRACT” # 🤠
chmod +x "$BINARY"
sudo mv "$BINARY" /usr/local/bin/
echo "✓ Installed $BINARY”Usage
# Install fzf (handles .tar.gz)
$ ./install-latest.sh junegunn/fzf
✓ Installed fzf
# Install ripgrep (handles different naming: rg)
$ ./install-latest.sh BurntSushi/ripgrep
✓ Installed rg-m to alternate between modelsecho 'what is life?' | npx aiEvery card is a pure function of its facts and opens its place on GitHub. Fetching them is github-data's job, once, with the author's own token: no API and no token on the page.