pi-media-models 0.1.2 → 0.1.4
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 +168 -55
- package/package.json +9 -3
- /package/{SKILL.md → skills/pi-media/SKILL.md} +0 -0
package/README.md
CHANGED
|
@@ -3,81 +3,193 @@
|
|
|
3
3
|
[](https://www.npmjs.com/package/pi-media-models)
|
|
4
4
|
[](https://opensource.org/licenses/MIT)
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Provider-neutral multimodal generation extension for [Pi Coding Agent](https://pi.dev). Generate images, video, audio, and speech across 9 providers with a single unified interface.
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
---
|
|
9
|
+
|
|
10
|
+
## Installation
|
|
11
|
+
|
|
12
|
+
Run this once in any terminal:
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
pi install npm:pi-media-models
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
That's it. Pi downloads the package, registers the extension, and loads the skill guide automatically. No manual configuration needed to get started.
|
|
19
|
+
|
|
20
|
+
If Pi is already running, type `/reload` in the chat to activate it in the current session.
|
|
21
|
+
|
|
22
|
+
> **Alternative:** Install directly from source
|
|
23
|
+
> ```bash
|
|
24
|
+
> pi install git:github.com/luffysolution-svg/pi-media-models
|
|
25
|
+
> ```
|
|
9
26
|
|
|
10
|
-
|
|
27
|
+
---
|
|
28
|
+
|
|
29
|
+
## Quick Start
|
|
30
|
+
|
|
31
|
+
After installation, open Pi and start chatting. No extra steps required if you have environment variables set for your chosen provider.
|
|
11
32
|
|
|
12
|
-
|
|
13
|
-
- **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
|
-
- **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.
|
|
33
|
+
**Example prompts:**
|
|
16
34
|
|
|
17
|
-
|
|
35
|
+
```
|
|
36
|
+
Generate an image of a misty mountain at sunrise using fal.ai
|
|
37
|
+
```
|
|
18
38
|
|
|
19
|
-
|
|
39
|
+
```
|
|
40
|
+
Use xAI to create a 5-second video of ocean waves with audio
|
|
41
|
+
```
|
|
20
42
|
|
|
21
|
-
|
|
43
|
+
```
|
|
44
|
+
Convert this text to speech using OpenAI: "Hello, world"
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
What image/video providers do I have configured?
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
Pi will automatically call the right tool, handle uploads and polling, and save the result to your local disk. It reports the saved file path when done.
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## API Key Setup
|
|
56
|
+
|
|
57
|
+
The extension reads keys from environment variables. Set whichever providers you want to use:
|
|
58
|
+
|
|
59
|
+
| Provider | Environment Variable |
|
|
60
|
+
|---|---|
|
|
61
|
+
| fal.ai | `FAL_KEY` |
|
|
62
|
+
| OpenAI | `OPENAI_API_KEY` |
|
|
63
|
+
| xAI (Grok) | `XAI_API_KEY` |
|
|
64
|
+
| Google Gemini | `GEMINI_API_KEY` |
|
|
65
|
+
| DashScope / QwenCloud | `DASHSCOPE_API_KEY` |
|
|
66
|
+
| OpenRouter | `OPENROUTER_API_KEY` |
|
|
67
|
+
| Atlas | `ATLAS_API_KEY` |
|
|
68
|
+
| Vertex AI | `GOOGLE_APPLICATION_CREDENTIALS` (ADC) |
|
|
69
|
+
|
|
70
|
+
**macOS / Linux** — add to `~/.zshrc` or `~/.bashrc`:
|
|
22
71
|
|
|
23
72
|
```bash
|
|
24
|
-
|
|
25
|
-
|
|
73
|
+
export FAL_KEY="your-key"
|
|
74
|
+
export XAI_API_KEY="your-key"
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
**Windows** — run in PowerShell (persists across reboots):
|
|
26
78
|
|
|
27
|
-
|
|
28
|
-
|
|
79
|
+
```powershell
|
|
80
|
+
[System.Environment]::SetEnvironmentVariable("FAL_KEY", "your-key", "User")
|
|
81
|
+
[System.Environment]::SetEnvironmentVariable("XAI_API_KEY", "your-key", "User")
|
|
29
82
|
```
|
|
30
83
|
|
|
31
|
-
|
|
84
|
+
Then restart Pi (or your terminal) for the variables to take effect.
|
|
32
85
|
|
|
33
|
-
|
|
86
|
+
### Alternative: Config File
|
|
34
87
|
|
|
35
|
-
|
|
36
|
-
|---|---|---|---|
|
|
37
|
-
| **OpenRouter** | `OpenRouterAdapter` | Image Generation, Async Video, TTS | `OPENROUTER_API_KEY` |
|
|
38
|
-
| **fal.ai** | `FalAdapter` | Images, Video, Audio, TTS, STT (Queue/CDN integration) | `FAL_KEY` |
|
|
39
|
-
| **Google Gemini API** | `GoogleMediaAdapter` | Gemini/Imagen, Veo, Lyria, TTS, STT | `GEMINI_API_KEY` |
|
|
40
|
-
| **Google Vertex AI** | `GoogleMediaAdapter` | ADC, Imagen/Gemini, Veo, Lyria, TTS, STT | ADC credentials |
|
|
41
|
-
| **DashScope / 百炼** | `DashScopeAdapter` | Qwen/Wan Images, Wan Video, Fun-Music, TTS/STT | `DASHSCOPE_API_KEY` |
|
|
42
|
-
| **QwenCloud** | `DashScopeAdapter` | Same as DashScope (International endpoints) | `DASHSCOPE_API_KEY` |
|
|
43
|
-
| **OpenAI API** | `OpenAIAdapter` | Image Gen/Edit (DALL-E), TTS, STT (Whisper) | `OPENAI_API_KEY` |
|
|
44
|
-
| **xAI (Grok Imagine)** | `XAIAdapter` | Image Gen/Edit, T2V/I2V, Reference-to-Video, Edit, Extend | `XAI_API_KEY` |
|
|
45
|
-
| **Atlas API** | `AtlasAdapter` | Sync/Async Image Gen & Edit, Video LROs | `ATLAS_API_KEY` |
|
|
88
|
+
If you prefer not to use environment variables, create the file `~/.pi/agent/media-models.json`:
|
|
46
89
|
|
|
47
|
-
|
|
90
|
+
```json
|
|
91
|
+
{
|
|
92
|
+
"providerOptions": {
|
|
93
|
+
"fal": { "apiKey": "your-fal-key" },
|
|
94
|
+
"xai": { "apiKey": "xai-your-key" },
|
|
95
|
+
"openai": { "apiKey": "sk-your-key" }
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
```
|
|
48
99
|
|
|
49
|
-
|
|
100
|
+
Keys in the config file take precedence over environment variables for that provider.
|
|
50
101
|
|
|
51
|
-
**
|
|
52
|
-
`~/.pi/agent/media-models.json` (Global) or `<project_root>/.pi/media-models.json` (Project-specific).
|
|
102
|
+
**Vertex AI** requires a service account JSON file path instead of an API key:
|
|
53
103
|
|
|
54
104
|
```json
|
|
55
105
|
{
|
|
56
|
-
"outputDir": "/path/to/custom/output/directory",
|
|
57
106
|
"providerOptions": {
|
|
58
107
|
"vertex": {
|
|
59
|
-
"credentialsFile": "/path/to/
|
|
108
|
+
"credentialsFile": "/path/to/service-account.json",
|
|
60
109
|
"project": "my-gcp-project",
|
|
61
110
|
"location": "us-central1"
|
|
62
|
-
},
|
|
63
|
-
"dashscope": {
|
|
64
|
-
"baseUrl": "https://<workspace_id>.cn-beijing.maas.aliyuncs.com"
|
|
65
111
|
}
|
|
66
|
-
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
---
|
|
117
|
+
|
|
118
|
+
## Output Files
|
|
119
|
+
|
|
120
|
+
All generated media is automatically downloaded and saved to:
|
|
121
|
+
|
|
122
|
+
```
|
|
123
|
+
~/.pi/agent/media/outputs/
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
To use a different directory, add `outputDir` to the config file:
|
|
127
|
+
|
|
128
|
+
```json
|
|
129
|
+
{
|
|
130
|
+
"outputDir": "/Users/alice/Pictures/ai-output"
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
---
|
|
135
|
+
|
|
136
|
+
## Supported Providers
|
|
137
|
+
|
|
138
|
+
| Provider | Capabilities | Env Var |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| **fal.ai** | Images, Video, Audio, TTS, STT | `FAL_KEY` |
|
|
141
|
+
| **xAI (Grok Imagine)** | Image gen/edit, T2V, I2V, video extend | `XAI_API_KEY` |
|
|
142
|
+
| **OpenAI** | Image gen/edit (DALL-E), TTS, STT (Whisper) | `OPENAI_API_KEY` |
|
|
143
|
+
| **Google Gemini** | Imagen, Gemini image, Veo video, Lyria audio, TTS | `GEMINI_API_KEY` |
|
|
144
|
+
| **Google Vertex AI** | Same as Gemini, enterprise ADC auth | ADC JSON |
|
|
145
|
+
| **DashScope / 百炼** | Qwen image, Wan video, music, TTS/STT | `DASHSCOPE_API_KEY` |
|
|
146
|
+
| **QwenCloud** | Same as DashScope (international endpoints) | `DASHSCOPE_API_KEY` |
|
|
147
|
+
| **OpenRouter** | Image gen, async video, TTS | `OPENROUTER_API_KEY` |
|
|
148
|
+
| **Atlas** | Image gen/edit, video (sync + async) | `ATLAS_API_KEY` |
|
|
149
|
+
|
|
150
|
+
To see which providers are active in your current setup, ask Pi:
|
|
151
|
+
|
|
152
|
+
```
|
|
153
|
+
What media providers do I have configured?
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
## Available Tools
|
|
159
|
+
|
|
160
|
+
The extension registers exactly 6 tools. Pi selects the correct one automatically based on your request.
|
|
161
|
+
|
|
162
|
+
| Tool | Purpose |
|
|
163
|
+
|---|---|
|
|
164
|
+
| `media_models` | List providers, models, and capabilities |
|
|
165
|
+
| `image_generate` | Generate images from text or reference images |
|
|
166
|
+
| `image_edit` | Edit an existing image (inpainting, style, background) |
|
|
167
|
+
| `video_generate` | Text-to-video, image-to-video, video extend/edit |
|
|
168
|
+
| `audio_generate` | Generate music or raw audio |
|
|
169
|
+
| `speech_generate` | TTS (text → audio file) or STT (audio → transcript) |
|
|
170
|
+
|
|
171
|
+
---
|
|
172
|
+
|
|
173
|
+
## Advanced: Custom OpenAI-Compatible Providers
|
|
174
|
+
|
|
175
|
+
You can add any OpenAI-compatible API as a custom provider in the config file. Capabilities and endpoints must be declared explicitly — the extension does not probe `/models` to infer them.
|
|
176
|
+
|
|
177
|
+
```json
|
|
178
|
+
{
|
|
67
179
|
"customProviders": [
|
|
68
180
|
{
|
|
69
|
-
"id": "my-
|
|
181
|
+
"id": "my-gateway",
|
|
70
182
|
"name": "Internal AI Gateway",
|
|
71
|
-
"baseUrl": "https://api.internal.com/v1",
|
|
183
|
+
"baseUrl": "https://api.internal.example.com/v1",
|
|
72
184
|
"apiKeyEnv": "MY_INTERNAL_KEY",
|
|
73
185
|
"auth": "bearer",
|
|
74
186
|
"models": [
|
|
75
187
|
{
|
|
76
|
-
"id": "internal-
|
|
188
|
+
"id": "internal-image-v2",
|
|
77
189
|
"vendor": "internal",
|
|
78
|
-
"capabilities": ["
|
|
190
|
+
"capabilities": ["image.text_to_image"],
|
|
79
191
|
"endpoints": {
|
|
80
|
-
"
|
|
192
|
+
"image.text_to_image": "/images/generations"
|
|
81
193
|
}
|
|
82
194
|
}
|
|
83
195
|
]
|
|
@@ -86,23 +198,24 @@ API Keys can be provided as standard environment variables. Alternatively, you c
|
|
|
86
198
|
}
|
|
87
199
|
```
|
|
88
200
|
|
|
89
|
-
|
|
201
|
+
---
|
|
90
202
|
|
|
91
|
-
##
|
|
203
|
+
## Security
|
|
92
204
|
|
|
93
|
-
|
|
205
|
+
- API keys and Bearer tokens are automatically redacted (`[REDACTED]`) from all error messages and logs before being returned to the LLM context.
|
|
206
|
+
- The config file (`media-models.json`) is listed in `.gitignore` and is never included in the npm package.
|
|
207
|
+
- No telemetry. All requests go directly from your machine to the provider API.
|
|
94
208
|
|
|
95
|
-
|
|
96
|
-
2. `image_generate`: Generate images from text, image, or multiple reference inputs.
|
|
97
|
-
3. `image_edit`: Edit existing images (supports masks and multiple references).
|
|
98
|
-
4. `video_generate`: Generates, edits, or extends videos. Automatically maps inputs (`referenceImages`, `inputVideo`, `duration`, `generateAudio`, etc.) to the provider's exact capability.
|
|
99
|
-
5. `audio_generate`: Generate music or raw audio (separate from TTS).
|
|
100
|
-
6. `speech_generate`: Handle TTS (Text-to-Speech) and STT (Speech-to-Text).
|
|
209
|
+
---
|
|
101
210
|
|
|
102
|
-
##
|
|
211
|
+
## Updating
|
|
103
212
|
|
|
104
|
-
|
|
105
|
-
|
|
213
|
+
```bash
|
|
214
|
+
pi update npm:pi-media-models
|
|
215
|
+
```
|
|
106
216
|
|
|
107
217
|
---
|
|
108
|
-
|
|
218
|
+
|
|
219
|
+
## License
|
|
220
|
+
|
|
221
|
+
MIT
|
package/package.json
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "pi-media-models",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.4",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Provider-neutral multimodal generation tools for Pi Coding Agent",
|
|
6
|
+
"keywords": [
|
|
7
|
+
"pi-package"
|
|
8
|
+
],
|
|
6
9
|
"pi": {
|
|
7
10
|
"extensions": [
|
|
8
11
|
"./index.ts"
|
|
9
12
|
],
|
|
10
13
|
"skills": [
|
|
11
|
-
"./
|
|
14
|
+
"./skills"
|
|
12
15
|
]
|
|
13
16
|
},
|
|
14
17
|
"scripts": {
|
|
@@ -21,6 +24,9 @@
|
|
|
21
24
|
"google-auth-library": "^10.5.0",
|
|
22
25
|
"typebox": "^1.0.62"
|
|
23
26
|
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
29
|
+
},
|
|
24
30
|
"devDependencies": {
|
|
25
31
|
"@earendil-works/pi-coding-agent": "0.84.4",
|
|
26
32
|
"@types/node": "^24.10.0",
|
|
@@ -33,8 +39,8 @@
|
|
|
33
39
|
},
|
|
34
40
|
"files": [
|
|
35
41
|
"src",
|
|
42
|
+
"skills",
|
|
36
43
|
"index.ts",
|
|
37
|
-
"SKILL.md",
|
|
38
44
|
"README.md"
|
|
39
45
|
]
|
|
40
46
|
}
|
|
File without changes
|