@modelrelay/sdk 2.1.0 → 4.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.
Files changed (42) hide show
  1. package/dist/api-Bitsm1tl.d.cts +5290 -0
  2. package/dist/api-Bitsm1tl.d.ts +5290 -0
  3. package/dist/{api-Ct5bpI3U.d.cts → api-CzFaWgs_.d.cts} +2636 -2113
  4. package/dist/{api-Ct5bpI3U.d.ts → api-CzFaWgs_.d.ts} +2636 -2113
  5. package/dist/{api-Bb7sw9L4.d.cts → api-D0wnVpwn.d.cts} +2598 -2148
  6. package/dist/{api-Bb7sw9L4.d.ts → api-D0wnVpwn.d.ts} +2598 -2148
  7. package/dist/billing/index.d.cts +1 -1
  8. package/dist/billing/index.d.ts +1 -1
  9. package/dist/{chunk-AZD5EKLV.js → chunk-5O4NJXLJ.js} +1 -1
  10. package/dist/{chunk-4FXUTSRZ.js → chunk-ADQ74R7T.js} +1 -1
  11. package/dist/{chunk-CXJZB6MA.js → chunk-CV3DTA6P.js} +1 -1
  12. package/dist/{chunk-VOFLESGQ.js → chunk-EMQKOEF3.js} +10 -8
  13. package/dist/{chunk-R6O6UQYM.js → chunk-JZRSCFQH.js} +1 -1
  14. package/dist/{chunk-MXXJDLGU.js → chunk-LW6SC7NQ.js} +2 -63
  15. package/dist/index.cjs +58 -51
  16. package/dist/index.d.cts +27 -21
  17. package/dist/index.d.ts +27 -21
  18. package/dist/index.js +58 -51
  19. package/dist/node.cjs +1 -1
  20. package/dist/node.js +1 -1
  21. package/dist/{tools-B7444ZtV.d.cts → tools-DAqAFZ8F.d.cts} +11 -13
  22. package/dist/{tools-B7444ZtV.d.ts → tools-DAqAFZ8F.d.ts} +11 -13
  23. package/package.json +1 -1
  24. package/dist/api-DWUVls-S.d.cts +0 -4762
  25. package/dist/api-DWUVls-S.d.ts +0 -4762
  26. package/dist/api-DZpC1zuz.d.cts +0 -4691
  27. package/dist/api-DZpC1zuz.d.ts +0 -4691
  28. package/dist/api-D_hE36Ps.d.cts +0 -4535
  29. package/dist/api-D_hE36Ps.d.ts +0 -4535
  30. package/dist/api-Dz9HcUTt.d.cts +0 -4522
  31. package/dist/api-Dz9HcUTt.d.ts +0 -4522
  32. package/dist/chunk-BP5HUQ4M.js +0 -1194
  33. package/dist/chunk-CYGWZYYJ.js +0 -1194
  34. package/dist/chunk-PLZWDUOP.js +0 -1194
  35. package/dist/chunk-SCOP57J4.js +0 -1194
  36. package/dist/chunk-SXNP5Y5L.js +0 -1194
  37. package/dist/tools-CWEBFsql.d.cts +0 -1192
  38. package/dist/tools-CWEBFsql.d.ts +0 -1192
  39. package/dist/tools-CvfwPjC5.d.cts +0 -1098
  40. package/dist/tools-CvfwPjC5.d.ts +0 -1098
  41. package/dist/tools-DUYHZdZP.d.cts +0 -982
  42. package/dist/tools-DUYHZdZP.d.ts +0 -982
@@ -1,1192 +0,0 @@
1
- declare const SDK_VERSION: string;
2
- declare const DEFAULT_BASE_URL = "https://api.modelrelay.ai/api/v1";
3
- declare const DEFAULT_CLIENT_HEADER: string;
4
- declare const DEFAULT_CONNECT_TIMEOUT_MS = 5000;
5
- declare const DEFAULT_REQUEST_TIMEOUT_MS = 60000;
6
- type NonEmptyArray<T> = [T, ...T[]];
7
- declare const StopReasons: {
8
- readonly Completed: "completed";
9
- readonly Stop: "stop";
10
- readonly StopSequence: "stop_sequence";
11
- readonly EndTurn: "end_turn";
12
- readonly MaxTokens: "max_tokens";
13
- readonly MaxLength: "max_len";
14
- readonly MaxContext: "max_context";
15
- readonly ToolCalls: "tool_calls";
16
- readonly TimeLimit: "time_limit";
17
- readonly ContentFilter: "content_filter";
18
- readonly Incomplete: "incomplete";
19
- readonly Unknown: "unknown";
20
- };
21
- type KnownStopReason = (typeof StopReasons)[keyof typeof StopReasons];
22
- type StopReason = KnownStopReason | {
23
- other: string;
24
- };
25
- /**
26
- * Branded type for provider identifiers (e.g., "anthropic", "openai").
27
- * The brand prevents accidental use of arbitrary strings where a provider ID is expected.
28
- */
29
- type ProviderId = string & {
30
- readonly __brand: "ProviderId";
31
- };
32
- /**
33
- * Branded type for model identifiers (e.g., "claude-3-5-sonnet-20241022").
34
- * The brand prevents accidental use of arbitrary strings where a model ID is expected.
35
- */
36
- type ModelId = string & {
37
- readonly __brand: "ModelId";
38
- };
39
- /**
40
- * Branded type for tier codes (e.g., "free", "pro", "enterprise").
41
- * The brand prevents accidental use of arbitrary strings where a tier code is expected.
42
- */
43
- type TierCode = string & {
44
- readonly __brand: "TierCode";
45
- };
46
- /**
47
- * Cast a string to a ProviderId. Use for known provider identifiers.
48
- */
49
- declare function asProviderId(value: string): ProviderId;
50
- /**
51
- * Cast a string to a ModelId. Use for known model identifiers.
52
- */
53
- declare function asModelId(value: string): ModelId;
54
- /**
55
- * Cast a string to a TierCode. Use for known tier codes.
56
- */
57
- declare function asTierCode(value: string): TierCode;
58
- declare const SubscriptionStatuses: {
59
- readonly Active: "active";
60
- readonly Trialing: "trialing";
61
- readonly PastDue: "past_due";
62
- readonly Canceled: "canceled";
63
- readonly Unpaid: "unpaid";
64
- readonly Incomplete: "incomplete";
65
- readonly IncompleteExpired: "incomplete_expired";
66
- readonly Paused: "paused";
67
- };
68
- type SubscriptionStatusKind = (typeof SubscriptionStatuses)[keyof typeof SubscriptionStatuses];
69
- declare const BillingProviders: {
70
- readonly Stripe: "stripe";
71
- readonly Crypto: "crypto";
72
- readonly AppStore: "app_store";
73
- readonly External: "external";
74
- };
75
- type BillingProvider = (typeof BillingProviders)[keyof typeof BillingProviders];
76
- /** Arbitrary customer metadata. Values can be any JSON type. */
77
- type CustomerMetadata = Record<string, unknown>;
78
- type PublishableKey = string & {
79
- readonly __brand: "PublishableKey";
80
- };
81
- type SecretKey = string & {
82
- readonly __brand: "SecretKey";
83
- };
84
- type ApiKey = PublishableKey | SecretKey;
85
- /**
86
- * TokenProvider supplies short-lived bearer tokens for ModelRelay data-plane calls.
87
- *
88
- * Providers are responsible for caching and refreshing tokens when needed.
89
- */
90
- interface TokenProvider {
91
- getToken(): Promise<string>;
92
- }
93
- /**
94
- * Common configuration options for the ModelRelay client.
95
- */
96
- interface ModelRelayBaseOptions {
97
- /**
98
- * Optional base URL override. Defaults to production API.
99
- */
100
- baseUrl?: string;
101
- fetch?: typeof fetch;
102
- /**
103
- * Default customer metadata used when exchanging publishable keys for frontend tokens.
104
- */
105
- customer?: FrontendCustomer;
106
- /**
107
- * Optional client header override for telemetry.
108
- */
109
- clientHeader?: string;
110
- /**
111
- * Default connect timeout in milliseconds (applies to each attempt).
112
- */
113
- connectTimeoutMs?: number;
114
- /**
115
- * Default request timeout in milliseconds (non-streaming). Set to 0 to disable.
116
- */
117
- timeoutMs?: number;
118
- /**
119
- * Retry configuration applied to all requests (can be overridden per call). Set to `false` to disable retries.
120
- */
121
- retry?: RetryConfig | false;
122
- /**
123
- * Default HTTP headers applied to every request.
124
- */
125
- defaultHeaders?: Record<string, string>;
126
- /**
127
- * Optional metrics callbacks for latency/usage.
128
- */
129
- metrics?: MetricsCallbacks;
130
- /**
131
- * Optional trace/log hooks for request + stream lifecycle.
132
- */
133
- trace?: TraceCallbacks;
134
- }
135
- /**
136
- * Configuration options requiring an API key.
137
- */
138
- interface ModelRelayKeyOptions extends ModelRelayBaseOptions {
139
- /**
140
- * API key (secret or publishable). Required.
141
- * - Secret keys (`mr_sk_...`) are for server-side API calls.
142
- * - Publishable keys (`mr_pk_...`) are for frontend token exchange.
143
- */
144
- key: ApiKey;
145
- /**
146
- * Optional bearer token (takes precedence over key for requests when provided).
147
- */
148
- token?: string;
149
- }
150
- /**
151
- * Configuration options requiring an access token.
152
- */
153
- interface ModelRelayTokenOptions extends ModelRelayBaseOptions {
154
- /**
155
- * Optional API key.
156
- */
157
- key?: ApiKey;
158
- /**
159
- * Bearer token to call the API directly (server or frontend token). Required.
160
- */
161
- token: string;
162
- }
163
- /**
164
- * Configuration options requiring a TokenProvider.
165
- */
166
- interface ModelRelayTokenProviderOptions extends ModelRelayBaseOptions {
167
- /**
168
- * Token provider used to fetch bearer tokens for `/responses`, `/runs`, and `/workflows/compile`.
169
- */
170
- tokenProvider: TokenProvider;
171
- /**
172
- * Optional API key. Useful for non-data-plane endpoints (e.g., /customers, /tiers).
173
- */
174
- key?: ApiKey;
175
- }
176
- /**
177
- * ModelRelay client configuration.
178
- *
179
- * You must provide at least one of `key` or `token` for authentication.
180
- * This is enforced at compile time through discriminated union types.
181
- *
182
- * @example With API key (server-side)
183
- * ```typescript
184
- * import { ModelRelay } from "@modelrelay/sdk";
185
- * const client = ModelRelay.fromSecretKey("mr_sk_...");
186
- * ```
187
- *
188
- * @example With access token (frontend or after token exchange)
189
- * ```typescript
190
- * const client = new ModelRelay({ token: frontendToken });
191
- * ```
192
- *
193
- * @example With publishable key (frontend token exchange)
194
- * ```typescript
195
- * import { ModelRelay, parsePublishableKey } from "@modelrelay/sdk";
196
- * const client = new ModelRelay({ key: parsePublishableKey("mr_pk_..."), customer: { provider: "oidc", subject: "user123" } });
197
- * ```
198
- *
199
- * @example With token provider (OIDC exchange, backend-minted tokens, etc.)
200
- * ```typescript
201
- * import { ModelRelay } from "@modelrelay/sdk";
202
- * const client = new ModelRelay({ tokenProvider });
203
- * ```
204
- */
205
- type ModelRelayOptions = ModelRelayKeyOptions | ModelRelayTokenOptions | ModelRelayTokenProviderOptions;
206
- /**
207
- * @deprecated Use ModelRelayOptions instead. This type allows empty configuration
208
- * which will fail at runtime.
209
- */
210
- interface FrontendCustomer {
211
- provider: string;
212
- subject: string;
213
- /**
214
- * Email address for auto-provisioning (if enabled for the project).
215
- * If omitted and the identity isn't linked yet, the API may return EMAIL_REQUIRED.
216
- */
217
- email?: string;
218
- deviceId?: string;
219
- ttlSeconds?: number;
220
- }
221
- /**
222
- * Request for fetching a frontend token for an existing identity.
223
- */
224
- interface FrontendTokenRequest {
225
- /** Publishable key (mr_pk_*) - required for authentication. */
226
- publishableKey: PublishableKey;
227
- /** Identity provider namespace (e.g. "oidc", "github", "oidc:https://issuer"). */
228
- identityProvider: string;
229
- /** Provider-scoped subject identifier (e.g. OIDC sub). */
230
- identitySubject: string;
231
- /** Optional device identifier for tracking/rate limiting. */
232
- deviceId?: string;
233
- /** Optional TTL in seconds for the issued token. */
234
- ttlSeconds?: number;
235
- }
236
- /**
237
- * Request for fetching a frontend token with auto-provisioning enabled.
238
- * The project must explicitly enable auto-provisioning; email is required for customer creation.
239
- */
240
- interface FrontendTokenAutoProvisionRequest {
241
- /** Publishable key (mr_pk_*) - required for authentication. */
242
- publishableKey: PublishableKey;
243
- /** Identity provider namespace (e.g. "oidc", "github", "oidc:https://issuer"). */
244
- identityProvider: string;
245
- /** Provider-scoped subject identifier (e.g. OIDC sub). */
246
- identitySubject: string;
247
- /** Email address - required for auto-provisioning a new customer. */
248
- email: string;
249
- /** Optional device identifier for tracking/rate limiting. */
250
- deviceId?: string;
251
- /** Optional TTL in seconds for the issued token. */
252
- ttlSeconds?: number;
253
- }
254
- /** Token type for OAuth2 bearer tokens. */
255
- type TokenType = "Bearer";
256
- interface FrontendToken {
257
- /** The bearer token for authenticating LLM requests. */
258
- token: string;
259
- /** When the token expires. */
260
- expiresAt: Date;
261
- /** Seconds until the token expires. */
262
- expiresIn: number;
263
- /** Token type, always "Bearer". */
264
- tokenType: TokenType;
265
- /** The publishable key ID that issued this token. */
266
- keyId: string;
267
- /** Unique session identifier for this token. */
268
- sessionId: string;
269
- /** The project ID this token is scoped to. */
270
- projectId: string;
271
- /** The internal customer ID (UUID). Only present for managed billing projects; BYOB projects have end-users but not customers. */
272
- customerId?: string;
273
- /** The external customer ID provided by the application. */
274
- customerExternalId: string;
275
- /** The tier code for the customer (e.g., "free", "pro", "enterprise").
276
- * Optional for BYOB (external billing) projects where customers may not have subscriptions.
277
- */
278
- tierCode?: TierCode;
279
- /**
280
- * Publishable key used for issuance. Added client-side for caching.
281
- */
282
- publishableKey?: PublishableKey;
283
- /**
284
- * Device identifier used when issuing the token. Added client-side for caching.
285
- */
286
- deviceId?: string;
287
- /**
288
- * Identity provider used for issuance. Added client-side for caching.
289
- */
290
- identityProvider?: string;
291
- /**
292
- * Identity subject used for issuance. Added client-side for caching.
293
- */
294
- identitySubject?: string;
295
- }
296
- interface CustomerTokenRequest {
297
- customerId?: string;
298
- customerExternalId?: string;
299
- ttlSeconds?: number;
300
- }
301
- interface CustomerToken {
302
- token: string;
303
- expiresAt: Date;
304
- expiresIn: number;
305
- tokenType: TokenType;
306
- projectId: string;
307
- /** Only present for managed billing projects; BYOB projects have end-users but not customers. */
308
- customerId?: string;
309
- customerExternalId: string;
310
- /** Optional for BYOB (external billing) projects */
311
- tierCode?: TierCode;
312
- }
313
- interface OIDCExchangeRequest {
314
- idToken: string;
315
- projectId?: string;
316
- }
317
- /**
318
- * Request options for starting a device authorization flow.
319
- */
320
- interface DeviceStartRequest {
321
- /**
322
- * Optional provider for native device flow.
323
- * - "github": Use GitHub's native device flow (user authenticates at github.com/login/device)
324
- * - undefined: Use ModelRelay's wrapped OAuth flow (default)
325
- */
326
- provider?: "github";
327
- }
328
- /**
329
- * Response from starting a device authorization flow.
330
- */
331
- interface DeviceStartResponse {
332
- /** Device code used for polling /auth/device/token */
333
- deviceCode: string;
334
- /** Human-enterable code shown to the user */
335
- userCode: string;
336
- /** URL where the user enters the code and completes authorization */
337
- verificationUri: string;
338
- /** Convenience URL that pre-fills the user_code (optional) */
339
- verificationUriComplete?: string;
340
- /** When the device code expires */
341
- expiresAt: Date;
342
- /** Minimum polling interval in seconds */
343
- interval: number;
344
- }
345
- /**
346
- * Successful response from polling device token endpoint.
347
- */
348
- interface DeviceTokenResponse {
349
- /** Bearer token for authenticating requests */
350
- token: string;
351
- /** When the token expires */
352
- expiresAt: Date;
353
- /** Seconds until the token expires */
354
- expiresIn: number;
355
- /** Token type, always "Bearer" */
356
- tokenType: TokenType;
357
- /** The project ID this token is scoped to */
358
- projectId: string;
359
- /** The internal customer ID (UUID). Only present for managed billing projects; BYOB projects have end-users but not customers. */
360
- customerId?: string;
361
- /** The external customer ID */
362
- customerExternalId: string;
363
- /** The tier code for the customer (optional for BYOB projects) */
364
- tierCode?: TierCode;
365
- }
366
- /**
367
- * Pending response from polling device token endpoint.
368
- * Indicates the user hasn't completed authorization yet.
369
- */
370
- interface DeviceTokenPending {
371
- /** Error code from the device flow */
372
- error: "authorization_pending" | "slow_down";
373
- /** Human-readable error description */
374
- errorDescription?: string;
375
- /** Updated polling interval (when error is slow_down) */
376
- interval?: number;
377
- }
378
- /**
379
- * Result from polling the device token endpoint.
380
- * Either a successful token or a pending/error state.
381
- */
382
- type DeviceTokenResult = {
383
- status: "approved";
384
- token: DeviceTokenResponse;
385
- } | {
386
- status: "pending";
387
- pending: DeviceTokenPending;
388
- } | {
389
- status: "error";
390
- error: string;
391
- errorDescription?: string;
392
- };
393
- /**
394
- * Request to start an OAuth flow for customer authentication.
395
- */
396
- interface OAuthStartRequest {
397
- /** Project ID to authenticate against */
398
- projectId: string;
399
- /** OAuth provider: "github" or "google" */
400
- provider: "github" | "google";
401
- /** Where to redirect after OAuth completion. Must be in project's whitelist. */
402
- redirectUri: string;
403
- }
404
- /**
405
- * Response from starting an OAuth flow.
406
- */
407
- interface OAuthStartResponse {
408
- /** URL to redirect the user to for OAuth authentication */
409
- redirectUrl: string;
410
- }
411
- interface Usage {
412
- inputTokens: number;
413
- outputTokens: number;
414
- totalTokens: number;
415
- }
416
- /**
417
- * Creates a Usage object with automatic totalTokens calculation if not provided.
418
- */
419
- declare function createUsage(inputTokens: number, outputTokens: number, totalTokens?: number): Usage;
420
- interface UsageSummary {
421
- plan: string;
422
- planType?: string;
423
- windowStart?: Date | string;
424
- windowEnd?: Date | string;
425
- limit?: number;
426
- used?: number;
427
- images?: number;
428
- actionsLimit?: number;
429
- actionsUsed?: number;
430
- remaining?: number;
431
- state?: string;
432
- }
433
- interface Project {
434
- id: string;
435
- name: string;
436
- description?: string;
437
- createdAt?: Date;
438
- updatedAt?: Date;
439
- }
440
- /**
441
- * Valid roles for chat messages.
442
- */
443
- declare const MessageRoles: {
444
- readonly User: "user";
445
- readonly Assistant: "assistant";
446
- readonly System: "system";
447
- readonly Tool: "tool";
448
- };
449
- type MessageRole = (typeof MessageRoles)[keyof typeof MessageRoles];
450
- declare const ContentPartTypes: {
451
- readonly Text: "text";
452
- };
453
- type ContentPartType = (typeof ContentPartTypes)[keyof typeof ContentPartTypes];
454
- type ContentPart = {
455
- type: "text";
456
- text: string;
457
- };
458
- declare const InputItemTypes: {
459
- readonly Message: "message";
460
- };
461
- type InputItemType = (typeof InputItemTypes)[keyof typeof InputItemTypes];
462
- type InputItem = {
463
- type: "message";
464
- role: MessageRole;
465
- content: ContentPart[];
466
- toolCalls?: ToolCall[];
467
- toolCallId?: string;
468
- };
469
- declare const OutputItemTypes: {
470
- readonly Message: "message";
471
- };
472
- type OutputItemType = (typeof OutputItemTypes)[keyof typeof OutputItemTypes];
473
- type OutputItem = {
474
- type: "message";
475
- role: MessageRole;
476
- content: ContentPart[];
477
- toolCalls?: ToolCall[];
478
- };
479
- declare const ToolTypes: {
480
- readonly Function: "function";
481
- readonly Web: "web";
482
- readonly XSearch: "x_search";
483
- readonly CodeExecution: "code_execution";
484
- };
485
- type ToolType = (typeof ToolTypes)[keyof typeof ToolTypes];
486
- declare const WebToolIntents: {
487
- readonly Auto: "auto";
488
- readonly SearchWeb: "search_web";
489
- readonly FetchURL: "fetch_url";
490
- };
491
- type WebToolIntent = (typeof WebToolIntents)[keyof typeof WebToolIntents];
492
- interface FunctionTool {
493
- name: string;
494
- description?: string;
495
- parameters?: Record<string, unknown>;
496
- }
497
- interface WebSearchConfig {
498
- allowedDomains?: string[];
499
- excludedDomains?: string[];
500
- maxUses?: number;
501
- intent?: WebToolIntent;
502
- }
503
- interface XSearchConfig {
504
- allowedHandles?: string[];
505
- excludedHandles?: string[];
506
- fromDate?: string;
507
- toDate?: string;
508
- }
509
- interface CodeExecConfig {
510
- language?: string;
511
- timeoutMs?: number;
512
- }
513
- interface Tool {
514
- type: ToolType;
515
- function?: FunctionTool;
516
- web?: WebSearchConfig;
517
- xSearch?: XSearchConfig;
518
- codeExecution?: CodeExecConfig;
519
- }
520
- declare const ToolChoiceTypes: {
521
- readonly Auto: "auto";
522
- readonly Required: "required";
523
- readonly None: "none";
524
- };
525
- type ToolChoiceType = (typeof ToolChoiceTypes)[keyof typeof ToolChoiceTypes];
526
- interface ToolChoice {
527
- type: ToolChoiceType;
528
- /**
529
- * Optional function tool name to force.
530
- * Only valid when type is "required".
531
- */
532
- function?: string;
533
- }
534
- interface FunctionCall {
535
- name: string;
536
- arguments: string;
537
- }
538
- interface ToolCall {
539
- id: string;
540
- type: ToolType;
541
- function?: FunctionCall;
542
- }
543
- declare const OutputFormatTypes: {
544
- readonly Text: "text";
545
- readonly JsonSchema: "json_schema";
546
- };
547
- type OutputFormatType = (typeof OutputFormatTypes)[keyof typeof OutputFormatTypes];
548
- interface JSONSchemaFormat {
549
- name: string;
550
- description?: string;
551
- schema: Record<string, unknown>;
552
- strict?: boolean;
553
- }
554
- interface OutputFormat {
555
- type: OutputFormatType;
556
- json_schema?: JSONSchemaFormat;
557
- }
558
- interface Citation {
559
- url?: string;
560
- title?: string;
561
- }
562
- interface Response {
563
- id: string;
564
- output: OutputItem[];
565
- stopReason?: StopReason;
566
- model: ModelId;
567
- usage: Usage;
568
- requestId?: string;
569
- provider?: ProviderId;
570
- citations?: Citation[];
571
- }
572
- interface FieldError {
573
- field?: string;
574
- message: string;
575
- }
576
- interface RetryConfig {
577
- maxAttempts?: number;
578
- baseBackoffMs?: number;
579
- maxBackoffMs?: number;
580
- retryPost?: boolean;
581
- }
582
- interface RetryMetadata {
583
- attempts: number;
584
- lastStatus?: number;
585
- lastError?: string;
586
- }
587
- type TransportErrorKind = "timeout" | "connect" | "request" | "empty_response" | "other";
588
- interface RequestContext {
589
- method: string;
590
- path: string;
591
- model?: ModelId;
592
- requestId?: string;
593
- responseId?: string;
594
- }
595
- interface HttpRequestMetrics {
596
- latencyMs: number;
597
- status?: number;
598
- error?: string;
599
- retries?: RetryMetadata;
600
- context: RequestContext;
601
- }
602
- interface StreamFirstTokenMetrics {
603
- latencyMs: number;
604
- error?: string;
605
- context: RequestContext;
606
- }
607
- interface TokenUsageMetrics {
608
- usage: Usage;
609
- context: RequestContext;
610
- }
611
- interface MetricsCallbacks {
612
- httpRequest?: (metrics: HttpRequestMetrics) => void;
613
- streamFirstToken?: (metrics: StreamFirstTokenMetrics) => void;
614
- usage?: (metrics: TokenUsageMetrics) => void;
615
- }
616
- interface TraceCallbacks {
617
- requestStart?: (context: RequestContext) => void;
618
- requestFinish?: (info: {
619
- context: RequestContext;
620
- status?: number;
621
- error?: unknown;
622
- retries?: RetryMetadata;
623
- latencyMs: number;
624
- }) => void;
625
- streamEvent?: (info: {
626
- context: RequestContext;
627
- event: ResponseEvent;
628
- }) => void;
629
- streamError?: (info: {
630
- context: RequestContext;
631
- error: unknown;
632
- }) => void;
633
- }
634
- declare function mergeMetrics(base?: MetricsCallbacks, override?: MetricsCallbacks): MetricsCallbacks | undefined;
635
- declare function mergeTrace(base?: TraceCallbacks, override?: TraceCallbacks): TraceCallbacks | undefined;
636
- declare function normalizeStopReason(value?: unknown): StopReason | undefined;
637
- declare function stopReasonToString(value?: StopReason): string | undefined;
638
- declare function normalizeModelId(value: unknown): ModelId | undefined;
639
- declare function modelToString(value: ModelId): string;
640
- type ResponseEventType = "message_start" | "message_delta" | "message_stop" | "tool_use_start" | "tool_use_delta" | "tool_use_stop" | "ping" | "custom";
641
- interface MessageStartData {
642
- responseId?: string;
643
- model?: string;
644
- message?: Record<string, unknown>;
645
- [key: string]: unknown;
646
- }
647
- interface MessageDeltaData {
648
- delta?: string | {
649
- text?: string;
650
- [key: string]: unknown;
651
- };
652
- responseId?: string;
653
- model?: string;
654
- [key: string]: unknown;
655
- }
656
- interface MessageStopData {
657
- stopReason?: StopReason;
658
- usage?: Usage;
659
- responseId?: string;
660
- model?: ModelId;
661
- [key: string]: unknown;
662
- }
663
- /** Incremental update to a tool call during streaming. */
664
- interface ToolCallDelta {
665
- index: number;
666
- id?: string;
667
- type?: string;
668
- function?: FunctionCallDelta;
669
- }
670
- /** Incremental function call data. */
671
- interface FunctionCallDelta {
672
- name?: string;
673
- arguments?: string;
674
- }
675
- interface ResponseEvent<T = unknown> {
676
- type: ResponseEventType;
677
- event: string;
678
- data?: T;
679
- textDelta?: string;
680
- /** Incremental tool call update during streaming. */
681
- toolCallDelta?: ToolCallDelta;
682
- /** Completed tool calls when type is tool_use_stop or message_stop. */
683
- toolCalls?: ToolCall[];
684
- /** Tool result payload when type is tool_use_stop. */
685
- toolResult?: unknown;
686
- responseId?: string;
687
- model?: ModelId;
688
- stopReason?: StopReason;
689
- usage?: Usage;
690
- requestId?: string;
691
- raw: string;
692
- }
693
- type StructuredJSONRecordType = "start" | "update" | "completion" | "error";
694
- /**
695
- * Recursively makes all properties optional.
696
- * Useful for typing partial payloads during progressive streaming before
697
- * all fields are complete.
698
- *
699
- * @example
700
- * interface Article { title: string; body: string; }
701
- * type PartialArticle = DeepPartial<Article>;
702
- * // { title?: string; body?: string; }
703
- */
704
- type DeepPartial<T> = T extends object ? {
705
- [P in keyof T]?: DeepPartial<T[P]>;
706
- } : T;
707
- interface StructuredJSONEvent<T> {
708
- type: "update" | "completion";
709
- payload: T;
710
- requestId?: string;
711
- /**
712
- * Set of field paths that are complete (have their closing delimiter).
713
- * Use dot notation for nested fields (e.g., "metadata.author").
714
- * Check with completeFields.has("fieldName").
715
- */
716
- completeFields: Set<string>;
717
- }
718
- interface APIFrontendToken {
719
- token: string;
720
- expires_at: string;
721
- expires_in: number;
722
- token_type: TokenType;
723
- key_id: string;
724
- session_id: string;
725
- project_id: string;
726
- /** Optional for BYOB projects where customers are not created in the billing sense. */
727
- customer_id?: string;
728
- customer_external_id: string;
729
- tier_code?: TierCode;
730
- }
731
- interface APICustomerRef {
732
- id: string;
733
- external_id: string;
734
- owner_id: string;
735
- }
736
- interface APICheckoutSession {
737
- id: string;
738
- plan: string;
739
- status: string;
740
- url: string;
741
- expires_at?: string;
742
- completed_at?: string;
743
- }
744
- interface APIUsage {
745
- input_tokens?: number;
746
- output_tokens?: number;
747
- total_tokens?: number;
748
- }
749
- interface APIResponsesResponse {
750
- id?: string;
751
- stop_reason?: string;
752
- model?: string;
753
- usage?: APIUsage;
754
- provider?: string;
755
- output?: OutputItem[];
756
- citations?: Citation[];
757
- }
758
- interface APIKey {
759
- id: string;
760
- label: string;
761
- kind: string;
762
- createdAt: Date;
763
- expiresAt?: Date;
764
- lastUsedAt?: Date;
765
- redactedKey: string;
766
- secretKey?: string;
767
- }
768
-
769
- /**
770
- * Creates a user message.
771
- */
772
- declare function createUserMessage(content: string): InputItem;
773
- /**
774
- * Creates an assistant message.
775
- */
776
- declare function createAssistantMessage(content: string): InputItem;
777
- /**
778
- * Creates a system message.
779
- */
780
- declare function createSystemMessage(content: string): InputItem;
781
- /**
782
- * Creates a tool call object.
783
- */
784
- declare function createToolCall(id: string, name: string, args: string, type?: ToolType): ToolCall;
785
- /**
786
- * Creates a function call object.
787
- */
788
- declare function createFunctionCall(name: string, args: string): FunctionCall;
789
- /**
790
- * Interface for Zod-like schema types.
791
- * Compatible with Zod's ZodType and similar libraries.
792
- */
793
- interface ZodLikeSchema {
794
- _def: {
795
- typeName: string;
796
- [key: string]: unknown;
797
- };
798
- parse(data: unknown): unknown;
799
- safeParse(data: unknown): {
800
- success: boolean;
801
- data?: unknown;
802
- error?: unknown;
803
- };
804
- }
805
- /**
806
- * Options for JSON Schema generation.
807
- */
808
- interface JsonSchemaOptions {
809
- /** Whether to include $schema property. Defaults to false. */
810
- includeSchema?: boolean;
811
- /** Target JSON Schema version. Defaults to "draft-07". */
812
- target?: "draft-04" | "draft-07" | "draft-2019-09" | "draft-2020-12";
813
- }
814
- /**
815
- * Converts a Zod schema to JSON Schema.
816
- * This is a simplified implementation that handles common Zod types.
817
- * For full Zod support, consider using the 'zod-to-json-schema' package.
818
- *
819
- * @param schema - A Zod schema
820
- * @param options - Optional JSON Schema generation options
821
- * @returns A JSON Schema object
822
- */
823
- declare function zodToJsonSchema(schema: ZodLikeSchema, options?: JsonSchemaOptions): Record<string, unknown>;
824
- /**
825
- * Creates a function tool from a Zod schema.
826
- *
827
- * This function automatically converts a Zod schema to a JSON Schema
828
- * and creates a tool definition. It eliminates the need to manually
829
- * write JSON schemas for tool parameters.
830
- *
831
- * @example
832
- * ```typescript
833
- * import { z } from "zod";
834
- * import { createFunctionToolFromSchema } from "@modelrelay/sdk";
835
- *
836
- * const weatherParams = z.object({
837
- * location: z.string().describe("City name"),
838
- * unit: z.enum(["celsius", "fahrenheit"]).default("celsius"),
839
- * });
840
- *
841
- * const weatherTool = createFunctionToolFromSchema(
842
- * "get_weather",
843
- * "Get weather for a location",
844
- * weatherParams
845
- * );
846
- * ```
847
- *
848
- * @param name - The tool name
849
- * @param description - A description of what the tool does
850
- * @param schema - A Zod schema defining the tool's parameters
851
- * @param options - Optional JSON Schema generation options
852
- * @returns A Tool definition with the JSON schema derived from the Zod schema
853
- */
854
- declare function createFunctionToolFromSchema(name: string, description: string, schema: ZodLikeSchema, options?: JsonSchemaOptions): Tool;
855
- /**
856
- * Creates a function tool with the given name, description, and JSON schema.
857
- */
858
- declare function createFunctionTool(name: string, description: string, parameters?: Record<string, unknown>): Tool;
859
- /**
860
- * Creates a web tool with optional domain filters and intent.
861
- */
862
- declare function createWebTool(options?: {
863
- intent?: WebToolIntent;
864
- allowedDomains?: string[];
865
- excludedDomains?: string[];
866
- maxUses?: number;
867
- }): Tool;
868
- /**
869
- * Returns a ToolChoice that lets the model decide when to use tools.
870
- */
871
- declare function toolChoiceAuto(): ToolChoice;
872
- /**
873
- * Returns a ToolChoice that forces the model to use a tool.
874
- */
875
- declare function toolChoiceRequired(): ToolChoice;
876
- /**
877
- * Returns a ToolChoice that prevents the model from using tools.
878
- */
879
- declare function toolChoiceNone(): ToolChoice;
880
- /**
881
- * Returns true if the response contains tool calls.
882
- */
883
- declare function hasToolCalls(response: Response): boolean;
884
- /**
885
- * Returns the first tool call from a response, or undefined if none exist.
886
- */
887
- declare function firstToolCall(response: Response): ToolCall | undefined;
888
- /**
889
- * Creates a message containing the result of a tool call.
890
- */
891
- declare function toolResultMessage(toolCallId: string, result: unknown): InputItem;
892
- /**
893
- * Creates a tool result message from a ToolCall.
894
- * Convenience wrapper around toolResultMessage using the call's ID.
895
- */
896
- declare function respondToToolCall(call: ToolCall, result: unknown): InputItem;
897
- /**
898
- * Creates an assistant message that includes tool calls.
899
- * Used to include the assistant's tool-calling turn in conversation history.
900
- */
901
- declare function assistantMessageWithToolCalls(content: string, toolCalls: ToolCall[]): InputItem;
902
- /**
903
- * Accumulates streaming tool call deltas into complete tool calls.
904
- */
905
- declare class ToolCallAccumulator {
906
- private calls;
907
- /**
908
- * Processes a streaming tool call delta.
909
- * Returns true if this started a new tool call.
910
- */
911
- processDelta(delta: ToolCallDelta): boolean;
912
- /**
913
- * Returns all accumulated tool calls in index order.
914
- */
915
- getToolCalls(): ToolCall[];
916
- /**
917
- * Returns a specific tool call by index, or undefined if not found.
918
- */
919
- getToolCall(index: number): ToolCall | undefined;
920
- /**
921
- * Clears all accumulated tool calls.
922
- */
923
- reset(): void;
924
- }
925
- /**
926
- * Error thrown when tool argument parsing or validation fails.
927
- * Contains a descriptive message suitable for sending back to the model.
928
- */
929
- declare class ToolArgsError extends Error {
930
- /** The tool call ID for correlation */
931
- readonly toolCallId: string;
932
- /** The tool name that was called */
933
- readonly toolName: string;
934
- /** The raw arguments string that failed to parse */
935
- readonly rawArguments: string;
936
- constructor(message: string, toolCallId: string, toolName: string, rawArguments: string);
937
- }
938
- /**
939
- * Schema interface compatible with Zod, Yup, and similar validation libraries.
940
- * Any object with a `parse` method that returns the validated type works.
941
- */
942
- interface Schema<T> {
943
- parse(data: unknown): T;
944
- }
945
- /**
946
- * Parses and validates tool call arguments using a schema.
947
- *
948
- * Works with any schema library that has a `parse` method (Zod, Yup, etc.).
949
- * Throws a descriptive ToolArgsError if parsing or validation fails.
950
- *
951
- * @example
952
- * ```typescript
953
- * import { z } from "zod";
954
- *
955
- * const WeatherArgs = z.object({
956
- * location: z.string(),
957
- * unit: z.enum(["celsius", "fahrenheit"]).default("celsius"),
958
- * });
959
- *
960
- * // In your tool handler:
961
- * const args = parseToolArgs(toolCall, WeatherArgs);
962
- * // args is typed as { location: string; unit: "celsius" | "fahrenheit" }
963
- * ```
964
- *
965
- * @param call - The tool call containing arguments to parse
966
- * @param schema - A schema with a `parse` method (Zod, Yup, etc.)
967
- * @returns The parsed and validated arguments with proper types
968
- * @throws {ToolArgsError} If JSON parsing or schema validation fails
969
- */
970
- declare function parseToolArgs<T>(call: ToolCall, schema: Schema<T>): T;
971
- /**
972
- * Attempts to parse tool arguments, returning a result object instead of throwing.
973
- *
974
- * @example
975
- * ```typescript
976
- * const result = tryParseToolArgs(toolCall, WeatherArgs);
977
- * if (result.success) {
978
- * console.log(result.data.location);
979
- * } else {
980
- * console.error(result.error.message);
981
- * }
982
- * ```
983
- *
984
- * @param call - The tool call containing arguments to parse
985
- * @param schema - A schema with a `parse` method
986
- * @returns An object with either { success: true, data: T } or { success: false, error: ToolArgsError }
987
- */
988
- declare function tryParseToolArgs<T>(call: ToolCall, schema: Schema<T>): {
989
- success: true;
990
- data: T;
991
- } | {
992
- success: false;
993
- error: ToolArgsError;
994
- };
995
- /**
996
- * Parses raw JSON arguments without schema validation.
997
- * Useful when you want JSON parsing error handling but not schema validation.
998
- *
999
- * @param call - The tool call containing arguments to parse
1000
- * @returns The parsed JSON as an unknown type
1001
- * @throws {ToolArgsError} If JSON parsing fails
1002
- */
1003
- declare function parseToolArgsRaw(call: ToolCall): unknown;
1004
- /**
1005
- * Handler function type for tool execution.
1006
- * Can be sync or async, receives parsed arguments and returns a result.
1007
- */
1008
- type ToolHandler<T = unknown, R = unknown> = (args: T, call: ToolCall) => R | Promise<R>;
1009
- /**
1010
- * Result of executing a tool call.
1011
- */
1012
- interface ToolExecutionResult {
1013
- toolCallId: string;
1014
- toolName: string;
1015
- result: unknown;
1016
- error?: string;
1017
- /**
1018
- * True if the error is due to malformed arguments (JSON parse or validation failure)
1019
- * and the model should be given a chance to retry with corrected arguments.
1020
- */
1021
- isRetryable?: boolean;
1022
- }
1023
- /**
1024
- * Registry for mapping tool names to handler functions with automatic dispatch.
1025
- *
1026
- * @example
1027
- * ```typescript
1028
- * const registry = new ToolRegistry()
1029
- * .register("get_weather", async (args) => {
1030
- * return { temp: 72, unit: "fahrenheit" };
1031
- * })
1032
- * .register("search", async (args) => {
1033
- * return { results: ["result1", "result2"] };
1034
- * });
1035
- *
1036
- * // Execute all tool calls from a response
1037
- * const results = await registry.executeAll(response.toolCalls);
1038
- *
1039
- * // Convert results to messages for the next request
1040
- * const messages = registry.resultsToMessages(results);
1041
- * ```
1042
- */
1043
- declare class ToolRegistry {
1044
- private handlers;
1045
- /**
1046
- * Registers a handler function for a tool name.
1047
- * @param name - The tool name (must match the function name in the tool definition)
1048
- * @param handler - Function to execute when this tool is called
1049
- * @returns this for chaining
1050
- */
1051
- register<T = unknown, R = unknown>(name: string, handler: ToolHandler<T, R>): this;
1052
- /**
1053
- * Unregisters a tool handler.
1054
- * @param name - The tool name to unregister
1055
- * @returns true if the handler was removed, false if it didn't exist
1056
- */
1057
- unregister(name: string): boolean;
1058
- /**
1059
- * Checks if a handler is registered for the given tool name.
1060
- */
1061
- has(name: string): boolean;
1062
- /**
1063
- * Returns the list of registered tool names.
1064
- */
1065
- getRegisteredTools(): string[];
1066
- /**
1067
- * Executes a single tool call.
1068
- * @param call - The tool call to execute
1069
- * @returns The execution result
1070
- */
1071
- execute(call: ToolCall): Promise<ToolExecutionResult>;
1072
- /**
1073
- * Executes multiple tool calls in parallel.
1074
- * @param calls - Array of tool calls to execute
1075
- * @returns Array of execution results in the same order as input
1076
- */
1077
- executeAll(calls: ToolCall[]): Promise<ToolExecutionResult[]>;
1078
- /**
1079
- * Converts execution results to tool result messages.
1080
- * Useful for appending to the conversation history.
1081
- * @param results - Array of execution results
1082
- * @returns Array of tool result input items (role "tool")
1083
- */
1084
- resultsToMessages(results: ToolExecutionResult[]): InputItem[];
1085
- }
1086
- /**
1087
- * Formats a tool execution error into a message suitable for sending back to the model.
1088
- * The message is designed to help the model understand what went wrong and correct it.
1089
- *
1090
- * @example
1091
- * ```typescript
1092
- * const result = await registry.execute(toolCall);
1093
- * if (result.error && result.isRetryable) {
1094
- * const errorMessage = formatToolErrorForModel(result);
1095
- * messages.push(toolResultMessage(result.toolCallId, errorMessage));
1096
- * // Continue conversation to let model retry
1097
- * }
1098
- * ```
1099
- */
1100
- declare function formatToolErrorForModel(result: ToolExecutionResult): string;
1101
- /**
1102
- * Checks if any results have retryable errors.
1103
- *
1104
- * @example
1105
- * ```typescript
1106
- * const results = await registry.executeAll(toolCalls);
1107
- * if (hasRetryableErrors(results)) {
1108
- * // Send error messages back to model and continue conversation
1109
- * }
1110
- * ```
1111
- */
1112
- declare function hasRetryableErrors(results: ToolExecutionResult[]): boolean;
1113
- /**
1114
- * Filters results to only those with retryable errors.
1115
- */
1116
- declare function getRetryableErrors(results: ToolExecutionResult[]): ToolExecutionResult[];
1117
- /**
1118
- * Creates tool result messages for retryable errors, formatted to help the model correct them.
1119
- *
1120
- * @example
1121
- * ```typescript
1122
- * const results = await registry.executeAll(toolCalls);
1123
- * if (hasRetryableErrors(results)) {
1124
- * const retryMessages = createRetryMessages(results);
1125
- * messages.push(...retryMessages);
1126
- * // Make another API call to let model retry
1127
- * }
1128
- * ```
1129
- */
1130
- declare function createRetryMessages(results: ToolExecutionResult[]): InputItem[];
1131
- /**
1132
- * Options for executeWithRetry.
1133
- */
1134
- interface RetryOptions {
1135
- /**
1136
- * Maximum number of retry attempts for parse/validation errors.
1137
- * @default 2
1138
- */
1139
- maxRetries?: number;
1140
- /**
1141
- * Callback invoked when a retryable error occurs.
1142
- * Should return new tool calls from the model's response.
1143
- * If not provided, executeWithRetry will not retry automatically.
1144
- *
1145
- * @param errorMessages - Messages to send back to the model
1146
- * @param attempt - Current attempt number (1-based)
1147
- * @returns New tool calls from the model, or empty array to stop retrying
1148
- */
1149
- onRetry?: (errorMessages: InputItem[], attempt: number) => Promise<ToolCall[]>;
1150
- }
1151
- /**
1152
- * Executes tool calls with automatic retry on parse/validation errors.
1153
- *
1154
- * This is a higher-level utility that wraps registry.executeAll with retry logic.
1155
- * When a retryable error occurs, it calls the onRetry callback to get new tool calls
1156
- * from the model and continues execution.
1157
- *
1158
- * **Result Preservation**: Successful results are preserved across retries. If you
1159
- * execute multiple tool calls and only some fail, the successful results are kept
1160
- * and merged with the results from retry attempts. Results are keyed by toolCallId,
1161
- * so if a retry returns a call with the same ID as a previous result, the newer
1162
- * result will replace it.
1163
- *
1164
- * @example
1165
- * ```typescript
1166
- * const results = await executeWithRetry(registry, toolCalls, {
1167
- * maxRetries: 2,
1168
- * onRetry: async (errorMessages, attempt) => {
1169
- * console.log(`Retry attempt ${attempt}`);
1170
- * // Add error messages to conversation and call the model again
1171
- * messages.push(assistantMessageWithToolCalls("", toolCalls));
1172
- * messages.push(...errorMessages);
1173
- * const req = client.responses
1174
- * .new()
1175
- * .model("...")
1176
- * .input(messages)
1177
- * .tools(tools)
1178
- * .build();
1179
- * const response = await client.responses.create(req);
1180
- * return firstToolCall(response) ? [firstToolCall(response)!] : [];
1181
- * },
1182
- * });
1183
- * ```
1184
- *
1185
- * @param registry - The tool registry to use for execution
1186
- * @param toolCalls - Initial tool calls to execute
1187
- * @param options - Retry configuration
1188
- * @returns Final execution results after all retries, including preserved successes
1189
- */
1190
- declare function executeWithRetry(registry: ToolRegistry, toolCalls: ToolCall[], options?: RetryOptions): Promise<ToolExecutionResult[]>;
1191
-
1192
- export { createToolCall as $, type ApiKey as A, DEFAULT_BASE_URL as B, type CustomerTokenRequest as C, type DeviceStartRequest as D, createFunctionTool as E, type FrontendCustomer as F, createFunctionToolFromSchema as G, createWebTool as H, type InputItem as I, toolChoiceAuto as J, toolChoiceRequired as K, toolChoiceNone as L, type MetricsCallbacks as M, hasToolCalls as N, type OIDCExchangeRequest as O, type ProviderId as P, firstToolCall as Q, type RetryConfig as R, type StructuredJSONEvent as S, type TraceCallbacks as T, createUserMessage as U, createAssistantMessage as V, createSystemMessage as W, toolResultMessage as X, respondToToolCall as Y, type ZodLikeSchema as Z, assistantMessageWithToolCalls as _, type RequestContext as a, type ToolCall as a$, createFunctionCall as a0, ToolCallAccumulator as a1, zodToJsonSchema as a2, parseToolArgs as a3, tryParseToolArgs as a4, parseToolArgsRaw as a5, ToolArgsError as a6, formatToolErrorForModel as a7, hasRetryableErrors as a8, getRetryableErrors as a9, type DeviceTokenResponse as aA, type DeviceTokenPending as aB, type Usage as aC, createUsage as aD, type UsageSummary as aE, type Project as aF, MessageRoles as aG, type MessageRole as aH, ContentPartTypes as aI, type ContentPartType as aJ, type ContentPart as aK, InputItemTypes as aL, type InputItemType as aM, OutputItemTypes as aN, type OutputItemType as aO, type OutputItem as aP, ToolTypes as aQ, type ToolType as aR, WebToolIntents as aS, type WebToolIntent as aT, type FunctionTool as aU, type WebSearchConfig as aV, type XSearchConfig as aW, type CodeExecConfig as aX, ToolChoiceTypes as aY, type ToolChoiceType as aZ, type FunctionCall as a_, createRetryMessages as aa, executeWithRetry as ab, type JsonSchemaOptions as ac, type Schema as ad, type ToolHandler as ae, type RetryOptions as af, SDK_VERSION as ag, DEFAULT_CLIENT_HEADER as ah, DEFAULT_CONNECT_TIMEOUT_MS as ai, DEFAULT_REQUEST_TIMEOUT_MS as aj, type NonEmptyArray as ak, StopReasons as al, type KnownStopReason as am, type StopReason as an, asProviderId as ao, asModelId as ap, asTierCode as aq, SubscriptionStatuses as ar, type SubscriptionStatusKind as as, BillingProviders as at, type BillingProvider as au, type CustomerMetadata as av, type ModelRelayBaseOptions as aw, type ModelRelayTokenOptions as ax, type ModelRelayTokenProviderOptions as ay, type TokenType as az, type TokenProvider as b, OutputFormatTypes as b0, type OutputFormatType as b1, type JSONSchemaFormat as b2, type Citation as b3, type HttpRequestMetrics as b4, type StreamFirstTokenMetrics as b5, type TokenUsageMetrics as b6, mergeMetrics as b7, mergeTrace as b8, normalizeStopReason as b9, stopReasonToString as ba, normalizeModelId as bb, modelToString as bc, type ResponseEventType as bd, type MessageStartData as be, type MessageDeltaData as bf, type MessageStopData as bg, type ToolCallDelta as bh, type FunctionCallDelta as bi, type StructuredJSONRecordType as bj, type DeepPartial as bk, type APIFrontendToken as bl, type APICustomerRef as bm, type APICheckoutSession as bn, type APIUsage as bo, type APIResponsesResponse as bp, type APIKey as bq, type FrontendTokenRequest as c, type FrontendToken as d, type FrontendTokenAutoProvisionRequest as e, type CustomerToken as f, type DeviceStartResponse as g, type DeviceTokenResult as h, type OAuthStartRequest as i, type OAuthStartResponse as j, type ModelId as k, type OutputFormat as l, type Tool as m, type ToolChoice as n, type ResponseEvent as o, type Response as p, type FieldError as q, type RetryMetadata as r, type TransportErrorKind as s, ToolRegistry as t, type ToolExecutionResult as u, type TierCode as v, type PublishableKey as w, type SecretKey as x, type ModelRelayKeyOptions as y, type ModelRelayOptions as z };