Add model-api commands (fetch, list, predict)#18
Conversation
There was a problem hiding this comment.
Pull request overview
Adds a new model-api command group to the Baseten CLI to browse and invoke “Model APIs”, plus supporting plumbing for shared auth transport and enhanced table rendering.
Changes:
- Add
baseten model-api {list,fetch,predict}commands (management fetch/list + direct inference POST for predict) with unit tests. - Introduce
TableOutputto support right-aligned columns and migrate existing table outputs to the new signature. - Add
AuthTransport()and a newRemote.ModelAPIInferenceURL()helper to support non-SDK HTTP calls.
Reviewed changes
Copilot reviewed 12 out of 13 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| internal/cmd/remote.go | Adds ModelAPIInferenceURL() and remote host mapping for Model API inference. |
| internal/cmd/command.org_secret.go | Migrates table output to TableOutput. |
| internal/cmd/command.org_apikey.go | Migrates table output to TableOutput. |
| internal/cmd/command.model.go | Migrates table output to TableOutput. |
| internal/cmd/command.model_environment.go | Migrates table output to TableOutput. |
| internal/cmd/command.model_deployment.go | Migrates table output to TableOutput. |
| internal/cmd/command.model_api.go | Implements model-api fetch/list/predict command handlers. |
| internal/cmd/command.model_api_test.go | Adds unit tests for model-api list/fetch/predict behaviors. |
| internal/cmd/command_context.go | Adds TableOutput, right-aligned columns, and AuthTransport() refactor. |
| go.mod | Bumps baseten-go dependency to a newer pseudo-version. |
| go.sum | Adds checksums for the updated baseten-go version. |
| cmd/command.model_api.go | Adds CLI metadata and flag structs for model-api commands. |
| cmd/command.go | Registers the new model-api command group under the root command. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| Children: []Command{ | ||
| { | ||
| Name: "fetch", | ||
| Summary: "Fetch a Model API", |
There was a problem hiding this comment.
What do you think about changing language to "Describe a Model API" of "Featch a Model API description". We're dealing with the metadata here, I my understanding "the API" is more like the "backend server" (e.g. you can call/invoke it).
There was a problem hiding this comment.
I am trying to keep the idea of "fetch" = "get single resource" and "list" = "get multiple resources" across the CLI. But, I could see changing all "fetch"es to "describe"s. E.g. baseten model describe instead of baseten model fetch. Think we should do that?
a6c8908 to
30435ea
Compare
🚀 What
Adds the
model-apicommand group:fetch(single Model API by name),list(workspace-added,--allfor full catalog), andpredict(inference via--content, or verbatim--data/--file)Depends on basetenlabs/baseten-go#9
💻 How
Management client for fetch/list, direct inference POST for predict (model selected by
--model). List rendersNAME/CONTEXT/$/1M IN/$/1M OUT/ADDEDwith cost columns right-aligned via a newTableOutputstruct onOutputTable.🔬 Testing
Unit tests cover list (rows, JSON, pagination, added-only), fetch (text/JSON), and predict (content, verbatim, validation).
go test ./...green.