Skip to content

Add model-api commands (fetch, list, predict)#18

Merged
cretz merged 4 commits into
mainfrom
cretz/model-api-commands
Jun 22, 2026
Merged

Add model-api commands (fetch, list, predict)#18
cretz merged 4 commits into
mainfrom
cretz/model-api-commands

Conversation

@cretz

@cretz cretz commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

🚀 What

Adds the model-api command group: fetch (single Model API by name), list (workspace-added, --all for full catalog), and predict (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 renders NAME / CONTEXT / $/1M IN / $/1M OUT / ADDED with cost columns right-aligned via a new TableOutput struct on OutputTable.

🔬 Testing

Unit tests cover list (rows, JSON, pagination, added-only), fetch (text/JSON), and predict (content, verbatim, validation). go test ./... green.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 TableOutput to support right-aligned columns and migrate existing table outputs to the new signature.
  • Add AuthTransport() and a new Remote.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.

Comment thread internal/cmd/remote.go
Comment thread internal/cmd/command.model_api.go
Comment thread cmd/command.model_api.go
Children: []Command{
{
Name: "fetch",
Summary: "Fetch a Model API",

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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).

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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?

@cretz cretz force-pushed the cretz/model-api-commands branch from a6c8908 to 30435ea Compare June 22, 2026 14:52
@cretz cretz merged commit 3f84614 into main Jun 22, 2026
3 checks passed
@cretz cretz deleted the cretz/model-api-commands branch June 22, 2026 14:57
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.

3 participants