Access Keychain Access password generator (password assistant) via Terminal without the user interface
Your exact question has been asked on Stackoverflow in 2009. The answers did not provide a way to access the Keychain password generator, but did suggest some alternatives.

A Google search for mac terminal password generator also shows several ways to generate a password from Terminal. I have listed a couple below.

openssl rand -base64 6


You can change -base64 to -hex to limit the use of special characters. The 6 indicates the lenght of the password.

env LC_CTYPE=C tr -dc "a-zA-Z0-9-_\$\?" &lt; /dev/urandom | head -c 10


The "a-zA-Z0-9-_\$\?" part indicates allowed characters and the 10 defines the length.