pi-media-models 0.1.3 → 0.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +95 -29
- package/package.json +10 -4
- package/skills/pi-media/SKILL.md +13 -19
package/README.md
CHANGED
|
@@ -10,13 +10,14 @@ This extension seamlessly bridges Pi's reasoning capabilities with top-tier AI m
|
|
|
10
10
|
## ✨ Features
|
|
11
11
|
|
|
12
12
|
- **Unified Interface**: One request format (`provider`, `model`, `prompt`, `referenceImages`, etc.) maps automatically to the correct capability across providers.
|
|
13
|
+
- **Config-First Authentication**: Manage all API keys and credentials directly in a single `media-models.json` configuration file — no cluttered environment variables needed.
|
|
13
14
|
- **Auto-Download**: Output media (images, videos, audio) is automatically downloaded and saved to a local directory (`~/.pi/agent/media/outputs/`) using atomic `.part` renames. LLM context remains pristine and only receives local file paths.
|
|
14
|
-
- **Smart Input Resolution**: Pass local paths (`C:/...`), file URIs (`file://`), standard URLs (`http(s)://`), or base64 (`data:...`). The router transparently handles multipart uploads, base64 encoding, or CDN pre-uploading (e.g., for `fal.ai`).
|
|
15
|
+
- **Smart Input Resolution**: Pass local paths (`C:/...` or `/path/...`), file URIs (`file://`), standard URLs (`http(s)://`), or base64 (`data:...`). The router transparently handles multipart uploads, base64 encoding, or CDN pre-uploading (e.g., for `fal.ai`).
|
|
15
16
|
- **Resilient Polling**: Advanced `MediaJob` processing handles asynchronous Long-Running Operations (LROs), 429 rate limits (respecting `Retry-After`), and timeouts. Supports remote job cancellation where supported by the provider.
|
|
16
17
|
|
|
17
18
|
## 📦 Installation
|
|
18
19
|
|
|
19
|
-
This extension is built for the **Pi Coding Agent**. It
|
|
20
|
+
This extension is built for the **Pi Coding Agent**. It bundles both the executable extension logic and the LLM `SKILL.md` prompt context.
|
|
20
21
|
|
|
21
22
|
Install natively inside your Pi environment:
|
|
22
23
|
|
|
@@ -28,48 +29,91 @@ pi install npm:pi-media-models
|
|
|
28
29
|
pi install git:github.com/luffysolution-svg/pi-media-models
|
|
29
30
|
```
|
|
30
31
|
|
|
31
|
-
Once installed,
|
|
32
|
+
Once installed, restart Pi or type `/reload` in your active session.
|
|
32
33
|
|
|
33
|
-
##
|
|
34
|
+
## 🚀 Quick Usage
|
|
34
35
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
After installation, the extension and its companion skill are active immediately. You can talk to Pi naturally — Pi knows how to query available models and route tasks to the appropriate tool.
|
|
37
|
+
|
|
38
|
+
**Example Prompts:**
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
帮我用 fal.ai 画一张赛博朋克风格的雨夜街景,比例 16:9
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
```
|
|
45
|
+
Use xAI to generate a 5-second video of ocean waves with audio
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
```
|
|
49
|
+
使用 Atlas 编辑这张图片,把背景换成雪山:C:/assets/photo.jpg
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
```
|
|
53
|
+
帮我查一下当前已配置好可用的多模态模型有哪些?
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
Pi 会自动调取对应工具、完成排队轮询与文件下载,并直接返回本地媒体文件的保存路径。
|
|
46
57
|
|
|
47
58
|
## ⚙️ Configuration
|
|
48
59
|
|
|
49
|
-
API
|
|
60
|
+
All API keys, custom endpoints, and output paths are configured directly in a single JSON file.
|
|
61
|
+
|
|
62
|
+
**Configuration File Location:**
|
|
63
|
+
- **Global (Recommended):** `~/.pi/agent/media-models.json`
|
|
64
|
+
- **Project-Specific:** `<project_root>/.pi/media-models.json`
|
|
65
|
+
|
|
66
|
+
### Example `media-models.json`
|
|
50
67
|
|
|
51
|
-
|
|
52
|
-
`~/.pi/agent/media-models.json` (Global) or `<project_root>/.pi/media-models.json` (Project-specific).
|
|
68
|
+
Create or edit `~/.pi/agent/media-models.json`:
|
|
53
69
|
|
|
54
70
|
```json
|
|
55
71
|
{
|
|
56
|
-
"outputDir": "/
|
|
72
|
+
"outputDir": "~/.pi/agent/media/outputs",
|
|
57
73
|
"providerOptions": {
|
|
74
|
+
"fal": {
|
|
75
|
+
"apiKey": "fal-xxxxxxxxxxxxxxxxxxxx"
|
|
76
|
+
},
|
|
77
|
+
"xai": {
|
|
78
|
+
"apiKey": "xai-xxxxxxxxxxxxxxxxxxxx"
|
|
79
|
+
},
|
|
80
|
+
"atlas": {
|
|
81
|
+
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxx"
|
|
82
|
+
},
|
|
83
|
+
"dashscope": {
|
|
84
|
+
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxx"
|
|
85
|
+
},
|
|
86
|
+
"openai": {
|
|
87
|
+
"apiKey": "sk-xxxxxxxxxxxxxxxxxxxx"
|
|
88
|
+
},
|
|
89
|
+
"gemini": {
|
|
90
|
+
"apiKey": "AIzaxxxxxxxxxxxxxxxxxxxx"
|
|
91
|
+
},
|
|
92
|
+
"openrouter": {
|
|
93
|
+
"apiKey": "sk-or-xxxxxxxxxxxxxxxxxxxx"
|
|
94
|
+
},
|
|
58
95
|
"vertex": {
|
|
59
96
|
"credentialsFile": "/path/to/vertex-service-account.json",
|
|
60
97
|
"project": "my-gcp-project",
|
|
61
98
|
"location": "us-central1"
|
|
62
|
-
},
|
|
63
|
-
"dashscope": {
|
|
64
|
-
"baseUrl": "https://<workspace_id>.cn-beijing.maas.aliyuncs.com"
|
|
65
99
|
}
|
|
66
|
-
}
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
> **Note**: You only need to fill in the providers you plan to use. Unused providers can simply be omitted.
|
|
105
|
+
|
|
106
|
+
### Custom OpenAI-Compatible Providers
|
|
107
|
+
|
|
108
|
+
You can connect any third-party or internal OpenAI-compatible media gateway by declaring it in `customProviders`:
|
|
109
|
+
|
|
110
|
+
```json
|
|
111
|
+
{
|
|
67
112
|
"customProviders": [
|
|
68
113
|
{
|
|
69
114
|
"id": "my-custom-ai",
|
|
70
115
|
"name": "Internal AI Gateway",
|
|
71
116
|
"baseUrl": "https://api.internal.com/v1",
|
|
72
|
-
"apiKeyEnv": "MY_INTERNAL_KEY",
|
|
73
117
|
"auth": "bearer",
|
|
74
118
|
"models": [
|
|
75
119
|
{
|
|
@@ -86,13 +130,25 @@ API Keys can be provided as standard environment variables. Alternatively, you c
|
|
|
86
130
|
}
|
|
87
131
|
```
|
|
88
132
|
|
|
89
|
-
|
|
133
|
+
## 🔌 Supported Providers
|
|
134
|
+
|
|
135
|
+
| Provider | Provider ID | Supported Capabilities | Config Option |
|
|
136
|
+
|---|---|---|---|
|
|
137
|
+
| **fal.ai** | `fal` | Images, Video, Audio, TTS, STT (Queue/CDN integration) | `providerOptions.fal.apiKey` |
|
|
138
|
+
| **xAI (Grok Imagine)** | `xai` | Image Gen/Edit, T2V/I2V, Reference-to-Video, Video Extend | `providerOptions.xai.apiKey` |
|
|
139
|
+
| **Atlas API** | `atlas` | Sync/Async Image Gen & Edit, Video LROs | `providerOptions.atlas.apiKey` |
|
|
140
|
+
| **DashScope / 百炼** | `dashscope` | Qwen/Wan Images, Wan Video, Fun-Music, TTS/STT | `providerOptions.dashscope.apiKey` |
|
|
141
|
+
| **QwenCloud** | `qwencloud` | Same as DashScope (International endpoints) | `providerOptions.qwencloud.apiKey` |
|
|
142
|
+
| **OpenAI API** | `openai` | Image Gen/Edit (DALL-E), TTS, STT (Whisper) | `providerOptions.openai.apiKey` |
|
|
143
|
+
| **Google Gemini API** | `gemini` | Gemini/Imagen, Veo, Lyria, TTS, STT | `providerOptions.gemini.apiKey` |
|
|
144
|
+
| **Google Vertex AI** | `vertex` | ADC, Imagen/Gemini, Veo, Lyria, TTS, STT | `providerOptions.vertex.credentialsFile` |
|
|
145
|
+
| **OpenRouter** | `openrouter` | Image Generation, Async Video, TTS | `providerOptions.openrouter.apiKey` |
|
|
90
146
|
|
|
91
147
|
## 🛠️ Exposed Tools
|
|
92
148
|
|
|
93
|
-
The extension registers
|
|
149
|
+
The extension registers exactly 6 unified tools for the reasoning agent:
|
|
94
150
|
|
|
95
|
-
1. `media_models`: Lists providers, configured models, and capabilities.
|
|
151
|
+
1. `media_models`: Lists providers, configured models, and supported capabilities.
|
|
96
152
|
2. `image_generate`: Generate images from text, image, or multiple reference inputs.
|
|
97
153
|
3. `image_edit`: Edit existing images (supports masks and multiple references).
|
|
98
154
|
4. `video_generate`: Generates, edits, or extends videos. Automatically maps inputs (`referenceImages`, `inputVideo`, `duration`, `generateAudio`, etc.) to the provider's exact capability.
|
|
@@ -102,7 +158,17 @@ The extension registers the following unified tools for the reasoning agent:
|
|
|
102
158
|
## 🔒 Security & Privacy
|
|
103
159
|
|
|
104
160
|
- **No Key Logging**: API keys and Bearer tokens are redacted (`[REDACTED]`) from all error logs and HTTP outputs before being returned to the LLM.
|
|
105
|
-
- **
|
|
161
|
+
- **Local Downloads**: Media assets are fetched directly by your local client into your configured `outputDir` without third-party proxies.
|
|
162
|
+
- **Git Ignored**: `media-models.json` is automatically ignored from git repositories to prevent accidental credential commits.
|
|
106
163
|
|
|
107
164
|
---
|
|
108
|
-
|
|
165
|
+
|
|
166
|
+
## 🔄 Updating
|
|
167
|
+
|
|
168
|
+
```bash
|
|
169
|
+
pi update npm:pi-media-models
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
## 📄 License
|
|
173
|
+
|
|
174
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,12 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-media-models",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Provider-neutral multimodal generation tools for Pi Coding Agent",
|
|
6
|
-
"keywords": [
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package"
|
|
8
|
+
],
|
|
7
9
|
"pi": {
|
|
8
|
-
"extensions": [
|
|
9
|
-
|
|
10
|
+
"extensions": [
|
|
11
|
+
"./index.ts"
|
|
12
|
+
],
|
|
13
|
+
"skills": [
|
|
14
|
+
"./skills"
|
|
15
|
+
]
|
|
10
16
|
},
|
|
11
17
|
"scripts": {
|
|
12
18
|
"typecheck": "tsc --noEmit",
|
package/skills/pi-media/SKILL.md
CHANGED
|
@@ -82,34 +82,28 @@ All generated media is automatically downloaded to `~/.pi/agent/media/outputs/`.
|
|
|
82
82
|
|
|
83
83
|
## Key Configuration
|
|
84
84
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
**Environment variables** (any shell or system env):
|
|
88
|
-
|
|
89
|
-
| Provider | Variable |
|
|
90
|
-
|---|---|
|
|
91
|
-
| OpenAI | `OPENAI_API_KEY` |
|
|
92
|
-
| fal.ai | `FAL_KEY` |
|
|
93
|
-
| Gemini | `GEMINI_API_KEY` |
|
|
94
|
-
| Vertex AI | `GOOGLE_APPLICATION_CREDENTIALS` (ADC) |
|
|
95
|
-
| xAI | `XAI_API_KEY` |
|
|
96
|
-
| DashScope / QwenCloud | `DASHSCOPE_API_KEY` |
|
|
97
|
-
| OpenRouter | `OPENROUTER_API_KEY` |
|
|
98
|
-
| Atlas | `ATLAS_API_KEY` |
|
|
99
|
-
|
|
100
|
-
**Config file** (`~/.pi/agent/media-models.json` or `.pi/media-models.json` in the project root):
|
|
85
|
+
All API keys and provider options are configured in `~/.pi/agent/media-models.json` (or `.pi/media-models.json` in the workspace root):
|
|
101
86
|
|
|
102
87
|
```json
|
|
103
88
|
{
|
|
104
|
-
"outputDir": "/
|
|
89
|
+
"outputDir": "~/.pi/agent/media/outputs",
|
|
105
90
|
"providerOptions": {
|
|
91
|
+
"fal": { "apiKey": "fal-..." },
|
|
106
92
|
"xai": { "apiKey": "xai-..." },
|
|
93
|
+
"atlas": { "apiKey": "sk-..." },
|
|
94
|
+
"dashscope": { "apiKey": "sk-..." },
|
|
95
|
+
"openai": { "apiKey": "sk-..." },
|
|
96
|
+
"gemini": { "apiKey": "AIza..." },
|
|
97
|
+
"openrouter": { "apiKey": "sk-or-..." },
|
|
107
98
|
"vertex": {
|
|
108
99
|
"credentialsFile": "/path/to/service-account.json",
|
|
109
|
-
"project": "my-gcp-project"
|
|
100
|
+
"project": "my-gcp-project",
|
|
101
|
+
"location": "us-central1"
|
|
110
102
|
}
|
|
111
103
|
}
|
|
112
104
|
}
|
|
113
105
|
```
|
|
114
106
|
|
|
115
|
-
|
|
107
|
+
Tell the user to edit `~/.pi/agent/media-models.json` directly to add or update API keys.
|
|
108
|
+
|
|
109
|
+
*(Environment variables such as `FAL_KEY`, `OPENAI_API_KEY`, `XAI_API_KEY` are also checked as a fallback).*
|