pi-tarmis-provider 1.0.7
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/AGENTS.md +82 -0
- package/LICENSE +21 -0
- package/README.md +184 -0
- package/custom-models.json +1 -0
- package/deprecated-models.json +1 -0
- package/index.ts +463 -0
- package/models.json +143 -0
- package/package.json +61 -0
- package/patch.json +34 -0
- package/scripts/update-models.js +501 -0
package/AGENTS.md
ADDED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
# AGENTS.md
|
|
2
|
+
|
|
3
|
+
## DO NOT EDIT — Auto-generated Files
|
|
4
|
+
|
|
5
|
+
The following files are **idempotent** and regenerated by `scripts/update-models.js`. Never edit them directly — your changes will be overwritten on the next model sync.
|
|
6
|
+
|
|
7
|
+
| File | Why it's auto-generated |
|
|
8
|
+
|------|------------------------|
|
|
9
|
+
| `models.json` | Built from the provider API. `update-models.js` fetches models, derives pricing/context/maxTokens/vision/reasoning from the API metadata, and writes this file. |
|
|
10
|
+
| `deprecated-models.json` | Graveyard for models the API delisted. update-models.js stamps them with deprecatedAt and pi keeps serving them for a 2-week grace period, then evicts them. Never edit by hand. |
|
|
11
|
+
| `README.md` (model table) | The table under `## Available Models` is replaced in-place by `update-models.js` after merging base models → patch → custom models. |
|
|
12
|
+
|
|
13
|
+
## Correct Files to Edit
|
|
14
|
+
|
|
15
|
+
When a model needs overrides, new properties, or corrections, edit the appropriate source file below. These are the **source of truth** that the update script reads but never writes.
|
|
16
|
+
|
|
17
|
+
| File | Purpose |
|
|
18
|
+
|------|---------|
|
|
19
|
+
| `patch.json` | Per-model overrides keyed by model ID. Add reasoning flags, compat settings, pricing corrections, thinking level maps, etc. Applied on top of `models.json` at runtime and for README generation. |
|
|
20
|
+
| `custom-models.json` | Models that don't exist in the provider API (hidden models, router endpoints, cross-provider aliases). Merged after patch. Format: array of full model objects (same schema as `models.json` entries). |
|
|
21
|
+
| `index.ts` | Provider extension code. |
|
|
22
|
+
| `scripts/update-models.js` | The sync script itself (edit only if changing how models are fetched/transformed). |
|
|
23
|
+
|
|
24
|
+
## How Tarmis differs from other providers
|
|
25
|
+
|
|
26
|
+
Tarmis's `/v1/models` endpoint returns **rich metadata** (name, per-token pricing with an optional cached-input rate, `context_length`, `max_output_length`, `input_modalities`, and `supported_features`). `transformModel` derives most model fields directly from the API, so `models.json` self-heals on every sync:
|
|
27
|
+
|
|
28
|
+
- `reasoning` ← `supported_features` includes `"reasoning"`
|
|
29
|
+
- `input` / vision ← `input_modalities` includes `"image"`
|
|
30
|
+
- `cost` ← `pricing[0].prompt` / `completion` / `input_cache_read` (per-token → per-million)
|
|
31
|
+
- `contextWindow` ← `context_length`
|
|
32
|
+
- `maxTokens` ← `max_output_length`
|
|
33
|
+
|
|
34
|
+
The API reports *which* models support reasoning, but not the wire format each model expects. Reasoning models are given standard OpenAI-compatible defaults (`thinkingFormat: "openai"`, `supportsReasoningEffort: true`, `supportsDeveloperRole: false`). `patch.json` is where you override that for any model that needs a different format (e.g. a DeepSeek-native `thinking` field).
|
|
35
|
+
|
|
36
|
+
Additionally, `/v1/models` is **public** (no auth), so the catalogue syncs even before a key is configured.
|
|
37
|
+
|
|
38
|
+
## Data Flow
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
Provider API ──fetch──► models.json ──apply──► patch.json ──merge──► custom-models.json
|
|
42
|
+
│ │ │
|
|
43
|
+
└────────────────────────────┴──────────────────────┘
|
|
44
|
+
│
|
|
45
|
+
README model table
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
1. `models.json` — base data from the provider API (auto-generated, DO NOT EDIT)
|
|
49
|
+
2. `patch.json` — overrides applied on top (EDIT THIS for corrections/enrichments)
|
|
50
|
+
3. `custom-models.json` — additional models not in the API (EDIT THIS for new models)
|
|
51
|
+
4. README table — rendered from the merged result of all three (auto-generated, DO NOT EDIT)
|
|
52
|
+
|
|
53
|
+
## Common Tasks
|
|
54
|
+
|
|
55
|
+
### Change a reasoning model's thinking format
|
|
56
|
+
→ Edit `patch.json`. Add an entry keyed by the model's `id` with a `compat` override, e.g.:
|
|
57
|
+
```json
|
|
58
|
+
{
|
|
59
|
+
"deepseek-ai/DeepSeek-V4-Flash": {
|
|
60
|
+
"compat": { "thinkingFormat": "deepseek", "requiresReasoningContentOnAssistantMessages": true }
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### Add a compat setting or override pricing for an existing model
|
|
66
|
+
→ Edit `patch.json`. Add an entry keyed by the model's `id`.
|
|
67
|
+
|
|
68
|
+
### Add a model not available in the provider API
|
|
69
|
+
→ Edit `custom-models.json`. Add a full model object to the array.
|
|
70
|
+
|
|
71
|
+
### Update models from the provider API
|
|
72
|
+
→ Run `node scripts/update-models.js` (the `/v1/models` endpoint is public — no key needed).
|
|
73
|
+
|
|
74
|
+
### Regenerate the README model table
|
|
75
|
+
→ Run `node scripts/update-models.js` — it updates both `models.json` and the README table.
|
|
76
|
+
|
|
77
|
+
## TL;DR
|
|
78
|
+
|
|
79
|
+
- **Never edit `models.json`** — edit `patch.json` instead.
|
|
80
|
+
- **Never edit the README model table** — run the update script instead.
|
|
81
|
+
- `patch.json` and `custom-models.json` are the source files you should modify.
|
|
82
|
+
- Most model fields are auto-derived from the API; `patch.json` only needs entries when a model deviates from the defaults.
|
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025
|
|
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
ADDED
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
# 🪐 pi-tarmis-provider
|
|
4
|
+
|
|
5
|
+
**Open models on Tarmis's own GPUs for [pi](https://github.com/earendil-works/pi-coding-agent)**
|
|
6
|
+
|
|
7
|
+
_One OpenAI-compatible API to open models on Tarmis's own GPUs — DeepSeek, GLM, Kimi, MiniMax, and more._
|
|
8
|
+
|
|
9
|
+
[](https://www.npmjs.com/package/pi-tarmis-provider)
|
|
10
|
+
[](https://github.com/earendil-works/pi-coding-agent)
|
|
11
|
+
[](./LICENSE)
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
---
|
|
16
|
+
|
|
17
|
+
## Features
|
|
18
|
+
|
|
19
|
+
- **OpenAI-compatible API** — Uses Tarmis's `/v1/chat/completions` endpoint
|
|
20
|
+
- **Rich auto-synced catalogue** — The Tarmis `/v1/models` endpoint returns per-model pricing, context windows, max output, modalities, and supported features; `models.json` is generated directly from it
|
|
21
|
+
- **Public model list** — `/v1/models` is unauthenticated, so pi lists Tarmis models (and the background model sync runs) even before you set a key
|
|
22
|
+
- **Reasoning models** — Thinking models are detected from the API's `supported_features` and configured for `reasoning_effort` control
|
|
23
|
+
- **Vision models** — Image input is auto-detected from `input_modalities`
|
|
24
|
+
- **Tool use** — Function calling for models that advertise `tools` support
|
|
25
|
+
- **Streaming** — Real-time token streaming
|
|
26
|
+
- **Prompt caching** — Cached input is billed at a cheaper rate when the API reports an `input_cache_read` price
|
|
27
|
+
|
|
28
|
+
## Available Models
|
|
29
|
+
|
|
30
|
+
| Model | Context | Vision | Reasoning | Input $/M | Output $/M |
|
|
31
|
+
|-------|---------|--------|-----------|-----------|------------|
|
|
32
|
+
| DeepSeek V4 Flash | 1.0M | ❌ | ✅ | $0.09 | $0.18 |
|
|
33
|
+
| DeepSeek V4 Pro | 1.0M | ❌ | ✅ | $0.43 | $0.87 |
|
|
34
|
+
| GLM-5.2 | 1.0M | ❌ | ✅ | $0.60 | $2.20 |
|
|
35
|
+
| Kimi K3 | 1.0M | ✅ | ✅ | $2.50 | $10.00 |
|
|
36
|
+
| MiniMax M3 | 524K | ❌ | ✅ | $0.30 | $1.20 |
|
|
37
|
+
|
|
38
|
+
> The table above is regenerated by `node scripts/update-models.js` from the live Tarmis API. Costs are per million tokens (the API reports per-token prices). Prices subject to change — check [docs.tarmis.ai/docs/pricing](https://docs.tarmis.ai/docs/pricing) for current pricing.
|
|
39
|
+
|
|
40
|
+
## Installation
|
|
41
|
+
|
|
42
|
+
### Option 1: Using `pi install` (Recommended)
|
|
43
|
+
|
|
44
|
+
Install from npm (published as [`pi-tarmis-provider`](https://www.npmjs.com/package/pi-tarmis-provider)) or directly from GitHub:
|
|
45
|
+
|
|
46
|
+
```bash
|
|
47
|
+
# From npm
|
|
48
|
+
pi install npm:pi-tarmis-provider
|
|
49
|
+
|
|
50
|
+
# Or directly from GitHub
|
|
51
|
+
pi install https://github.com/monotykamary/pi-tarmis-provider
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
Then set your API key and run pi:
|
|
55
|
+
```bash
|
|
56
|
+
# Recommended: add to auth.json
|
|
57
|
+
# See Authentication section below
|
|
58
|
+
|
|
59
|
+
# Or set as environment variable
|
|
60
|
+
export TARMIS_API_KEY=your-api-key-here
|
|
61
|
+
|
|
62
|
+
pi
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Get your API key from [tarmis.ai](https://tarmis.ai).
|
|
66
|
+
|
|
67
|
+
### Option 2: Manual Clone
|
|
68
|
+
|
|
69
|
+
1. Clone this repository:
|
|
70
|
+
```bash
|
|
71
|
+
git clone https://github.com/monotykamary/pi-tarmis-provider.git
|
|
72
|
+
cd pi-tarmis-provider
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
2. Set your Tarmis API key:
|
|
76
|
+
```bash
|
|
77
|
+
# Recommended: add to auth.json
|
|
78
|
+
# See Authentication section below
|
|
79
|
+
|
|
80
|
+
# Or set as environment variable
|
|
81
|
+
export TARMIS_API_KEY=your-api-key-here
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
3. Run pi with the extension:
|
|
85
|
+
```bash
|
|
86
|
+
pi -e /path/to/pi-tarmis-provider
|
|
87
|
+
```
|
|
88
|
+
|
|
89
|
+
## Authentication
|
|
90
|
+
|
|
91
|
+
The Tarmis API key can be configured in multiple ways (resolved in this order):
|
|
92
|
+
|
|
93
|
+
1. **`auth.json`** (recommended) — Add to `~/.pi/agent/auth.json`:
|
|
94
|
+
```json
|
|
95
|
+
{ "tarmis": { "type": "api_key", "key": "your-api-key" } }
|
|
96
|
+
```
|
|
97
|
+
The `key` field supports literal values, env var names, and shell commands (prefix with `!`). See [pi's auth file docs](https://github.com/badlogic/pi-mono) for details.
|
|
98
|
+
2. **Runtime override** — Use the `--api-key` CLI flag
|
|
99
|
+
3. **Environment variable** — Set `TARMIS_API_KEY`
|
|
100
|
+
|
|
101
|
+
Get your API key from [tarmis.ai](https://tarmis.ai).
|
|
102
|
+
|
|
103
|
+
> **Note:** A key is only required to actually call a model. The model catalogue (`/v1/models`) is public, so pi displays available Tarmis models and keeps them synced even before a key is configured.
|
|
104
|
+
|
|
105
|
+
## Environment Variables
|
|
106
|
+
|
|
107
|
+
| Variable | Required | Description |
|
|
108
|
+
|----------|----------|-------------|
|
|
109
|
+
| `TARMIS_API_KEY` | No | Your Tarmis API key (fallback if not in auth.json; only needed to call a model) |
|
|
110
|
+
|
|
111
|
+
## Configuration
|
|
112
|
+
|
|
113
|
+
Add to your pi configuration for automatic loading:
|
|
114
|
+
|
|
115
|
+
```json
|
|
116
|
+
{
|
|
117
|
+
"extensions": [
|
|
118
|
+
"/path/to/pi-tarmis-provider"
|
|
119
|
+
]
|
|
120
|
+
}
|
|
121
|
+
```
|
|
122
|
+
|
|
123
|
+
## Usage
|
|
124
|
+
|
|
125
|
+
Once loaded, select a model with:
|
|
126
|
+
|
|
127
|
+
```
|
|
128
|
+
/model tarmis minimax/minimax-m3
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
Or use `/models` to browse all available Tarmis models.
|
|
132
|
+
|
|
133
|
+
### Reasoning Effort
|
|
134
|
+
|
|
135
|
+
For reasoning models, control thinking depth:
|
|
136
|
+
|
|
137
|
+
```
|
|
138
|
+
/reasoning high
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
Values: `none`, `low`, `medium`, `high`, `max`
|
|
142
|
+
|
|
143
|
+
## API Compatibility
|
|
144
|
+
|
|
145
|
+
Tarmis provides an OpenAI-compatible API. Key notes:
|
|
146
|
+
|
|
147
|
+
| Aspect | Behavior |
|
|
148
|
+
|--------|----------|
|
|
149
|
+
| Endpoint | `https://api.tarmis.ai/v1/chat/completions` |
|
|
150
|
+
| Max tokens field | Both `max_tokens` and `max_completion_tokens` accepted |
|
|
151
|
+
| Thinking format | `openai` (`reasoning_content` in response, `reasoning_effort` in request) |
|
|
152
|
+
| Developer role | Not assumed (developer messages are converted to system) |
|
|
153
|
+
| Reasoning effort | Accepted by reasoning models |
|
|
154
|
+
| `/v1/models` | Public (no auth) — returns pricing, context, modalities, and features |
|
|
155
|
+
| Prompt caching | Cached input billed at a cheaper `input_cache_read` rate when the API exposes one |
|
|
156
|
+
|
|
157
|
+
> **Reasoning compat:** The Tarmis `/v1/models` endpoint reports *which* models support reasoning, but not the wire format each model expects. Reasoning models are given the standard OpenAI-compatible defaults (`thinkingFormat: "openai"`, `supportsReasoningEffort: true`, `supportsDeveloperRole: false`). If a model on Tarmis needs a different format (for example DeepSeek's native `thinking` field), override it in `patch.json` — see [AGENTS.md](./AGENTS.md).
|
|
158
|
+
|
|
159
|
+
## API Documentation
|
|
160
|
+
|
|
161
|
+
- Tarmis Docs: https://docs.tarmis.ai
|
|
162
|
+
- OpenAI-compatible endpoint: `https://api.tarmis.ai/v1`
|
|
163
|
+
- Models endpoint (public): `https://api.tarmis.ai/v1/models`
|
|
164
|
+
- Pricing: https://docs.tarmis.ai/docs/pricing
|
|
165
|
+
|
|
166
|
+
## Updating Models
|
|
167
|
+
|
|
168
|
+
Run the update script to fetch the latest models from Tarmis's API:
|
|
169
|
+
|
|
170
|
+
```bash
|
|
171
|
+
node scripts/update-models.js
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
The `/v1/models` endpoint is public, so no API key is required. This will:
|
|
175
|
+
|
|
176
|
+
1. Fetch models from `https://api.tarmis.ai/v1/models`
|
|
177
|
+
2. Derive pricing, context windows, max output, vision, and reasoning support from the API metadata
|
|
178
|
+
3. Apply overrides from `patch.json`
|
|
179
|
+
4. Update `models.json` and the README model table
|
|
180
|
+
5. Move delisted models into `deprecated-models.json` (14-day grace period)
|
|
181
|
+
|
|
182
|
+
## License
|
|
183
|
+
|
|
184
|
+
MIT
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
[]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|