@computesdk/pi-particle 0.0.0-stage → 1.0.0
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/LICENSE +21 -0
- package/README.md +28 -2
- package/index.ts +71 -0
- package/package.json +51 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 computesdk
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @computesdk/pi-particle
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[Particle AI](https://particle.ai) as a Pi provider: an OpenAI-compatible inference platform for open-weight models.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
pi install npm:@computesdk/pi-particle # or: pi -e /path/to/pi-extensions/packages/pi-particle
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
Set `PARTICLE_API_KEY` (keys look like `pai-…`) in your environment and the models show up in `/model` as `particle/particle-1` and friends.
|
|
10
|
+
|
|
11
|
+
| Model | Input | Context | $/1M in | $/1M out |
|
|
12
|
+
| --- | --- | --- | --- | --- |
|
|
13
|
+
| `particle-1` — Particle-1 | text, image | 1M | 0.25 | 1.00 |
|
|
14
|
+
| `deepseek-ai/deepseek-v41-flash-1017` — DeepSeek V4.1 Flash | text, image | 1M | 0.25 | 1.00 |
|
|
15
|
+
| `glm-5.3-flash` — GLM 5.3 Flash | text, image | 1M | 0.12 | 0.40 |
|
|
16
|
+
|
|
17
|
+
Endpoint `https://api.particle.ai/v1`, bearer auth, `api: "openai-completions"` — Pi's built-in implementation does the request, stream and tool-call plumbing, so the whole extension is one `pi.registerProvider` call with the catalog above. Prices are per 1M tokens at Particle's peak (standard) rates from [docs.particle.ai/usage-billing](https://docs.particle.ai/usage-billing); off-peak is half of these.
|
|
18
|
+
|
|
19
|
+
Pi's thinking levels map onto Particle's `reasoning_effort` ladder (`none | low | high | xhigh | max`; `minimal`/`medium` collapse onto `low`/`high`). GLM 5.3 Flash always reasons — Particle rejects `reasoning_effort: "none"` with a 400 — so `off` is marked unsupported (`null`) for that model rather than sent.
|
|
20
|
+
|
|
21
|
+
## Development
|
|
22
|
+
|
|
23
|
+
```sh
|
|
24
|
+
pnpm test # tsc --noEmit && node test.ts
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`test.ts` loads the extension with a fake Pi and checks every registered model: id, name, modalities, context/output limits, costs, uniqueness, and that every Pi thinking level is either mapped to a provider value or explicitly unsupported.
|
|
28
|
+
|
|
29
|
+
MIT licensed.
|
package/index.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
// Particle AI — an OpenAI-compatible inference platform for open-weight models.
|
|
2
|
+
// Base URL: https://api.particle.ai/v1 · Auth: Authorization: Bearer <PARTICLE_API_KEY> (keys look like `pai-…`).
|
|
3
|
+
// Docs: https://docs.particle.ai · Models: https://docs.particle.ai/models
|
|
4
|
+
//
|
|
5
|
+
// This is a Pi provider extension: `pi.registerProvider` adds the endpoint and its model catalog, and Pi's
|
|
6
|
+
// built-in `openai-completions` implementation handles the request/stream/tool-call plumbing. Load it with
|
|
7
|
+
// `pi -e ./index.ts` or install the package (`pi install npm:@computesdk/pi-particle`).
|
|
8
|
+
//
|
|
9
|
+
// Prices are USD per 1M tokens, at Particle's peak (standard) rates; off-peak is 50% of these. Update them
|
|
10
|
+
// from https://docs.particle.ai/usage-billing when they change.
|
|
11
|
+
|
|
12
|
+
import type { ExtensionAPI, ProviderModelConfig } from "@earendil-works/pi-coding-agent";
|
|
13
|
+
|
|
14
|
+
/** Pi's chat-model shape: the chat arm of the provider model union. */
|
|
15
|
+
type ChatModel = Extract<ProviderModelConfig, { type?: "chat" }>;
|
|
16
|
+
type ThinkingLevelMap = NonNullable<ChatModel["thinkingLevelMap"]>;
|
|
17
|
+
|
|
18
|
+
// Pi thinking levels (off/minimal/low/medium/high/xhigh/max) → the provider's `reasoning_effort` value.
|
|
19
|
+
// Particle's ladder: none | low | high | xhigh | max; `minimal`/`medium` collapse onto low/high.
|
|
20
|
+
// GLM 5.3 Flash always reasons — `off` is rejected with 400, so it is marked unsupported (`null`).
|
|
21
|
+
const EFFORT_STANDARD: ThinkingLevelMap = { off: "none", minimal: "low", low: "low", medium: "high", high: "high", xhigh: "high", max: "max" };
|
|
22
|
+
const EFFORT_GLM: ThinkingLevelMap = { off: null, minimal: "low", low: "low", medium: "high", high: "high", xhigh: "xhigh", max: "max" };
|
|
23
|
+
|
|
24
|
+
const CONTEXT = 1_048_576; // every Particle model: 1M tokens (prompt + completion combined)
|
|
25
|
+
const MAX_TOKENS = 32_768; // default output cap when no limit is sent; the ceiling is 131,072
|
|
26
|
+
|
|
27
|
+
export const MODELS: ChatModel[] = [
|
|
28
|
+
{
|
|
29
|
+
type: "chat",
|
|
30
|
+
id: "particle-1",
|
|
31
|
+
name: "Particle-1",
|
|
32
|
+
reasoning: true,
|
|
33
|
+
thinkingLevelMap: EFFORT_STANDARD,
|
|
34
|
+
input: ["text", "image"],
|
|
35
|
+
cost: { input: 0.25, output: 1.0, cacheRead: 0.03, cacheWrite: 0 },
|
|
36
|
+
contextWindow: CONTEXT,
|
|
37
|
+
maxTokens: MAX_TOKENS,
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
type: "chat",
|
|
41
|
+
id: "deepseek-ai/deepseek-v41-flash-1017",
|
|
42
|
+
name: "DeepSeek V4.1 Flash",
|
|
43
|
+
reasoning: true,
|
|
44
|
+
thinkingLevelMap: EFFORT_STANDARD,
|
|
45
|
+
input: ["text", "image"],
|
|
46
|
+
cost: { input: 0.25, output: 1.0, cacheRead: 0.03, cacheWrite: 0 },
|
|
47
|
+
contextWindow: CONTEXT,
|
|
48
|
+
maxTokens: MAX_TOKENS,
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
type: "chat",
|
|
52
|
+
id: "glm-5.3-flash",
|
|
53
|
+
name: "GLM 5.3 Flash",
|
|
54
|
+
reasoning: true,
|
|
55
|
+
thinkingLevelMap: EFFORT_GLM,
|
|
56
|
+
input: ["text", "image"],
|
|
57
|
+
cost: { input: 0.12, output: 0.4, cacheRead: 0.03, cacheWrite: 0 },
|
|
58
|
+
contextWindow: CONTEXT,
|
|
59
|
+
maxTokens: MAX_TOKENS,
|
|
60
|
+
},
|
|
61
|
+
];
|
|
62
|
+
|
|
63
|
+
export default function particleProvider(pi: ExtensionAPI) {
|
|
64
|
+
pi.registerProvider("particle", {
|
|
65
|
+
name: "Particle AI",
|
|
66
|
+
baseUrl: "https://api.particle.ai/v1",
|
|
67
|
+
apiKey: "$PARTICLE_API_KEY",
|
|
68
|
+
api: "openai-completions",
|
|
69
|
+
models: MODELS,
|
|
70
|
+
});
|
|
71
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,53 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@computesdk/pi-particle",
|
|
3
|
-
"version": "
|
|
4
|
-
"
|
|
5
|
-
"
|
|
6
|
-
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Particle AI provider for Pi: particle-1, DeepSeek V4.1 Flash and GLM 5.3 Flash on Particle's OpenAI-compatible API.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"pi-package",
|
|
7
|
+
"pi",
|
|
8
|
+
"pi-extension",
|
|
9
|
+
"provider",
|
|
10
|
+
"particle",
|
|
11
|
+
"particle-ai",
|
|
12
|
+
"openai-compatible"
|
|
13
|
+
],
|
|
14
|
+
"license": "MIT",
|
|
15
|
+
"type": "module",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/computesdk/pi-extensions.git",
|
|
19
|
+
"directory": "packages/pi-particle"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/computesdk/pi-extensions/tree/main/packages/pi-particle#readme",
|
|
22
|
+
"bugs": {
|
|
23
|
+
"url": "https://github.com/computesdk/pi-extensions/issues"
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"engines": {
|
|
29
|
+
"node": ">=22.18.0"
|
|
30
|
+
},
|
|
31
|
+
"pi": {
|
|
32
|
+
"extensions": [
|
|
33
|
+
"./index.ts"
|
|
34
|
+
]
|
|
35
|
+
},
|
|
36
|
+
"files": [
|
|
37
|
+
"index.ts",
|
|
38
|
+
"README.md",
|
|
39
|
+
"LICENSE"
|
|
40
|
+
],
|
|
41
|
+
"scripts": {
|
|
42
|
+
"check": "tsc --noEmit",
|
|
43
|
+
"test": "tsc --noEmit && node test.ts"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"@earendil-works/pi-coding-agent": "*"
|
|
47
|
+
},
|
|
48
|
+
"devDependencies": {
|
|
49
|
+
"@earendil-works/pi-coding-agent": "catalog:",
|
|
50
|
+
"@types/node": "catalog:",
|
|
51
|
+
"typescript": "catalog:"
|
|
52
|
+
}
|
|
53
|
+
}
|