How openai/openai-cli works
OpenAI CLI turns resource-oriented terminal commands into OpenAI REST API requests and presents responses or errors in scriptable and human-readable forms. A parallel image workflow generates and saves images, then supports local preview and optional terminal-native rendering; shell completion and help improve command discovery. The graph combines the shown entry point and sampled implementations with README-documented capabilities. Many generated API command files and image subsystems were not excerpted, so their internal call links are omitted or shown only where documentation supports them.
Main entry points: main.go CLI entry · adminorganizationexternalstorage.go Admin storage commands · webhook.go Webhook commands · image_picker_generate.go Image commands
Components 23
CLI entry and discovery
- CLI entry
cmd/openai/main.go - Help and errors
pkg/custom/help.go - Shell completion
internal/autocomplete/autocomplete.go
API command surface
- Command tree
pkg/cmd/cmd.go - API resource commands
pkg/cmd - Admin storage commands
pkg/cmd/adminorganizationexternalstorage.go - Service account commands
pkg/cmd/adminorganizationprojectserviceaccount.go - Service account keys
pkg/cmd/adminorganizationprojectserviceaccountapikey.go - Webhook commands
pkg/cmd/webhook.go
Output and presentation
- Readable output
internal/readable/readable.go - Stream projection
pkg/transformers/project_text_stream.go - JSON presentation
internal/jsonview
Image workflows
- Image commands
pkg/custom/image_picker_generate.go - Image saving
internal/imageoutput/save_response.go - Preview preferences
internal/imageprefs/imageprefs.go - Saved image preview
pkg/custom/preview_saved_image.go - Terminal image rendering
internal/terminalimage/font.go - Image font gallery
internal/imagegallery/gallery.go - Image font processing
internal/imagefont/imagefont.go
Request support
- Request flags
internal/requestflag - Query encoding
internal/apiquery/query.go
Other components
- CLI user
- OpenAI REST API
Connections 25
- CLI user → CLI entry: runs command
README.md - CLI entry → Command tree: runs
cmd/openai/main.go - CLI entry → Help and errors: configures help
cmd/openai/main.go - CLI entry → Shell completion: prepares completion
cmd/openai/main.go - Command tree → API resource commands: dispatches commands
- API resource commands → OpenAI REST API: calls REST API
README.md - Admin storage commands → OpenAI REST API: calls REST API
pkg/cmd/adminorganizationexternalstorage.go - Service account commands → OpenAI REST API: calls REST API
pkg/cmd/adminorganizationprojectserviceaccount.go - Service account keys → OpenAI REST API: calls REST API
pkg/cmd/adminorganizationprojectserviceaccountapikey.go - Webhook commands → OpenAI REST API: calls REST API
pkg/cmd/webhook.go - Admin storage commands → Request flags: reads flags
pkg/cmd/adminorganizationexternalstorage.go - Service account commands → Request flags: reads flags
pkg/cmd/adminorganizationprojectserviceaccount.go - Webhook commands → Request flags: reads flags
pkg/cmd/webhook.go - Admin storage commands → Query encoding: encodes queries
- Webhook commands → Query encoding: encodes queries
pkg/cmd/webhook.go - OpenAI REST API → Readable output: returns results
- Stream projection → Readable output: projects stream text
pkg/transformers/project_text_stream.go - API resource commands → JSON presentation: presents JSON
- Image commands → OpenAI REST API: requests generation
README.md - Image commands → Image saving: saves results
README.md - Saved image preview → Terminal image rendering: renders saved image
pkg/custom/preview_saved_image.go - Terminal image rendering → Image font gallery: uses gallery
internal/terminalimage/font.go - Terminal image rendering → Image font processing: uses font processing
internal/terminalimage/font.go - Image font gallery → Image font processing: encodes images
internal/imagegallery/gallery.go - Image commands → Preview preferences: uses preferences