Add endpoint commands: responses, chat_completions, moderations, embeddings - #8
Merged
Merged
Conversation
…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>
|
Important
This repository does not receive automatic reviews because it has fewer than 10 stars. ⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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--modelagainst 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, andcost_savingsstay as they are.What's added
responses [text]/v1/responses-m(required),-i,--metadata,--body,--rawchat_completions [text](aliaschat-completions)/v1/chat/completions-m(required),-i→ system message,--metadata,--body,--rawchoices[0].message.contentmoderations [text]/v1/moderations-m(required),--bodyembeddings [text]/v1/embeddings-m(required),--body--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.cost_savingsand the periodic note keep working.src/lib/request.ts. Existing commands are untouched.Verification
npm run lint,npm run build, andnpm testpass (56 tests; 16 new intests/endpointCommands.test.ts, withfetchmocked).api.zerogpu.aifrom the built CLI, with a throwaway HOME:responses … -m gliner-multi-pii-v1 --metadata '{"usecase":"redact","mask":"label"}': output identical toredact_piiresponses -m zlm-v1-iab-classify-edgewith text on stdin via heredoc: workschat_completions -m gliner2-base-v1 --metadata '{"usecase":"ner",…}': entities returnedresponses -m gpt-oss-120b --body '{"max_output_tokens":64}' --raw: completedmoderations -m zlm-v1-moderation-edge: flagged;embeddings -m bge-small-en-v1.5: 384 dimsRequest failed with status 404.+ body, exit 1; missing-m, empty stdin, invalid--body→ clear error, exit 1cost_savings --jsonshowed every successful call recordedNote:
chat-completions "Say hi in three words." -m qwen3-30b-a3b-fp8exited 1 withResponse did not contain any message content.The model used its whole 2,000-token completion budget on reasoning and returnedcontent: null.zerogpu chat -m qwen3-30b-a3b-fp8fails 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