@opencode-ai/models 0.0.3 → 0.0.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 +4 -29
- package/dist/snapshot.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,11 @@
|
|
|
1
1
|
# @opencode-ai/models
|
|
2
2
|
|
|
3
|
-
Official typed client for the [
|
|
3
|
+
Official typed client for the [Models.dev](https://models.dev) API.
|
|
4
4
|
|
|
5
5
|
```sh
|
|
6
6
|
npm install @opencode-ai/models
|
|
7
7
|
```
|
|
8
8
|
|
|
9
|
-
- **Zero dependencies.** The root client is a small `fetch` wrapper; works on Node ≥ 18, Bun, Deno, browsers, and edge runtimes.
|
|
10
|
-
- **Fully typed.** Hand-written types, verified in CI to be exactly equivalent to the schemas that generate the data.
|
|
11
|
-
- **Three entrypoints.** Promise client, [Effect](https://effect.website) client, and a bundled offline snapshot.
|
|
12
|
-
|
|
13
9
|
## Usage
|
|
14
10
|
|
|
15
11
|
```ts
|
|
@@ -26,19 +22,6 @@ models["anthropic/claude-opus-4-6"]?.knowledge // provider-agnostic metadata
|
|
|
26
22
|
const catalog = await client.catalog() // GET /catalog.json — both in one request
|
|
27
23
|
```
|
|
28
24
|
|
|
29
|
-
| Method | Endpoint | Contents |
|
|
30
|
-
| --- | --- | --- |
|
|
31
|
-
| `providers()` | `/api.json` | Providers with their models, pricing, and limits |
|
|
32
|
-
| `models()` | `/models.json` | Provider-agnostic model metadata, keyed by `<lab>/<model>` |
|
|
33
|
-
| `catalog()` | `/catalog.json` | `{ providers, models }` in a single payload |
|
|
34
|
-
|
|
35
|
-
The client is **stateless**: every call performs exactly one GET, nothing is cached, and lookups are plain object access on the returned data. Cache however you like:
|
|
36
|
-
|
|
37
|
-
```ts
|
|
38
|
-
let cached: Promise<ProviderMap> | undefined
|
|
39
|
-
const providers = () => (cached ??= client.providers())
|
|
40
|
-
```
|
|
41
|
-
|
|
42
25
|
Options:
|
|
43
26
|
|
|
44
27
|
```ts
|
|
@@ -53,9 +36,9 @@ await client.providers({ signal: AbortSignal.timeout(5000) })
|
|
|
53
36
|
|
|
54
37
|
Errors are a single `ModelsDevError` with `reason: "Transport" | "UnexpectedStatus" | "MalformedResponse"` and the underlying `cause`.
|
|
55
38
|
|
|
56
|
-
##
|
|
39
|
+
## Snapshot
|
|
57
40
|
|
|
58
|
-
A full copy of the database ships inside the package as a separate, tree-shakable entrypoint
|
|
41
|
+
A full copy of the database ships inside the package as a separate, tree-shakable entrypoint:
|
|
59
42
|
|
|
60
43
|
```ts
|
|
61
44
|
import snapshot, { providers, models, generatedAt } from "@opencode-ai/models/snapshot"
|
|
@@ -69,7 +52,7 @@ Use it for no-network runtimes, tests, cold-start-sensitive paths, or as an expl
|
|
|
69
52
|
const providers = await client.providers().catch(async () => (await import("@opencode-ai/models/snapshot")).providers)
|
|
70
53
|
```
|
|
71
54
|
|
|
72
|
-
|
|
55
|
+
The published snapshot is at most ~24h behind the live API (data releases are automated).
|
|
73
56
|
|
|
74
57
|
## Effect
|
|
75
58
|
|
|
@@ -98,11 +81,3 @@ const program = Effect.gen(function* () {
|
|
|
98
81
|
|
|
99
82
|
program.pipe(Effect.provide(Models.layer().pipe(Layer.provide(FetchHttpClient.layer))))
|
|
100
83
|
```
|
|
101
|
-
|
|
102
|
-
## Types
|
|
103
|
-
|
|
104
|
-
All data types are exported from the root (and re-exported from `/effect`): `Provider`, `Model`, `ModelMetadata`, `Catalog`, `Cost`, `Limit`, `ReasoningOption`, and friends.
|
|
105
|
-
|
|
106
|
-
## Contributing
|
|
107
|
-
|
|
108
|
-
The data lives as TOML files in [anomalyco/models.dev](https://github.com/anomalyco/models.dev) — corrections and new models/providers are welcome there. This package is generated and published from that repository.
|