@model-go/cli
v0.1.6
Published
The official CLI for modelgo. Pairs with AI agent skills so AI agents can operate modelgo on your behalf.
Readme
modelgo-cli
The official CLI for modelgo. Pairs with AI agent skills (Claude Code, Codex, Gemini CLI, etc.) so AI agents can operate modelgo on your behalf.
v0 framework stage. Device-flow
authcommands are available.modelgo pay requestsupports anonymous x402 pay-per-call calls to model gateway APIs; API key management is not wired up yet.
Install
npx @model-go/cli@latest installThis runs an interactive wizard that:
- Installs
@model-go/cliglobally via npm (which downloads the Go binary from GitHub Releases asmodelgo). - Distributes
modelgo-*skills to every AI agent installed on your machine (Claude Code, Trae, Trae CN, and other agents in the skills ecosystem).
After install, restart your AI agent (open a new chat / session) and try:
"Check my modelgo login status."
Your AI should find the modelgo-shared skill and run modelgo auth status.
Direct commands
modelgo --version
modelgo auth login
modelgo auth status
modelgo auth logout
modelgo pay methods
modelgo pay request --env cn --path /v1/chat/completions --method POST --data '{"model":"gpt-4o","messages":[]}' --json
modelgo --helpmodelgo auth login without --no-wait is a blocking command: it prints the
authorization URL, then keeps polling until the browser approval completes or
the device code expires.
Environments
The CLI talks to a named environment. Two are built in:
| Env | Base URL |
| ------ | ---------------------------- |
| cn | https://api.modelgo.com |
| intl | https://api.modelgo.ai |
The active environment defaults to cn. Switch it, or register your own:
modelgo env list # show built-in + custom envs (active marked with *)
modelgo env current # print the active env
modelgo env use intl # switch the active env
modelgo env add <name> --base-url https://... # register or override an env URL
modelgo env remove <name> # remove a custom env or overrideEnvironment definitions and the active selection live in ~/.modelgo/config.json.
Credentials are stored per-env in ~/.modelgo/auth.json, so switching environments
preserves each login. There are no environment variables to set.
Auth commands operate on the active env; pass --env <name> to target a different one:
modelgo auth login --env intl
modelgo auth status --env intl
modelgo auth logout --all # clear every envNon-streaming agent flows
For AI-agent harnesses that cannot stream intermediate output to the user, use:
modelgo auth login --no-wait --json
modelgo auth login --device-code <DEVICE_CODE>Do not show the URL and then immediately block on --device-code in the same
turn. In final-message-only harnesses, that pattern prevents the user from ever
seeing the URL before the agent starts waiting.
--jsonemits newline-delimited JSON (NDJSON). In the default waiting flow (modelgo auth login --jsonwithout--no-wait), stdout receives two JSON objects: first the device-code object (withverification_url), then the authenticated object once approved. Parse line by line — don'tJSON.parsethe whole stream. With--no-wait, only the device-code object is printed.
x402 pay-per-call model APIs
Use modelgo pay request when the user wants to call a model API without logging in to ModelGo first. The CLI opts into the gateway x402 path with X-Payment-Protocol: x402.
modelgo pay request --env cn --path /v1/chat/completions --method POST --data '{"model":"gpt-4o","messages":[{"role":"user","content":"hello"}]}' --intent "调用 gpt-4o 完成聊天补全" --jsonIn the cn environment, if the gateway returns a 402 that advertises alipay:*, the CLI writes the PAYMENT-REQUIRED payload to a local file and returns a structured handoff for alipay-payment-skill. In intl, the CLI does not route to Alipay; it returns the advertised x402 options for a future non-Alipay rail.
Upgrade
Re-run the installer; it detects an out-of-date install and upgrades in place:
npx @model-go/cli@latest installLicense
MIT — see LICENSE.
