@sixb/azure-ai-foundry 0.1.4 → 0.1.6

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.
@@ -1,5 +1,6 @@
1
- import type { JsonObject, LanguageModelRateCard, ModelCostEstimator, ModelUsage } from "@sixb/core/models";
1
+ import type { JsonObject, ModelRateCard, ModelUsage } from "@sixb/core/models";
2
+ import { type PricedEstimator } from "./accounting";
2
3
  /** Native Messages counters are additive; absent cache/thinking counters stay unknown. */
3
4
  export declare function foundryMessagesUsage(raw: JsonObject): ModelUsage;
4
- export declare function foundryMessagesEstimator(card: LanguageModelRateCard | undefined, request: JsonObject | undefined, modelName?: string, modelVersion?: string, aliases?: readonly string[]): ModelCostEstimator;
5
+ export declare function foundryMessagesEstimator(card: ModelRateCard | undefined, request: JsonObject | undefined, modelName?: string, modelVersion?: string, aliases?: readonly string[]): PricedEstimator;
5
6
  //# sourceMappingURL=messages-accounting.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"messages-accounting.d.ts","sourceRoot":"","sources":["../src/messages-accounting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,UAAU,EACV,qBAAqB,EACrB,kBAAkB,EAClB,UAAU,EACX,MAAM,mBAAmB,CAAA;AAI1B,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CA6BhE;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,qBAAqB,GAAG,SAAS,EACvC,OAAO,EAAE,UAAU,GAAG,SAAS,EAC/B,SAAS,CAAC,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAC1B,kBAAkB,CAoBpB"}
