# samuraigpt/muapi-cli architecture

> Architecture diagram of the GitHub repository samuraigpt/muapi-cli, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samuraigpt/muapi-cli
- Repository: https://github.com/samuraigpt/muapi-cli

## Overview

MuAPI CLI is an agent-friendly command-line client for MuAPI’s image, video, audio, and other model APIs. Users configure credentials, choose a curated command or invoke any endpoint with schema-driven inputs, then submit work, optionally wait for prediction results, and display or download outputs. The CLI also exposes tools through MCP and an optional LangChain integration for agent discovery, skills, and creative workflows. The graph combines sampled call paths with relationships explicit in the README and SOURCE INDEX; unsampled command internals are represented at their existing source paths.

Main entry points: [`muapi/main.py`](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/main.py) (Command router), [`muapi/client.py`](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/client.py) (HTTP and polling), [`muapi/commands/run.py`](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/run.py) (Generic model runner), [`muapi/commands/image.py`](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/image.py) (Image and video)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["CLI entry and commands"]
  node_entry["Command router<br/>[main.py]"]
  node_media["Image and video<br/>[image.py]"]
  node_audio["Audio generation<br/>[audio.py]"]
  node_edit["Media editing<br/>[edit.py]"]
  node_enhance["Media enhancement<br/>[enhance.py]"]
  node_run["Generic model runner<br/>[run.py]"]
  node_predict["Prediction status<br/>[predict.py]"]
  node_upload["File upload<br/>[upload.py]"]
end

subgraph group_runtime["Shared runtime"]
  node_client["HTTP and polling<br/>[client.py]"]
  node_config[("Credential storage<br/>[config.py]")]
  node_schema["Schema introspection"]
  node_output["Output and downloads<br/>[utils.py]"]
end

subgraph group_accounts["Account and workflows"]
  node_auth["Authentication<br/>[auth.py]"]
  node_account["Account and keys<br/>[account.py]"]
  node_keys["API key management<br/>[keys.py]"]
  node_workflow["Workflow commands<br/>[workflow.py]"]
end

subgraph group_mcp["MCP interface"]
  node_mcpserver["MCP tool server<br/>[mcp_server.py]"]
end

subgraph group_agents["LangChain integration"]
  node_lc_tools["Agent tools<br/>[tools.py]"]
  node_lc_client["Agent API wrapper<br/>[_client.py]"]
  node_registry[("Model and skill registry<br/>[_registry.py]")]
  node_loader["Model loader<br/>[loader.py]"]
  node_callbacks["Generation callbacks<br/>[callbacks.py]"]
end

node_user(("CLI user"))
node_api{{"MuAPI service"}}

node_user -->|"runs commands"| node_entry
node_entry -->|"routes to"| node_auth
node_entry -->|"routes to"| node_account
node_entry -->|"routes to"| node_keys
node_entry -->|"routes to"| node_media
node_entry -->|"routes to"| node_audio
node_entry -->|"routes to"| node_edit
node_entry -->|"routes to"| node_enhance
node_entry -->|"routes to"| node_run
node_entry -->|"routes to"| node_predict
node_entry -.->|"routes to"| node_workflow
node_entry -->|"routes to"| node_mcpserver
node_auth -->|"saves credentials"| node_config
node_auth -->|"authenticates"| node_api
node_client -->|"reads credentials"| node_config
node_media -->|"submits generation"| node_client
node_audio -->|"submits generation"| node_client
node_edit -->|"submits edits"| node_client
node_enhance -->|"submits enhancement"| node_client
node_run -->|"submits endpoint"| node_client
node_run -->|"introspects schema"| node_schema
node_predict -->|"checks predictions"| node_client
node_upload -->|"uploads files"| node_client
node_client -->|"sends requests"| node_api
node_media -->|"prints results"| node_output
node_run -->|"prints results"| node_output
node_workflow -.->|"executes workflows"| node_api
node_mcpserver -->|"dispatches tools"| node_client
node_mcpserver -->|"serves tool requests"| node_api
node_user -.->|"uses agent tools"| node_lc_tools
node_lc_tools -->|"discovers models"| node_registry
node_lc_tools -->|"runs generation"| node_lc_client
node_lc_client -->|"calls CLI client"| node_client
node_lc_client -->|"resolves endpoints"| node_registry
node_loader -->|"loads model data"| node_client

click node_entry "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/main.py"
click node_auth "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/auth.py"
click node_account "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/account.py"
click node_keys "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/keys.py"
click node_media "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/image.py"
click node_audio "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/audio.py"
click node_edit "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/edit.py"
click node_enhance "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/enhance.py"
click node_run "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/run.py"
click node_predict "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/predict.py"
click node_workflow "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/workflow.py"
click node_upload "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/upload.py"
click node_client "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/client.py"
click node_config "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/config.py"
click node_schema "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/schema_introspect.py"
click node_output "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/utils.py"
click node_mcpserver "https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/mcp_server.py"
click node_lc_tools "https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/tools.py"
click node_lc_client "https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/_client.py"
click node_registry "https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/_registry.py"
click node_loader "https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/loader.py"
click node_callbacks "https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/callbacks.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_entry,node_media,node_audio,node_edit,node_enhance,node_run,node_predict,node_upload,node_user toneBlue
class node_client,node_config,node_schema,node_output toneAmber
class node_auth,node_account,node_keys,node_workflow,node_api toneMint
class node_mcpserver toneRose
class node_lc_tools,node_lc_client,node_registry,node_loader,node_callbacks toneIndigo
```

## Components

### CLI entry and commands

- [Command router](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/main.py): `muapi/main.py`
- [Image and video](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/image.py): `muapi/commands/image.py`
- [Audio generation](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/audio.py): `muapi/commands/audio.py`
- [Media editing](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/edit.py): `muapi/commands/edit.py`
- [Media enhancement](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/enhance.py): `muapi/commands/enhance.py`
- [Generic model runner](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/run.py): `muapi/commands/run.py`
- [Prediction status](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/predict.py): `muapi/commands/predict.py`
- [File upload](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/upload.py): `muapi/commands/upload.py`

### Shared runtime

- [HTTP and polling](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/client.py): `muapi/client.py`
- [Credential storage](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/config.py): `muapi/config.py`
- [Schema introspection](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/schema_introspect.py): `muapi/schema_introspect.py`
- [Output and downloads](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/utils.py): `muapi/utils.py`

### Account and workflows

- [Authentication](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/auth.py): `muapi/commands/auth.py`
- [Account and keys](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/account.py): `muapi/commands/account.py`
- [API key management](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/keys.py): `muapi/commands/keys.py`
- [Workflow commands](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/workflow.py): `muapi/commands/workflow.py`

### MCP interface

- [MCP tool server](https://github.com/samuraigpt/muapi-cli/blob/main/muapi/commands/mcp_server.py): `muapi/commands/mcp_server.py`

### LangChain integration

- [Agent tools](https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/tools.py): `integrations/langchain/muapi_langchain/tools.py`
- [Agent API wrapper](https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/_client.py): `integrations/langchain/muapi_langchain/_client.py`
- [Model and skill registry](https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/_registry.py): `integrations/langchain/muapi_langchain/_registry.py`
- [Model loader](https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/loader.py): `integrations/langchain/muapi_langchain/loader.py`
- [Generation callbacks](https://github.com/samuraigpt/muapi-cli/blob/main/integrations/langchain/muapi_langchain/callbacks.py): `integrations/langchain/muapi_langchain/callbacks.py`

### Other components

- **CLI user**
- **MuAPI service**

## Connections

- CLI user → Command router: runs commands (evidence: `README.md`)
- Command router → Authentication: routes to (evidence: `muapi/main.py`)
- Command router → Account and keys: routes to (evidence: `muapi/main.py`)
- Command router → API key management: routes to (evidence: `muapi/main.py`)
- Command router → Image and video: routes to (evidence: `muapi/main.py`)
- Command router → Audio generation: routes to (evidence: `muapi/main.py`)
- Command router → Media editing: routes to (evidence: `muapi/main.py`)
- Command router → Media enhancement: routes to (evidence: `muapi/main.py`)
- Command router → Generic model runner: routes to (evidence: `muapi/main.py`)
- Command router → Prediction status: routes to (evidence: `muapi/main.py`)
- Command router → Workflow commands: routes to (evidence: `muapi/main.py`)
- Command router → MCP tool server: routes to (evidence: `muapi/main.py`)
- Authentication → Credential storage: saves credentials (evidence: `muapi/commands/auth.py`)
- Authentication → MuAPI service: authenticates (evidence: `muapi/commands/auth.py`)
- HTTP and polling → Credential storage: reads credentials (evidence: `muapi/client.py`)
- Image and video → HTTP and polling: submits generation (evidence: `muapi/commands/image.py`)
- Audio generation → HTTP and polling: submits generation (evidence: `muapi/commands/audio.py`)
- Media editing → HTTP and polling: submits edits (evidence: `muapi/commands/edit.py`)
- Media enhancement → HTTP and polling: submits enhancement (evidence: `muapi/commands/enhance.py`)
- Generic model runner → HTTP and polling: submits endpoint (evidence: `muapi/commands/run.py`)
- Generic model runner → Schema introspection: introspects schema (evidence: `muapi/commands/run.py`)
- Prediction status → HTTP and polling: checks predictions (evidence: `muapi/commands/predict.py`)
- File upload → HTTP and polling: uploads files (evidence: `muapi/commands/upload.py`)
- HTTP and polling → MuAPI service: sends requests (evidence: `muapi/client.py`)
- Image and video → Output and downloads: prints results (evidence: `muapi/commands/image.py`)
- Generic model runner → Output and downloads: prints results (evidence: `muapi/commands/run.py`)
- Workflow commands → MuAPI service: executes workflows
- MCP tool server → HTTP and polling: dispatches tools (evidence: `muapi/commands/mcp_server.py`)
- MCP tool server → MuAPI service: serves tool requests (evidence: `muapi/commands/mcp_server.py`)
- CLI user → Agent tools: uses agent tools
- Agent tools → Model and skill registry: discovers models (evidence: `integrations/langchain/muapi_langchain/tools.py`)
- Agent tools → Agent API wrapper: runs generation (evidence: `integrations/langchain/muapi_langchain/tools.py`)
- Agent API wrapper → HTTP and polling: calls CLI client (evidence: `integrations/langchain/muapi_langchain/_client.py`)
- Agent API wrapper → Model and skill registry: resolves endpoints (evidence: `integrations/langchain/muapi_langchain/_client.py`)
- Model loader → HTTP and polling: loads model data (evidence: `integrations/langchain/muapi_langchain/loader.py`)
