Skip to content

Add endpoint commands: responses, chat_completions, moderations, embeddings - #8

Merged
amaan-ai20 merged 1 commit into
mainfrom
feat/endpoint-commands
Sep 15, 2026
Merged

amaan-ai20 merged 1 commit into
mainfrom
feat/endpoint-commands

Conversation

@amaan-ai20

Copy link
Copy Markdown
Collaborator

Why

The Claude Code and OpenClaw plugins shell out to per-task commands (chat -m …, classify_iab, redact_pii, …). Each of those pins a model or checks --model against a list, so every model addition, rename, or removal needs a CLI release, and customers on an older or newer CLI than the plugin expects get broken skills.

This PR adds one stable command per API endpoint. They send whatever model the caller names and keep no model list. The plugins will pick the endpoint per skill and call these, so they stop depending on CLI model updates. login, status, and cost_savings stay as they are.

What's added

Command Endpoint Options Prints
responses [text] /v1/responses -m (required), -i, --metadata, --body, --raw output text (pretty JSON when it parses)
chat_completions [text] (alias chat-completions) /v1/chat/completions -m (required), -i → system message, --metadata, --body, --raw choices[0].message.content
moderations [text] /v1/moderations -m (required), --body full response
embeddings [text] /v1/embeddings -m (required), --body full response
  • Input comes from the positional argument, or from stdin when there is none, so large prompts stay off the command line and plugins can use a heredoc directly. Trailing newlines from stdin are dropped.
  • --body <json> merges extra top-level fields (e.g. max_output_tokens). Fields set by the other options take precedence. This lets new API parameters be used without a CLI release too.
  • Savings are recorded under the requested model, like every other command, so cost_savings and the periodic note keep working.
  • Shared plumbing lives in src/lib/request.ts. Existing commands are untouched.
  • Docs: README "Endpoints" section, DOCUMENTATION §4.16–4.19 plus a §5 note, and ADDING_COMMANDS. The model-sync skill now says never to add a model list to these commands or remove them.
  • Version: 3.7.2 → 3.8.0. Merging publishes it.

Verification

  • npm run lint, npm run build, and npm test pass (56 tests; 16 new in tests/endpointCommands.test.ts, with fetch mocked).
  • Live smoke tests against api.zerogpu.ai from the built CLI, with a throwaway HOME:
    • responses … -m gliner-multi-pii-v1 --metadata '{"usecase":"redact","mask":"label"}': output identical to redact_pii
    • responses -m zlm-v1-iab-classify-edge with text on stdin via heredoc: works
    • chat_completions -m gliner2-base-v1 --metadata '{"usecase":"ner",…}': entities returned
    • responses -m gpt-oss-120b --body '{"max_output_tokens":64}' --raw: completed
    • moderations -m zlm-v1-moderation-edge: flagged; embeddings -m bge-small-en-v1.5: 384 dims
    • unknown model → Request failed with status 404. + body, exit 1; missing -m, empty stdin, invalid --body → clear error, exit 1
    • cost_savings --json showed every successful call recorded

Note: chat-completions "Say hi in three words." -m qwen3-30b-a3b-fp8 exited 1 with Response did not contain any message content. The model used its whole 2,000-token completion budget on reasoning and returned content: null. zerogpu chat -m qwen3-30b-a3b-fp8 fails the same way on that prompt, so it is model behaviour, not this change. --body '{"max_tokens":…}' is available if the plugins need more room.

Next

Once this is published, the Claude Code and OpenClaw plugins switch their inference skills to these commands and require zerogpu-cli >= 3.8.0.

🤖 Generated with Claude Code

…tions, moderations, embeddings

Four thin commands that POST to the API endpoint they are named for, with
whatever model the caller passes. They keep no model list, so a new or
renamed model works without a CLI release. The Claude Code and OpenClaw
plugins will call these instead of the per-task commands, which makes them
independent of CLI model updates.

- -m/--model (required), sent as-is; the API decides whether it exists
- text from the positional argument, or stdin when there isn't one
- responses/chat_completions: -i, --metadata, --raw; print the model text
- moderations/embeddings: print the full response
- --body on all four for extra top-level request fields
- savings recorded like every other command
- version 3.7.2 -> 3.8.0

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Important

  • 🔍 Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: a578f8c6-09d3-4092-b1cf-eee109893c62


Comment @coderabbitai help to get the list of available commands.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant