@shop-os/modelkit 0.2.11 → 0.2.12
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/CHANGELOG.md +8 -0
- package/README.md +5 -1
- package/dist/index.cjs +16 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +16 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,14 @@ header in the release PR.
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [0.2.12] - 2026-09-17
|
|
13
|
+
|
|
14
|
+
### Changed
|
|
15
|
+
- Usage events for Anthropic calls that Bedrock serves carry `provider: "bedrock"`. They carried `"anthropic"` in 0.2.11. `model` is still the catalog id, and token pricing is keyed by the model id alone, so billing does not change; usage reports get one group per transport. Calls on the Anthropic API still carry `"anthropic"`. The AI SDK provider id of the model (`model.provider`) stays `anthropic.messages` on both transports.
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
- `kit.usageProvider(modelId, call?)` and `LanguageModelHandle.usageProvider`: the `provider` an app puts on a usage event it emits itself. It follows the resolved transport, including the credential fallback, without building the model.
|
|
19
|
+
|
|
12
20
|
## [0.2.11] - 2026-09-17
|
|
13
21
|
|
|
14
22
|
### Added
|
package/README.md
CHANGED
|
@@ -131,7 +131,11 @@ The kit keeps its `Warning` type for coercions; the SDK's warning type is `AiWar
|
|
|
131
131
|
|
|
132
132
|
Anthropic catalog rows can go through AWS Bedrock InvokeModel instead of the
|
|
133
133
|
Anthropic API. The call surface is the same, and usage events and
|
|
134
|
-
`response.modelId` still carry the catalog id.
|
|
134
|
+
`response.modelId` still carry the catalog id. Usage events for calls that
|
|
135
|
+
Bedrock serves carry `provider: "bedrock"`, so reports get one group per
|
|
136
|
+
transport; pricing is keyed by the model id alone and does not change. An app
|
|
137
|
+
that emits its own usage events takes the provider from
|
|
138
|
+
`kit.usageProvider(modelId)`.
|
|
135
139
|
|
|
136
140
|
The transport of a row is decided in this order:
|
|
137
141
|
|
package/dist/index.cjs
CHANGED
|
@@ -3488,6 +3488,10 @@ function resolveAnthropicTransport(model, config, tier, warn) {
|
|
|
3488
3488
|
warn(`[modelkit] ${model.id}: no credentials for the ${preferred} transport; using ${other}`);
|
|
3489
3489
|
return other;
|
|
3490
3490
|
}
|
|
3491
|
+
var BEDROCK_USAGE_PROVIDER = "bedrock";
|
|
3492
|
+
function textUsageProvider(model, transport) {
|
|
3493
|
+
return transport === "bedrock" ? BEDROCK_USAGE_PROVIDER : textProviderOf(model);
|
|
3494
|
+
}
|
|
3491
3495
|
|
|
3492
3496
|
// src/client.ts
|
|
3493
3497
|
function requiredKeys(model, config, transport) {
|
|
@@ -3658,7 +3662,7 @@ function createModelKit(config, adapters) {
|
|
|
3658
3662
|
return {
|
|
3659
3663
|
entry,
|
|
3660
3664
|
languageModel: adapter.languageModel(ctx),
|
|
3661
|
-
provider:
|
|
3665
|
+
provider: textUsageProvider(entry, ctx.anthropicTransport)
|
|
3662
3666
|
};
|
|
3663
3667
|
}
|
|
3664
3668
|
async function passthroughImage(req, call) {
|
|
@@ -3957,7 +3961,7 @@ function createModelKit(config, adapters) {
|
|
|
3957
3961
|
return "url" in ref ? { type: "file", data: ref.url, mediaType } : { type: "file", data: ref.bytes, mediaType };
|
|
3958
3962
|
},
|
|
3959
3963
|
languageModel(modelId, call = {}) {
|
|
3960
|
-
const { entry, languageModel: model } = textTarget(modelId, call);
|
|
3964
|
+
const { entry, languageModel: model, provider } = textTarget(modelId, call);
|
|
3961
3965
|
if (model.specificationVersion !== "v3")
|
|
3962
3966
|
throw new ModelKitError({
|
|
3963
3967
|
code: "unsupported_option",
|
|
@@ -3967,9 +3971,18 @@ function createModelKit(config, adapters) {
|
|
|
3967
3971
|
return {
|
|
3968
3972
|
model,
|
|
3969
3973
|
providerOptions: withoutModelkit(entry.providerOptions),
|
|
3970
|
-
catalog: entry
|
|
3974
|
+
catalog: entry,
|
|
3975
|
+
usageProvider: provider
|
|
3971
3976
|
};
|
|
3972
3977
|
},
|
|
3978
|
+
usageProvider(modelId, call = {}) {
|
|
3979
|
+
const entry = catalog.require(modelId);
|
|
3980
|
+
if (entry.type !== "text") return entry.adapter;
|
|
3981
|
+
return textUsageProvider(
|
|
3982
|
+
entry,
|
|
3983
|
+
resolveAnthropicTransport(entry, config, call.tier, warnOnce)
|
|
3984
|
+
);
|
|
3985
|
+
},
|
|
3973
3986
|
async generateText(options, call = {}) {
|
|
3974
3987
|
const target = textTarget(options.model, call);
|
|
3975
3988
|
const steps = createTextSteps(
|