1
+ {"version":3,"file":"messages-accounting.d.ts","sourceRoot":"","sources":["../src/messages-accounting.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAsB,aAAa,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAA;AAClG,OAAO,EAAE,KAAK,eAAe,EAAkB,MAAM,cAAc,CAAA;AAGnE,0FAA0F;AAC1F,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,UAAU,GAAG,UAAU,CA6BhE;AAED,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,aAAa,GAAG,SAAS,EAC/B,OAAO,EAAE,UAAU,GAAG,SAAS,EAC/B,SAAS,CAAC,EAAE,MAAM,EAClB,YAAY,CAAC,EAAE,MAAM,EACrB,OAAO,CAAC,EAAE,SAAS,MAAM,EAAE,GAC1B,eAAe,CAoBjB"}
@@ -1,4 +1,4 @@
1
- import { type LanguageModel, type LanguageModelDefinition, type LanguageModelProvider, type LanguageModelRateCard, type ModelCostEstimator, type ModelReasoningLevel } from "@sixb/core/models";
1
+ import { type LanguageModel, type LanguageModelDefinition, type LanguageModelLabel, type LanguageModelProvider, type ModelCostEstimator, type ModelRateCard, type ModelReasoningLevel } from "@sixb/core/models";
2
2
  import { type AzureAIFoundryCatalogOptions } from "./catalog";
3
3
  import { type ChatRequestOptions } from "./chat-request";
4
4
  import { type AzureAIFoundryCatalog, type AzureAIFoundryDeployment, type AzureAIFoundryDiscoveryOptions } from "./discovery";
@@ -30,25 +30,25 @@ export interface AzureAIFoundryModelMetadata {
30
30
  readonly deployment?: AzureAIFoundryDeployment;
31
31
  readonly discoveredAt?: string;
32
32
  }
33
- export interface AzureAIFoundryModelOptions extends RequestOptions {
33
+ export interface AzureAIFoundryModelOptions extends RequestOptions, LanguageModelLabel {
34
34
  /** Reasoning Sixb applies when this model runs without an explicit choice. */
35
35
  readonly reasoning?: ModelReasoningLevel;
36
36
  readonly definition?: Omit<LanguageModelDefinition, "kind" | "providerId" | "modelId">;
37
- readonly rateCard?: LanguageModelRateCard;
37
+ readonly rateCard?: ModelRateCard;
38
38
  readonly costEstimator?: ModelCostEstimator;
39
39
  /** Default: preserve positive reports; trust zero only for OpenAI. "unknown" omits all reasoning counts. */
40
40
  readonly reasoningUsage?: "reported" | "unknown";
41
41
  }
42
- export interface AzureAIFoundryMessagesOptions extends MessagesRequestOptions {
42
+ export interface AzureAIFoundryMessagesOptions extends MessagesRequestOptions, LanguageModelLabel {
43
43
  readonly reasoning?: ModelReasoningLevel;
44
44
  readonly definition?: AzureAIFoundryModelOptions["definition"];
45
- readonly rateCard?: LanguageModelRateCard;
45
+ readonly rateCard?: ModelRateCard;
46
46
  readonly costEstimator?: ModelCostEstimator;
47
47
  }
48
- export interface AzureAIFoundryChatOptions extends ChatRequestOptions {
48
+ export interface AzureAIFoundryChatOptions extends ChatRequestOptions, LanguageModelLabel {
49
49
  readonly reasoning?: ModelReasoningLevel;
50
50
  readonly definition?: AzureAIFoundryModelOptions["definition"];
51
- readonly rateCard?: LanguageModelRateCard;
51
+ readonly rateCard?: ModelRateCard;
52
52
  readonly costEstimator?: ModelCostEstimator;
53
53
  readonly reasoningUsage?: "reported" | "unknown";
54
54
  }
@@ -1 +1 @@
1
- {"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../src/provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,aAAa,EAClB,KAAK,uBAAuB,EAC5B,KAAK,qBAAqB,EAC1B,KAAK,qBAAqB,EAM1B,KAAK,kBAAkB,EAEvB,KAAK,mBAAmB,EAEzB,MAAM,mBAAmB,CAAA;AAK1B,OAAO,EACL,KAAK,4BAA4B,EAGlC,MAAM,WAAW,CAAA;AAElB,OAAO,EAAE,KAAK,kBAAkB,EAA2C,MAAM,gBAAgB,CAAA;AACjG,OAAO,EACL,KAAK,qBAAqB,EAC1B,KAAK,wBAAwB,EAC7B,KAAK,8BAA8B,EAGpC,MAAM,aAAa,CAAA;AACpB,OAAO,EACL,KAAK,4BAA4B,EACjC,KAAK,8BAA8B,EACnC,KAAK,uCAAuC,EAE7C,MAAM,aAAa,CAAA;AAEpB,OAAO,EAEL,KAAK,sBAAsB,EAE5B,MAAM,oBAAoB,CAAA;AAC3B,OAAO,E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AuB,SAAQ,qBAAqB;IACnE,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,0BAA0B,GAAG,mBAAmB,CAAA;IACnF,SAAS,CACP,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,0BAA0B,GACnC,mBAAmB,CAAC,WAAW,CAAC,CAAA;IACnC,QAAQ,CACN,cAAc,EAAE,MAAM,EACtB,OAAO,CAAC,EAAE,6BAA6B,GACtC,mBAAmB,CAAC,UAAU,CAAC,CAAA;IAClC,SAAS,CACP,cAAc,EAAE,MAAM,EACtB,OAAO,EAAE,8BAA8B,GACtC,4BAA4B,CAAA;IAC/B,QAAQ,CAAC,OAAO,EAAE,qBAAqB,CAAA;IACvC,IAAI,CAAC,cAAc,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,yBAAyB,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAA;CAC/F;AAED,wBAAgB,oBAAoB,CAAC,OAAO,EAAE,qBAAqB,GAAG,sBAAsB,CA6F3F"}
@@ -30,7 +30,7 @@ export declare function resolveModel(input: {
30
30
  deployment?: AzureAIFoundryDeployment;
31
31
  discoveredAt?: string;
32
32
  }>;
33
- rateCard: import("@sixb/core/models").LanguageModelRateCard | undefined;
33
+ rateCard: import("@sixb/core/models").ModelRateCard | undefined;
34
34
  aliases: readonly string[];
35
35
  };
36
36
  //# sourceMappingURL=resolution.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"resolution.d.ts","sourceRoot":"","sources":["../src/resolution.ts"],"names":[],"mappings":"AAAA,OAAO,EAGL,KAAK,uBAAuB,EAE7B,MAAM,mBAAmB,CAAA;AAC1B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAC7C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,KAAK,EAAE,wBAAwB,EAAE,MAAM,aAAa,CAAA;AAC3D,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,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AY,CAAC,EAAE,YAAY,CAAA;CAC5B;;;;;;;;;;;;;;;;;;;EAmGA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sixb/azure-ai-foundry",
3
- "version": "0.1.4",
3
+ "version": "0.1.6",
4
4
  "description": "Azure AI Foundry model provider for Sixb",
5
5
  "homepage": "https://sixb.ai",
6
6
  "bugs": {
@@ -31,8 +31,8 @@
31
31
  "prepack": "bun run build"
32
32
  },
33
33
  "dependencies": {
34
- "@sixb/core": "^0.1.18",
35
- "@sixb/model-protocols": "0.1.1"
34
+ "@sixb/core": "^0.1.26",
35
+ "@sixb/model-protocols": "0.1.3"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/bun": "latest",
package/src/accounting.ts CHANGED
@@ -2,8 +2,8 @@ import {
2
2
  defineModelRateCard,
3
3
  estimateModelReservation,
4
4
  type JsonObject,
5
- type LanguageModelRateCard,
6
5
  type ModelCostEstimator,
6
+ type ModelRateCard,
7
7
  type ModelUsage,
8
8
  rateModelCall,
9
9
  } from "@sixb/core/models"
@@ -43,13 +43,16 @@ export function foundryUsage(
43
43
  }
44
44
  }
45
45
 
46
+ /** An estimator, with the card it prices by when it prices this configuration at all. */
47
+ export type PricedEstimator = ModelCostEstimator & { readonly rateCard?: ModelRateCard }
48
+
46
49
  export function foundryEstimator(
47
- card: LanguageModelRateCard | undefined,
50
+ card: ModelRateCard | undefined,
48
51
  request: JsonObject | undefined,
49
52
  modelName?: string,
50
53
  modelVersion?: string,
51
54
  aliases?: readonly string[]
52
- ): ModelCostEstimator {
55
+ ): PricedEstimator {
53
56
  return tokenEstimator(
54
57
  card,
55
58
  request,
@@ -62,17 +65,18 @@ export function foundryEstimator(
62
65
  }
63
66
 
64
67
  export function tokenEstimator(
65
- card: LanguageModelRateCard | undefined,
68
+ card: ModelRateCard | undefined,
66
69
  request: JsonObject | undefined,
67
70
  requestKeys: readonly string[],
68
71
  tokenMeters: (raw: JsonObject | undefined) => boolean,
69
72
  modelName?: string,
70
73
  modelVersion?: string,
71
74
  aliases?: readonly string[]
72
- ): ModelCostEstimator {
75
+ ): PricedEstimator {
73
76
  const rateCard = card && defineModelRateCard(card)
74
77
  const fixed = Object.keys(request ?? {}).every((key) => requestKeys.includes(key))
75
78
  return {
79
+ ...(fixed && rateCard ? { rateCard } : {}),
76
80
  estimateReservation: (tokens) =>
77
81
  fixed ? estimateModelReservation({ ...tokens, rateCard }) : undefined,
78
82
  estimate: ({ usage, responseModelId, route }) => {
package/src/catalog.ts CHANGED
@@ -1,17 +1,16 @@
1
1
  import {
2
2
  defineLanguageModel,
3
3
  defineModelRateCard,
4
- type LanguageModelRateCard,
5
4
  MODEL_REASONING_EFFORTS,
6
5
  ModelCatalogUnavailableError,
6
+ type ModelRateCard,
7
7
  type ModelReasoningCapabilities,
8
8
  } from "@sixb/core/models"
9
+ import { downloadModelsDev, modelsDevRateCard } from "@sixb/model-protocols/models-dev"
9
10
  import { fireworksPublisher } from "./publisher"
10
11
  import type { FoundryProtocol } from "./transport"
11
- import { abortable } from "./transport"
12
12
  import { object, PREFIX } from "./util"
13
13
 
14
- const url = "https://models.dev/api.json"
15
14
  export interface AzureAIFoundryCatalogOptions {
16
15
  readonly ttlMs?: number
17
16
  readonly timeoutMs?: number
@@ -23,14 +22,14 @@ export interface CatalogModel {
23
22
  readonly modelName: string
24
23
  readonly protocol?: FoundryProtocol
25
24
  readonly definition: ReturnType<typeof defineLanguageModel>
26
- readonly rateCard?: LanguageModelRateCard
25
+ readonly rateCard?: ModelRateCard
27
26
  }
28
27
 
29
28
  export interface CatalogEmbeddingModel {
30
29
  readonly kind: "embedding"
31
30
  readonly catalogProvider: "azure" | "fireworks-ai"
32
31
  readonly modelName: string
33
- readonly rateCard?: LanguageModelRateCard
32
+ readonly rateCard?: ModelRateCard
34
33
  }
35
34
 
36
35
  type CatalogEntry = CatalogModel | CatalogEmbeddingModel
@@ -112,30 +111,9 @@ export class RemoteModelsDevCatalog {
112
111
  return this.pending
113
112
  }
114
113
  private async fetchModels() {
115
- const signal = AbortSignal.timeout(this.options.timeoutMs ?? 10000)
116
114
  let text: string
117
115
  try {
118
- const response = await abortable(
119
- () => (this.options.fetch ?? fetch)(url, { signal, redirect: "error" }),
120
- signal
121
- )
122
- if (!response.ok || !response.body) throw new Error(`HTTP ${response.status}`)
123
- const reader = response.body.getReader()
124
- const chunks: Uint8Array[] = []
125
- let bytes = 0
126
- try {
127
- for (;;) {
128
- const chunk = await abortable(() => reader.read(), signal)
129
- if (chunk.done) break
130
- bytes += chunk.value.length
131
- if (bytes > 32 * 1024 * 1024) throw new Error("Catalog exceeds 32 MiB")
132
- chunks.push(chunk.value)
133
- }
134
- text = Buffer.concat(chunks).toString()
135
- } finally {
136
- void reader.cancel().catch(() => {})
137
- reader.releaseLock()
138
- }
116
+ text = await downloadModelsDev(this.options)
139
117
  } catch (cause) {
140
118
  throw new ModelCatalogUnavailableError(`${PREFIX} models.dev catalog unavailable.`, { cause })
141
119
  }
@@ -262,106 +240,11 @@ function reasoning(
262
240
  function rates(
263
241
  raw: Record<string, unknown> | undefined,
264
242
  protocol: FoundryProtocol | undefined
265
- ): LanguageModelRateCard | undefined {
266
- const card = parseRates(raw)
243
+ ): ModelRateCard | undefined {
244
+ const card = modelsDevRateCard(raw)
267
245
  if (protocol !== "messages" || card?.cacheWriteInput === undefined) return card
268
246
  // models.dev's Messages cache_write is five-minute creation, including in context tiers.
269
247
  // One-hour prices are unknown and must not fall back to this rate.
270
248
  const { cacheWriteInput, ...rest } = card
271
249
  return defineModelRateCard({ ...rest, cacheWriteInput5m: cacheWriteInput })
272
250
  }
273
-
274
- function parseRates(raw: Record<string, unknown> | undefined): LanguageModelRateCard | undefined {
275
- if (!raw || raw.tiers === undefined) return flatRates(raw)
276
- const { tiers, context_over_200k: legacy, ...base } = raw
277
- const card = flatRates(base)
278
- if (!card || !Array.isArray(tiers)) return undefined
279
- const parsed: { size: number; card: LanguageModelRateCard }[] = []
280
- for (const value of tiers) {
281
- const entry = object(value)
282
- if (!entry) return undefined
283
- const { tier, ...prices } = entry
284
- const threshold = object(tier)
285
- const size = threshold?.size
286
- const tierCard = flatRates(prices)
287
- if (
288
- !tierCard ||
289
- !threshold ||
290
- Object.keys(threshold).some((k) => k !== "type" && k !== "size") ||
291
- (threshold.type !== undefined && threshold.type !== "context") ||
292
- typeof size !== "number" ||
293
- !Number.isSafeInteger(size) ||
294
- size < 0 ||
295
- size >= Number.MAX_SAFE_INTEGER
296
- )
297
- return undefined
298
- parsed.push({ size, card: tierCard })
299
- }
300
- parsed.sort((a, b) => a.size - b.size)
301
- if (new Set(parsed.map((t) => t.size)).size !== parsed.length) return undefined
302
- const keys = ["input", "output", "cacheReadInput", "cacheWriteInput"] as const
303
- if (legacy !== undefined) {
304
- const mirror = flatRates(object(legacy))
305
- if (
306
- !mirror ||
307
- parsed.length !== 1 ||
308
- parsed[0]!.size < 200000 ||
309
- keys.some((k) => mirror[k] !== parsed[0]!.card[k])
310
- )
311
- return undefined
312
- }
313
- // Missing cache rates are unknown, not inherited or silently treated as zero.
314
- if (parsed.some((t) => keys.some((k) => (card[k] === undefined) !== (t.card[k] === undefined))))
315
- return undefined
316
- const price = (key: (typeof keys)[number]) => {
317
- const basePrice = card[key]
318
- if (basePrice === undefined || !parsed.length) return basePrice
319
- if (typeof basePrice !== "string") return undefined
320
- return {
321
- default: basePrice,
322
- tiers: parsed.map((t, i) => ({
323
- minTokens: t.size + 1,
324
- ...(parsed[i + 1] ? { maxTokens: parsed[i + 1]!.size + 1 } : {}),
325
- price: String(t.card[key]),
326
- })),
327
- }
328
- }
329
- return defineModelRateCard({
330
- currency: "USD",
331
- unit: "million-tokens",
332
- input: price("input")!,
333
- output: price("output")!,
334
- ...(card.cacheReadInput === undefined ? {} : { cacheReadInput: price("cacheReadInput")! }),
335
- ...(card.cacheWriteInput === undefined ? {} : { cacheWriteInput: price("cacheWriteInput")! }),
336
- })
337
- }
338
-
339
- function flatRates(raw: Record<string, unknown> | undefined): LanguageModelRateCard | undefined {
340
- if (!raw) return undefined
341
- // These are reference prices per million tokens. Unrepresented tiers/dimensions must not
342
- // silently become flat prices; callers can supply an estimator for those billing contracts.
343
- if (Object.keys(raw).some((k) => !["input", "output", "cache_read", "cache_write"].includes(k)))
344
- return undefined
345
- const decimal = (v: unknown) =>
346
- (typeof v === "number" || typeof v === "string") && /^\d+(\.\d+)?$/.test(String(v))
347
- ? String(v)
348
- : undefined
349
- const input = decimal(raw.input),
350
- output = decimal(raw.output)
351
- if (input === undefined || output === undefined) return undefined
352
- const read = decimal(raw.cache_read),
353
- write = decimal(raw.cache_write)
354
- if (
355
- (raw.cache_read !== undefined && read === undefined) ||
356
- (raw.cache_write !== undefined && write === undefined)
357
- )
358
- return undefined
359
- return defineModelRateCard({
360
- currency: "USD",
361
- unit: "million-tokens",
362
- input,
363
- output,
364
- ...(read === undefined ? {} : { cacheReadInput: read }),
365
- ...(write === undefined ? {} : { cacheWriteInput: write }),
366
- })
367
- }
@@ -1,10 +1,5 @@
1
- import type {
2
- JsonObject,
3
- LanguageModelRateCard,
4
- ModelCostEstimator,
5
- ModelUsage,
6
- } from "@sixb/core/models"
7
- import { tokenEstimator } from "./accounting"
1
+ import type { JsonObject, ModelCostEstimator, ModelRateCard, ModelUsage } from "@sixb/core/models"
2
+ import { type PricedEstimator, tokenEstimator } from "./accounting"
8
3
  import { counter, object } from "./util"
9
4
 
10
5
  // Interpret Chat counters directly. Cache reads overlap prompt_tokens; reasoning overlaps
@@ -43,12 +38,12 @@ export function foundryChatUsage(
43
38
  }
44
39
 
45
40
  export function foundryChatEstimator(
46
- card: LanguageModelRateCard | undefined,
41
+ card: ModelRateCard | undefined,
47
42
  request: JsonObject | undefined,
48
43
  modelName?: string,
49
44
  modelVersion?: string,
50
45
  aliases?: readonly string[]
51
- ): ModelCostEstimator {
46
+ ): PricedEstimator {
52
47
  const estimator = tokenEstimator(
53
48
  card,
54
49
  request,
@@ -59,6 +54,7 @@ export function foundryChatEstimator(
59
54
  aliases
60
55
  )
61
56
  return {
57
+ ...(estimator.rateCard ? { rateCard: estimator.rateCard } : {}),
62
58
  estimateReservation: estimator.estimateReservation,
63
59
  estimate: (input) =>
64
60
  estimator.estimate({
package/src/embedding.ts CHANGED
@@ -7,9 +7,9 @@ import {
7
7
  type EmbeddingModelResponseMetadata,
8
8
  type EmbeddingModelResult,
9
9
  type JsonObject,
10
- type LanguageModelRateCard,
11
10
  ModelCatalogUnavailableError,
12
11
  type ModelCostEstimator,
12
+ type ModelRateCard,
13
13
  type ModelUsage,
14
14
  UnsupportedModelFeatureError,
15
15
  } from "@sixb/core/models"
@@ -30,7 +30,7 @@ export interface AzureAIFoundryEmbeddingOptions {
30
30
  readonly model: { readonly name: string; readonly version: string }
31
31
  /** Expected output size; sent to text-embedding-3 models, validated locally for ada-002. */
32
32
  readonly dimensions: number
33
- readonly rateCard?: LanguageModelRateCard
33
+ readonly rateCard?: ModelRateCard
34
34
  readonly costEstimator?: ModelCostEstimator
35
35
  }
36
36
 
@@ -1,10 +1,5 @@
1
- import type {
2
- JsonObject,
3
- LanguageModelRateCard,
4
- ModelCostEstimator,
5
- ModelUsage,
6
- } from "@sixb/core/models"
7
- import { tokenEstimator } from "./accounting"
1
+ import type { JsonObject, ModelCostEstimator, ModelRateCard, ModelUsage } from "@sixb/core/models"
2
+ import { type PricedEstimator, tokenEstimator } from "./accounting"
8
3
  import { counter, object } from "./util"
9
4
 
10
5
  /** Native Messages counters are additive; absent cache/thinking counters stay unknown. */
@@ -40,12 +35,12 @@ export function foundryMessagesUsage(raw: JsonObject): ModelUsage {
40
35
  }
41
36
 
42
37
  export function foundryMessagesEstimator(
43
- card: LanguageModelRateCard | undefined,
38
+ card: ModelRateCard | undefined,
44
39
  request: JsonObject | undefined,
45
40
  modelName?: string,
46
41
  modelVersion?: string,
47
42
  aliases?: readonly string[]
48
- ): ModelCostEstimator {
43
+ ): PricedEstimator {
49
44
  const estimator = tokenEstimator(
50
45
  card,
51
46
  request,
package/src/provider.ts CHANGED
@@ -3,8 +3,8 @@ import {
3
3
  type JsonObject,
4
4
  type LanguageModel,
5
5
  type LanguageModelDefinition,
6
+ type LanguageModelLabel,
6
7
  type LanguageModelProvider,
7
- type LanguageModelRateCard,
8
8
  type LanguageModelRequest,
9
9
  type LanguageModelStream,
10
10
  type LanguageModelStreamEvent,
@@ -12,13 +12,14 @@ import {
12
12
  ModelCatalogUnavailableError,
13
13
  type ModelCostEstimator,
14
14
  ModelProviderError,
15
+ type ModelRateCard,
15
16
  type ModelReasoningLevel,
16
17
  UnsupportedModelFeatureError,
17
18
  } from "@sixb/core/models"
18
19
  import { chatEvents } from "@sixb/model-protocols/chat"
19
20
  import { messagesEvents } from "@sixb/model-protocols/messages"
20
21
  import { responsesEvents } from "@sixb/model-protocols/responses"
21
- import { foundryEstimator, foundryUsage } from "./accounting"
22
+ import { foundryEstimator, foundryUsage, type PricedEstimator } from "./accounting"
22
23
  import {
23
24
  type AzureAIFoundryCatalogOptions,
24
25
  type CatalogModel,
@@ -82,27 +83,27 @@ export interface AzureAIFoundryModelMetadata {
82
83
  readonly discoveredAt?: string
83
84
  }
84
85
 
85
- export interface AzureAIFoundryModelOptions extends RequestOptions {
86
+ export interface AzureAIFoundryModelOptions extends RequestOptions, LanguageModelLabel {
86
87
  /** Reasoning Sixb applies when this model runs without an explicit choice. */
87
88
  readonly reasoning?: ModelReasoningLevel
88
89
  readonly definition?: Omit<LanguageModelDefinition, "kind" | "providerId" | "modelId">
89
- readonly rateCard?: LanguageModelRateCard
90
+ readonly rateCard?: ModelRateCard
90
91
  readonly costEstimator?: ModelCostEstimator
91
92
  /** Default: preserve positive reports; trust zero only for OpenAI. "unknown" omits all reasoning counts. */
92
93
  readonly reasoningUsage?: "reported" | "unknown"
93
94
  }
94
95
 
95
- export interface AzureAIFoundryMessagesOptions extends MessagesRequestOptions {
96
+ export interface AzureAIFoundryMessagesOptions extends MessagesRequestOptions, LanguageModelLabel {
96
97
  readonly reasoning?: ModelReasoningLevel
97
98
  readonly definition?: AzureAIFoundryModelOptions["definition"]
98
- readonly rateCard?: LanguageModelRateCard
99
+ readonly rateCard?: ModelRateCard
99
100
  readonly costEstimator?: ModelCostEstimator
100
101
  }
101
102
 
102
- export interface AzureAIFoundryChatOptions extends ChatRequestOptions {
103
+ export interface AzureAIFoundryChatOptions extends ChatRequestOptions, LanguageModelLabel {
103
104
  readonly reasoning?: ModelReasoningLevel
104
105
  readonly definition?: AzureAIFoundryModelOptions["definition"]
105
- readonly rateCard?: LanguageModelRateCard
106
+ readonly rateCard?: ModelRateCard
106
107
  readonly costEstimator?: ModelCostEstimator
107
108
  readonly reasoningUsage?: "reported" | "unknown"
108
109
  }
@@ -230,7 +231,7 @@ export function createAzureAIFoundry(options: AzureAIFoundryOptions): AzureAIFou
230
231
 
231
232
  class FoundryModel<Protocol extends FoundryProtocol> implements AzureAIFoundryModel<Protocol> {
232
233
  private readonly profile: ReturnType<typeof resolveModel>
233
- private readonly estimator: ModelCostEstimator
234
+ private readonly estimator: PricedEstimator
234
235
  #execution?: FoundryModel<Protocol>
235
236
  #pendingExecution?: Promise<FoundryModel<Protocol>>
236
237
  get protocol(): Protocol {
@@ -245,10 +246,15 @@ class FoundryModel<Protocol extends FoundryProtocol> implements AzureAIFoundryMo
245
246
  get costEstimator() {
246
247
  return this.#execution?.estimator ?? this.estimator
247
248
  }
249
+ /** The card the estimator prices by; none with a custom costEstimator or unpriced options. */
250
+ get rateCard() {
251
+ return (this.#execution?.estimator ?? this.estimator).rateCard
252
+ }
248
253
  private readonly options: AzureAIFoundryModelOptions & MessagesRequestOptions & ChatRequestOptions
249
254
  private readonly scope: string
250
255
  private readonly reliableReasoning: boolean | undefined
251
256
  readonly defaultReasoning?: ModelReasoningLevel
257
+ readonly maxOutputTokens?: number
252
258
 
253
259
  constructor(
254
260
  private readonly requestedProtocol: Protocol | undefined,
@@ -287,6 +293,7 @@ class FoundryModel<Protocol extends FoundryProtocol> implements AzureAIFoundryMo
287
293
  if (protocol === "messages") validateMessagesOptions(options)
288
294
  else if (protocol === "chat") validateChatOptions(options)
289
295
  else validateOptions(options)
296
+ if (options.maxOutputTokens !== undefined) this.maxOutputTokens = options.maxOutputTokens
290
297
  const { costEstimator, ...serializable } = options
291
298
  this.options = {
292
299
  ...structuredClone(serializable),
package/src/resolution.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  import {
2
2
  defineLanguageModel,
3
+ defineLanguageModelLabel,
3
4
  defineModelRateCard,
4
5
  type LanguageModelDefinition,
5
6
  UnsupportedModelFeatureError,
@@ -67,6 +68,7 @@ export function resolveModel(input: {
67
68
  publisher,
68
69
  via: "Azure AI Foundry",
69
70
  ...options.definition,
71
+ ...defineLanguageModelLabel(options, PREFIX),
70
72
  kind: "language",
71
73
  providerId: input.providerId,
72
74
  modelId: input.modelId,
@@ -85,6 +87,8 @@ export function resolveModel(input: {
85
87
  kind: "language",
86
88
  providerId: input.providerId,
87
89
  modelId: input.modelId,
90
+ name: definition.name,
91
+ description: definition.description,
88
92
  publisher: definition.publisher,
89
93
  via: definition.via,
90
94
  capabilities: {},