CLI 参考#
本页面列出了所有llm命令的--help输出。
llm –帮助#
Usage: llm [OPTIONS] COMMAND [ARGS]...
Access Large Language Models from the command-line
Documentation: https://llm.datasette.io/
LLM can run models from many different providers. Consult the plugin directory
for a list of available models:
https://llm.datasette.io/en/stable/plugins/directory.html
To get started with OpenAI, obtain an API key from them and:
$ llm keys set openai
Enter key: ...
Then execute a prompt like this:
llm 'Five outrageous names for a pet pelican'
Options:
--version Show the version and exit.
--help Show this message and exit.
Commands:
prompt* Execute a prompt
aliases Manage model aliases
chat Hold an ongoing chat with a model.
collections View and manage collections of embeddings
embed Embed text and store or return the result
embed-models Manage available embedding models
embed-multi Store embeddings for multiple strings at once
install Install packages from PyPI into the same environment as LLM
keys Manage stored API keys for different models
logs Tools for exploring logged prompts and responses
models Manage available models
openai Commands for working directly with the OpenAI API
plugins List installed plugins
similar Return top N similar IDs from a collection
templates Manage stored prompt templates
uninstall Uninstall Python packages from the LLM environment
llm prompt –帮助#
Usage: llm prompt [OPTIONS] [PROMPT]
Execute a prompt
Documentation: https://llm.datasette.io/en/stable/usage.html
Examples:
llm 'Capital of France?'
llm 'Capital of France?' -m gpt-4o
llm 'Capital of France?' -s 'answer in Spanish'
Multi-modal models can be called with attachments like this:
llm 'Extract text from this image' -a image.jpg
llm 'Describe' -a https://static.simonwillison.net/static/2024/pelicans.jpg
cat image | llm 'describe image' -a -
# With an explicit mimetype:
cat image | llm 'describe image' --at - image/jpeg
The -x/--extract option returns just the content of the first ``` fenced code
block, if one is present. If none are present it returns the full response.
llm 'JavaScript function for reversing a string' -x
Options:
-s, --system TEXT System prompt to use
-m, --model TEXT Model to use
-a, --attachment ATTACHMENT Attachment path or URL or -
--at, --attachment-type <TEXT TEXT>...
Attachment with explicit mimetype
-o, --option <TEXT TEXT>... key/value options for the model
-t, --template TEXT Template to use
-p, --param <TEXT TEXT>... Parameters for template
--no-stream Do not stream output
-n, --no-log Don't log to database
--log Log prompt and response to the database
-c, --continue Continue the most recent conversation.
--cid, --conversation TEXT Continue the conversation with the given ID.
--key TEXT API key to use
--save TEXT Save prompt with this template name
--async Run prompt asynchronously
-u, --usage Show token usage
-x, --extract Extract first fenced code block
--xl, --extract-last Extract last fenced code block
--help Show this message and exit.
llm chat –帮助#
Usage: llm chat [OPTIONS]
Hold an ongoing chat with a model.
Options:
-s, --system TEXT System prompt to use
-m, --model TEXT Model to use
-c, --continue Continue the most recent conversation.
--cid, --conversation TEXT Continue the conversation with the given ID.
-t, --template TEXT Template to use
-p, --param <TEXT TEXT>... Parameters for template
-o, --option <TEXT TEXT>... key/value options for the model
--no-stream Do not stream output
--key TEXT API key to use
--help Show this message and exit.
llm keys –帮助#
Usage: llm keys [OPTIONS] COMMAND [ARGS]...
Manage stored API keys for different models
Options:
--help Show this message and exit.
Commands:
list* List names of all stored keys
get Return the value of a stored key
path Output the path to the keys.json file
set Save a key in the keys.json file
llm 密钥列表 –帮助#
Usage: llm keys list [OPTIONS]
List names of all stored keys
Options:
--help Show this message and exit.
llm 键路径 –help#
Usage: llm keys path [OPTIONS]
Output the path to the keys.json file
Options:
--help Show this message and exit.
llm keys get –帮助#
Usage: llm keys get [OPTIONS] NAME
Return the value of a stored key
Example usage:
export OPENAI_API_KEY=$(llm keys get openai)
Options:
--help Show this message and exit.
llm keys set –帮助#
Usage: llm keys set [OPTIONS] NAME
Save a key in the keys.json file
Example usage:
$ llm keys set openai
Enter key: ...
Options:
--value TEXT Value to set
--help Show this message and exit.
llm 日志 –帮助#
Usage: llm logs [OPTIONS] COMMAND [ARGS]...
Tools for exploring logged prompts and responses
Options:
--help Show this message and exit.
Commands:
list* Show recent logged prompts and their responses
off Turn off logging for all prompts
on Turn on logging for all prompts
path Output the path to the logs.db file
status Show current status of database logging
llm 日志路径 –帮助#
Usage: llm logs path [OPTIONS]
Output the path to the logs.db file
Options:
--help Show this message and exit.
llm 日志状态 –帮助#
Usage: llm logs status [OPTIONS]
Show current status of database logging
Options:
--help Show this message and exit.
llm 日志开启 –帮助#
Usage: llm logs on [OPTIONS]
Turn on logging for all prompts
Options:
--help Show this message and exit.
llm 注销 –帮助#
Usage: llm logs off [OPTIONS]
Turn off logging for all prompts
Options:
--help Show this message and exit.
llm 日志列表 –帮助#
Usage: llm logs list [OPTIONS]
Show recent logged prompts and their responses
Options:
-n, --count INTEGER Number of entries to show - defaults to 3, use 0
for all
-p, --path FILE Path to log database
-m, --model TEXT Filter by model or model alias
-q, --query TEXT Search for logs matching this string
-t, --truncate Truncate long strings in output
-s, --short Shorter YAML output with truncated prompts
-u, --usage Include token usage
-r, --response Just output the last response
-x, --extract Extract first fenced code block
--xl, --extract-last Extract last fenced code block
-c, --current Show logs from the current conversation
--cid, --conversation TEXT Show logs for this conversation ID
--json Output logs as JSON
--help Show this message and exit.
llm 模型 –帮助#
Usage: llm models [OPTIONS] COMMAND [ARGS]...
Manage available models
Options:
--help Show this message and exit.
Commands:
list* List available models
default Show or set the default model
llm 模型列表 –帮助#
Usage: llm models list [OPTIONS]
List available models
Options:
--options Show options for each model, if available
--async List async models
-q, --query TEXT Search for models matching these strings
--help Show this message and exit.
llm 模型默认 –帮助#
Usage: llm models default [OPTIONS] [MODEL]
Show or set the default model
Options:
--help Show this message and exit.
llm 模板 –帮助#
Usage: llm templates [OPTIONS] COMMAND [ARGS]...
Manage stored prompt templates
Options:
--help Show this message and exit.
Commands:
list* List available prompt templates
edit Edit the specified prompt template using the default $EDITOR
path Output the path to the templates directory
show Show the specified prompt template
llm 模板列表 –帮助#
Usage: llm templates list [OPTIONS]
List available prompt templates
Options:
--help Show this message and exit.
llm 模板显示 –帮助#
Usage: llm templates show [OPTIONS] NAME
Show the specified prompt template
Options:
--help Show this message and exit.
llm 模板编辑 –帮助#
Usage: llm templates edit [OPTIONS] NAME
Edit the specified prompt template using the default $EDITOR
Options:
--help Show this message and exit.
llm 模板路径 –帮助#
Usage: llm templates path [OPTIONS]
Output the path to the templates directory
Options:
--help Show this message and exit.
llm 别名 –帮助#
Usage: llm aliases [OPTIONS] COMMAND [ARGS]...
Manage model aliases
Options:
--help Show this message and exit.
Commands:
list* List current aliases
path Output the path to the aliases.json file
remove Remove an alias
set Set an alias for a model
llm 别名列表 –帮助#
Usage: llm aliases list [OPTIONS]
List current aliases
Options:
--json Output as JSON
--help Show this message and exit.
llm 别名设置 –帮助#
Usage: llm aliases set [OPTIONS] ALIAS [MODEL_ID]
Set an alias for a model
Example usage:
llm aliases set mini gpt-4o-mini
Alternatively you can omit the model ID and specify one or more -q options.
The first model matching all of those query strings will be used.
llm aliases set mini -q 4o -q mini
Options:
-q, --query TEXT Set alias for model matching these strings
--help Show this message and exit.
llm 别名移除 –帮助#
Usage: llm aliases remove [OPTIONS] ALIAS
Remove an alias
Example usage:
$ llm aliases remove turbo
Options:
--help Show this message and exit.
llm 别名路径 –帮助#
Usage: llm aliases path [OPTIONS]
Output the path to the aliases.json file
Options:
--help Show this message and exit.
llm 插件 –帮助#
Usage: llm plugins [OPTIONS]
List installed plugins
Options:
--all Include built-in default plugins
--help Show this message and exit.
llm 安装 –帮助#
Usage: llm install [OPTIONS] [PACKAGES]...
Install packages from PyPI into the same environment as LLM
Options:
-U, --upgrade Upgrade packages to latest version
-e, --editable TEXT Install a project in editable mode from this path
--force-reinstall Reinstall all packages even if they are already up-to-
date
--no-cache-dir Disable the cache
--help Show this message and exit.
llm 卸载 –帮助#
Usage: llm uninstall [OPTIONS] PACKAGES...
Uninstall Python packages from the LLM environment
Options:
-y, --yes Don't ask for confirmation
--help Show this message and exit.
llm embed –帮助#
Usage: llm embed [OPTIONS] [COLLECTION] [ID]
Embed text and store or return the result
Options:
-i, --input PATH File to embed
-m, --model TEXT Embedding model to use
--store Store the text itself in the database
-d, --database FILE
-c, --content TEXT Content to embed
--binary Treat input as binary data
--metadata TEXT JSON object metadata to store
-f, --format [json|blob|base64|hex]
Output format
--help Show this message and exit.
llm embed-multi –帮助#
Usage: llm embed-multi [OPTIONS] COLLECTION [INPUT_PATH]
Store embeddings for multiple strings at once
Input can be CSV, TSV or a JSON list of objects.
The first column is treated as an ID - all other columns are assumed to be
text that should be concatenated together in order to calculate the
embeddings.
Input data can come from one of three sources:
1. A CSV, JSON, TSV or JSON-nl file (including on standard input)
2. A SQL query against a SQLite database
3. A directory of files
Options:
--format [json|csv|tsv|nl] Format of input file - defaults to auto-detect
--files <DIRECTORY TEXT>... Embed files in this directory - specify directory
and glob pattern
--encoding TEXT Encoding to use when reading --files
--binary Treat --files as binary data
--sql TEXT Read input using this SQL query
--attach <TEXT FILE>... Additional databases to attach - specify alias
and file path
--batch-size INTEGER Batch size to use when running embeddings
--prefix TEXT Prefix to add to the IDs
-m, --model TEXT Embedding model to use
--prepend TEXT Prepend this string to all content before
embedding
--store Store the text itself in the database
-d, --database FILE
--help Show this message and exit.
llm similar –帮助#
Usage: llm similar [OPTIONS] COLLECTION [ID]
Return top N similar IDs from a collection
Example usage:
llm similar my-collection -c "I like cats"
Or to find content similar to a specific stored ID:
llm similar my-collection 1234
Options:
-i, --input PATH File to embed for comparison
-c, --content TEXT Content to embed for comparison
--binary Treat input as binary data
-n, --number INTEGER Number of results to return
-d, --database FILE
--help Show this message and exit.
llm embed-models –帮助#
Usage: llm embed-models [OPTIONS] COMMAND [ARGS]...
Manage available embedding models
Options:
--help Show this message and exit.
Commands:
list* List available embedding models
default Show or set the default embedding model
llm embed-models 列表 –帮助#
Usage: llm embed-models list [OPTIONS]
List available embedding models
Options:
-q, --query TEXT Search for embedding models matching these strings
--help Show this message and exit.
llm embed-models 默认 –帮助#
Usage: llm embed-models default [OPTIONS] [MODEL]
Show or set the default embedding model
Options:
--remove-default Reset to specifying no default model
--help Show this message and exit.
llm 集合 –帮助#
Usage: llm collections [OPTIONS] COMMAND [ARGS]...
View and manage collections of embeddings
Options:
--help Show this message and exit.
Commands:
list* View a list of collections
delete Delete the specified collection
path Output the path to the embeddings database
llm collections 路径 –帮助#
Usage: llm collections path [OPTIONS]
Output the path to the embeddings database
Options:
--help Show this message and exit.
llm 集合列表 –帮助#
Usage: llm collections list [OPTIONS]
View a list of collections
Options:
-d, --database FILE Path to embeddings database
--json Output as JSON
--help Show this message and exit.
llm collections delete –帮助#
Usage: llm collections delete [OPTIONS] COLLECTION
Delete the specified collection
Example usage:
llm collections delete my-collection
Options:
-d, --database FILE Path to embeddings database
--help Show this message and exit.
llm openai –帮助#
Usage: llm openai [OPTIONS] COMMAND [ARGS]...
Commands for working directly with the OpenAI API
Options:
--help Show this message and exit.
Commands:
models List models available to you from the OpenAI API
llm openai models –帮助#
Usage: llm openai models [OPTIONS]
List models available to you from the OpenAI API
Options:
--json Output as JSON
--key TEXT OpenAI API key
--help Show this message and exit.