@modelrelay/sdk 0.14.1 → 0.17.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.
package/dist/index.d.cts CHANGED
@@ -22,34 +22,8 @@ type KnownStopReason = (typeof StopReasons)[keyof typeof StopReasons];
22
22
  type StopReason = KnownStopReason | {
23
23
  other: string;
24
24
  };
25
- declare const Providers: {
26
- readonly OpenAI: "openai";
27
- readonly Anthropic: "anthropic";
28
- readonly XAI: "xai";
29
- readonly GoogleAIStudio: "google-ai-studio";
30
- readonly Echo: "echo";
31
- };
32
- type KnownProvider = (typeof Providers)[keyof typeof Providers];
33
- type ProviderId = KnownProvider | {
34
- other: string;
35
- };
36
- declare const Models: {
37
- readonly Gpt4o: "gpt-4o";
38
- readonly Gpt4oMini: "gpt-4o-mini";
39
- readonly Gpt51: "gpt-5.1";
40
- readonly Claude35HaikuLatest: "claude-3-5-haiku-latest";
41
- readonly Claude35SonnetLatest: "claude-3-5-sonnet-latest";
42
- readonly ClaudeOpus45: "claude-opus-4-5";
43
- readonly Claude35Haiku: "claude-3.5-haiku";
44
- readonly Grok2: "grok-2";
45
- readonly Grok4_1FastNonReasoning: "grok-4-1-fast-non-reasoning";
46
- readonly Grok4_1FastReasoning: "grok-4-1-fast-reasoning";
47
- readonly Echo1: "echo-1";
48
- };
49
- type KnownModel = (typeof Models)[keyof typeof Models];
50
- type ModelId = KnownModel | {
51
- other: string;
52
- };
25
+ type ProviderId = string;
26
+ type ModelId = string;
53
27
  /**
54
28
  * Common configuration options for the ModelRelay client.
55
29
  */
@@ -271,21 +245,26 @@ interface ChatMessage {
271
245
  declare const ToolTypes: {
272
246
  readonly Function: "function";
273
247
  readonly Web: "web";
248
+ readonly WebSearch: "web_search";
274
249
  readonly XSearch: "x_search";
275
250
  readonly CodeExecution: "code_execution";
276
251
  };
277
252
  type ToolType = (typeof ToolTypes)[keyof typeof ToolTypes];
253
+ declare const WebToolModes: {
254
+ readonly Search: "search";
255
+ readonly Browse: "browse";
256
+ };
257
+ type WebToolMode = (typeof WebToolModes)[keyof typeof WebToolModes];
278
258
  interface FunctionTool {
279
259
  name: string;
280
260
  description?: string;
281
261
  parameters?: Record<string, unknown>;
282
262
  }
283
- type WebToolMode = "auto" | "search_only" | "fetch_only" | "search_and_fetch";
284
- interface WebToolConfig {
263
+ interface WebSearchConfig {
285
264
  allowedDomains?: string[];
286
265
  excludedDomains?: string[];
287
266
  maxUses?: number;
288
- mode?: WebToolMode;
267
+ mode?: string;
289
268
  }
290
269
  interface XSearchConfig {
291
270
  allowedHandles?: string[];
@@ -300,7 +279,9 @@ interface CodeExecConfig {
300
279
  interface Tool {
301
280
  type: ToolType;
302
281
  function?: FunctionTool;
303
- web?: WebToolConfig;
282
+ webSearch?: WebSearchConfig;
283
+ /** Alias for webSearch - used in API normalization */
284
+ web?: WebSearchConfig;
304
285
  xSearch?: XSearchConfig;
305
286
  codeExecution?: CodeExecConfig;
306
287
  }
@@ -322,13 +303,25 @@ interface ToolCall {
322
303
  type: ToolType;
323
304
  function?: FunctionCall;
324
305
  }
306
+ declare const ResponseFormatTypes: {
307
+ readonly Text: "text";
308
+ readonly JsonObject: "json_object";
309
+ readonly JsonSchema: "json_schema";
310
+ };
311
+ type ResponseFormatType = (typeof ResponseFormatTypes)[keyof typeof ResponseFormatTypes];
312
+ interface ResponseJSONSchemaFormat {
313
+ name: string;
314
+ description?: string;
315
+ schema: Record<string, unknown>;
316
+ strict?: boolean;
317
+ }
318
+ interface ResponseFormat {
319
+ type: ResponseFormatType;
320
+ json_schema?: ResponseJSONSchemaFormat;
321
+ }
325
322
  interface ChatCompletionCreateParams {
326
- /**
327
- * Model to use for the request. Optional - if omitted, the tier's default model is used.
328
- */
329
- model?: KnownModel;
323
+ model: ModelId;
330
324
  messages: NonEmptyArray<ChatMessage>;
331
- provider?: ProviderId;
332
325
  maxTokens?: number;
333
326
  temperature?: number;
334
327
  metadata?: Record<string, string>;
@@ -346,6 +339,11 @@ interface ChatCompletionCreateParams {
346
339
  * When using publishable keys, a customer id is required to mint a frontend token.
347
340
  */
348
341
  customerId?: string;
342
+ /**
343
+ * Structured outputs configuration. When set with type `json_object` or
344
+ * `json_schema`, the backend validates and returns structured JSON.
345
+ */
346
+ responseFormat?: ResponseFormat;
349
347
  /**
350
348
  * Opt out of SSE streaming and request a blocking JSON response.
351
349
  */
@@ -357,7 +355,6 @@ interface ChatCompletionCreateParams {
357
355
  }
358
356
  interface ChatCompletionResponse {
359
357
  id: string;
360
- provider?: ProviderId;
361
358
  content: string[];
362
359
  stopReason?: StopReason;
363
360
  model?: ModelId;
@@ -384,7 +381,6 @@ type TransportErrorKind = "timeout" | "connect" | "request" | "other";
384
381
  interface RequestContext {
385
382
  method: string;
386
383
  path: string;
387
- provider?: ProviderId;
388
384
  model?: ModelId;
389
385
  requestId?: string;
390
386
  responseId?: string;
@@ -432,8 +428,6 @@ declare function mergeMetrics(base?: MetricsCallbacks, override?: MetricsCallbac
432
428
  declare function mergeTrace(base?: TraceCallbacks, override?: TraceCallbacks): TraceCallbacks | undefined;
433
429
  declare function normalizeStopReason(value?: unknown): StopReason | undefined;
434
430
  declare function stopReasonToString(value?: StopReason): string | undefined;
435
- declare function normalizeProvider(value?: unknown): ProviderId | undefined;
436
- declare function providerToString(value?: ProviderId): string | undefined;
437
431
  declare function normalizeModelId(value: unknown): ModelId | undefined;
438
432
  declare function modelToString(value: ModelId): string;
439
433
  type ChatEventType = "message_start" | "message_delta" | "message_stop" | "tool_use_start" | "tool_use_delta" | "tool_use_stop" | "ping" | "custom";
@@ -487,6 +481,12 @@ interface ChatCompletionEvent<T = unknown> {
487
481
  requestId?: string;
488
482
  raw: string;
489
483
  }
484
+ type StructuredJSONRecordType = "start" | "update" | "completion" | "error";
485
+ interface StructuredJSONEvent<T> {
486
+ type: "update" | "completion";
487
+ payload: T;
488
+ requestId?: string;
489
+ }
490
490
  interface APIFrontendToken {
491
491
  token: string;
492
492
  expires_at?: string;
@@ -517,7 +517,6 @@ interface APIChatUsage {
517
517
  }
518
518
  interface APIChatResponse {
519
519
  id?: string;
520
- provider?: string;
521
520
  content?: string | string[];
522
521
  stop_reason?: string;
523
522
  model?: string;
@@ -721,6 +720,13 @@ declare class ChatCompletionsClient {
721
720
  stream: false;
722
721
  }): Promise<ChatCompletionResponse>;
723
722
  create(params: ChatCompletionCreateParams, options?: ChatRequestOptions): Promise<ChatCompletionsStream>;
723
+ /**
724
+ * Stream structured JSON responses using the NDJSON contract defined for
725
+ * /llm/proxy. The request must include a structured responseFormat.
726
+ */
727
+ streamJSON<T>(params: ChatCompletionCreateParams & {
728
+ responseFormat: ResponseFormat;
729
+ }, options?: ChatRequestOptions): Promise<StructuredJSONStream<T>>;
724
730
  }
725
731
  declare class ChatCompletionsStream implements AsyncIterable<ChatCompletionEvent> {
726
732
  private readonly response;
@@ -738,6 +744,21 @@ declare class ChatCompletionsStream implements AsyncIterable<ChatCompletionEvent
738
744
  private enrichContext;
739
745
  private recordFirstToken;
740
746
  }
747
+ declare class StructuredJSONStream<T> implements AsyncIterable<StructuredJSONEvent<T>> {
748
+ private readonly response;
749
+ private readonly requestId?;
750
+ private context;
751
+ private readonly metrics?;
752
+ private readonly trace?;
753
+ private closed;
754
+ private sawTerminal;
755
+ constructor(response: Response, requestId: string | undefined, context: RequestContext, metrics?: MetricsCallbacks, trace?: TraceCallbacks);
756
+ cancel(reason?: unknown): Promise<void>;
757
+ [Symbol.asyncIterator](): AsyncIterator<StructuredJSONEvent<T>>;
758
+ collect(): Promise<T>;
759
+ private parseRecord;
760
+ private traceStructuredEvent;
761
+ }
741
762
 
742
763
  /**
743
764
  * Customer metadata as an arbitrary key-value object.
@@ -780,6 +801,15 @@ interface CustomerUpsertRequest {
780
801
  email: string;
781
802
  metadata?: CustomerMetadata;
782
803
  }
804
+ /**
805
+ * Request to claim a customer by email, setting their external_id.
806
+ * Used when a customer subscribes via Stripe Checkout (email only) and later
807
+ * authenticates to the app, needing to link their identity.
808
+ */
809
+ interface CustomerClaimRequest {
810
+ email: string;
811
+ external_id: string;
812
+ }
783
813
  /**
784
814
  * Request to create a checkout session.
785
815
  */
@@ -834,6 +864,15 @@ declare class CustomersClient {
834
864
  * Otherwise, a new customer is created.
835
865
  */
836
866
  upsert(request: CustomerUpsertRequest): Promise<Customer>;
867
+ /**
868
+ * Claim a customer by email, setting their external_id.
869
+ * Used when a customer subscribes via Stripe Checkout (email only) and later
870
+ * authenticates to the app, needing to link their identity.
871
+ *
872
+ * @throws {APIError} with status 404 if customer not found by email
873
+ * @throws {APIError} with status 409 if customer already claimed or external_id in use
874
+ */
875
+ claim(request: CustomerClaimRequest): Promise<Customer>;
837
876
  /**
838
877
  * Delete a customer by ID.
839
878
  */
@@ -1391,4 +1430,4 @@ declare class ModelRelay {
1391
1430
  constructor(options: ModelRelayOptions);
1392
1431
  }
1393
1432
 
1394
- export { type APIChatResponse, type APIChatUsage, type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, AuthClient, type AuthHeaders, ChatClient, type ChatCompletionCreateParams, type ChatCompletionEvent, type ChatCompletionResponse, ChatCompletionsStream, type ChatEventType, type ChatMessage, type CheckoutSession, type CheckoutSessionRequest, type CodeExecConfig, ConfigError, type Customer, type CustomerCreateRequest, type CustomerMetadata, type CustomerUpsertRequest, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type ErrorCategory, type ErrorCode, ErrorCodes, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenRequest, type FunctionCall, type FunctionCallDelta, type FunctionTool, type HttpRequestMetrics, type JsonSchemaOptions, type KnownModel, type KnownProvider, type KnownStopReason, type MessageDeltaData, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelId, ModelRelay, type ModelRelayBaseOptions, ModelRelayError, type ModelRelayKeyOptions, type ModelRelayOptions, type ModelRelayOptionsLegacy, type ModelRelayTokenOptions, Models, type NonEmptyArray, type PriceInterval, type Project, type ProviderId, Providers, type RequestContext, type RetryConfig, type RetryMetadata, type RetryOptions, SDK_VERSION, type Schema, type StopReason, StopReasons, type StreamFirstTokenMetrics, type SubscriptionStatus, type Tier, TiersClient, type TokenUsageMetrics, type Tool, ToolArgsError, type ToolCall, ToolCallAccumulator, type ToolCallDelta, type ToolChoice, type ToolChoiceType, ToolChoiceTypes, type ToolExecutionResult, type ToolHandler, ToolRegistry, type ToolType, ToolTypes, type TraceCallbacks, TransportError, type TransportErrorKind, type Usage, type UsageSummary, type WebToolConfig, type WebToolMode, type XSearchConfig, type ZodLikeSchema, assistantMessageWithToolCalls, createAccessTokenAuth, createApiKeyAuth, createAssistantMessage, createFunctionCall, createFunctionTool, createFunctionToolFromSchema, createRetryMessages, createSystemMessage, createToolCall, createUsage, createUserMessage, createWebTool, executeWithRetry, firstToolCall, formatToolErrorForModel, getRetryableErrors, hasRetryableErrors, hasToolCalls, isPublishableKey, mergeMetrics, mergeTrace, modelToString, normalizeModelId, normalizeProvider, normalizeStopReason, parseErrorResponse, parseToolArgs, parseToolArgsRaw, providerToString, respondToToolCall, stopReasonToString, toolChoiceAuto, toolChoiceNone, toolChoiceRequired, toolResultMessage, tryParseToolArgs, zodToJsonSchema };
1433
+ export { type APIChatResponse, type APIChatUsage, type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, AuthClient, type AuthHeaders, ChatClient, type ChatCompletionCreateParams, type ChatCompletionEvent, type ChatCompletionResponse, ChatCompletionsStream, type ChatEventType, type ChatMessage, type CheckoutSession, type CheckoutSessionRequest, type CodeExecConfig, ConfigError, type Customer, type CustomerClaimRequest, type CustomerCreateRequest, type CustomerMetadata, type CustomerUpsertRequest, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type ErrorCategory, type ErrorCode, ErrorCodes, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenRequest, type FunctionCall, type FunctionCallDelta, type FunctionTool, type HttpRequestMetrics, type JsonSchemaOptions, type KnownStopReason, type MessageDeltaData, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelId, ModelRelay, type ModelRelayBaseOptions, ModelRelayError, type ModelRelayKeyOptions, type ModelRelayOptions, type ModelRelayOptionsLegacy, type ModelRelayTokenOptions, type NonEmptyArray, type PriceInterval, type Project, type ProviderId, type RequestContext, type ResponseFormat, type ResponseFormatType, ResponseFormatTypes, type ResponseJSONSchemaFormat, type RetryConfig, type RetryMetadata, type RetryOptions, SDK_VERSION, type Schema, type StopReason, StopReasons, type StreamFirstTokenMetrics, type StructuredJSONEvent, type StructuredJSONRecordType, StructuredJSONStream, type SubscriptionStatus, type Tier, TiersClient, type TokenUsageMetrics, type Tool, ToolArgsError, type ToolCall, ToolCallAccumulator, type ToolCallDelta, type ToolChoice, type ToolChoiceType, ToolChoiceTypes, type ToolExecutionResult, type ToolHandler, ToolRegistry, type ToolType, ToolTypes, type TraceCallbacks, TransportError, type TransportErrorKind, type Usage, type UsageSummary, type WebSearchConfig, type WebToolMode, WebToolModes, type XSearchConfig, type ZodLikeSchema, assistantMessageWithToolCalls, createAccessTokenAuth, createApiKeyAuth, createAssistantMessage, createFunctionCall, createFunctionTool, createFunctionToolFromSchema, createRetryMessages, createSystemMessage, createToolCall, createUsage, createUserMessage, createWebTool, executeWithRetry, firstToolCall, formatToolErrorForModel, getRetryableErrors, hasRetryableErrors, hasToolCalls, isPublishableKey, mergeMetrics, mergeTrace, modelToString, normalizeModelId, normalizeStopReason, parseErrorResponse, parseToolArgs, parseToolArgsRaw, respondToToolCall, stopReasonToString, toolChoiceAuto, toolChoiceNone, toolChoiceRequired, toolResultMessage, tryParseToolArgs, zodToJsonSchema };
package/dist/index.d.ts CHANGED
@@ -22,34 +22,8 @@ type KnownStopReason = (typeof StopReasons)[keyof typeof StopReasons];
22
22
  type StopReason = KnownStopReason | {
23
23
  other: string;
24
24
  };
25
- declare const Providers: {
26
- readonly OpenAI: "openai";
27
- readonly Anthropic: "anthropic";
28
- readonly XAI: "xai";
29
- readonly GoogleAIStudio: "google-ai-studio";
30
- readonly Echo: "echo";
31
- };
32
- type KnownProvider = (typeof Providers)[keyof typeof Providers];
33
- type ProviderId = KnownProvider | {
34
- other: string;
35
- };
36
- declare const Models: {
37
- readonly Gpt4o: "gpt-4o";
38
- readonly Gpt4oMini: "gpt-4o-mini";
39
- readonly Gpt51: "gpt-5.1";
40
- readonly Claude35HaikuLatest: "claude-3-5-haiku-latest";
41
- readonly Claude35SonnetLatest: "claude-3-5-sonnet-latest";
42
- readonly ClaudeOpus45: "claude-opus-4-5";
43
- readonly Claude35Haiku: "claude-3.5-haiku";
44
- readonly Grok2: "grok-2";
45
- readonly Grok4_1FastNonReasoning: "grok-4-1-fast-non-reasoning";
46
- readonly Grok4_1FastReasoning: "grok-4-1-fast-reasoning";
47
- readonly Echo1: "echo-1";
48
- };
49
- type KnownModel = (typeof Models)[keyof typeof Models];
50
- type ModelId = KnownModel | {
51
- other: string;
52
- };
25
+ type ProviderId = string;
26
+ type ModelId = string;
53
27
  /**
54
28
  * Common configuration options for the ModelRelay client.
55
29
  */
@@ -271,21 +245,26 @@ interface ChatMessage {
271
245
  declare const ToolTypes: {
272
246
  readonly Function: "function";
273
247
  readonly Web: "web";
248
+ readonly WebSearch: "web_search";
274
249
  readonly XSearch: "x_search";
275
250
  readonly CodeExecution: "code_execution";
276
251
  };
277
252
  type ToolType = (typeof ToolTypes)[keyof typeof ToolTypes];
253
+ declare const WebToolModes: {
254
+ readonly Search: "search";
255
+ readonly Browse: "browse";
256
+ };
257
+ type WebToolMode = (typeof WebToolModes)[keyof typeof WebToolModes];
278
258
  interface FunctionTool {
279
259
  name: string;
280
260
  description?: string;
281
261
  parameters?: Record<string, unknown>;
282
262
  }
283
- type WebToolMode = "auto" | "search_only" | "fetch_only" | "search_and_fetch";
284
- interface WebToolConfig {
263
+ interface WebSearchConfig {
285
264
  allowedDomains?: string[];
286
265
  excludedDomains?: string[];
287
266
  maxUses?: number;
288
- mode?: WebToolMode;
267
+ mode?: string;
289
268
  }
290
269
  interface XSearchConfig {
291
270
  allowedHandles?: string[];
@@ -300,7 +279,9 @@ interface CodeExecConfig {
300
279
  interface Tool {
301
280
  type: ToolType;
302
281
  function?: FunctionTool;
303
- web?: WebToolConfig;
282
+ webSearch?: WebSearchConfig;
283
+ /** Alias for webSearch - used in API normalization */
284
+ web?: WebSearchConfig;
304
285
  xSearch?: XSearchConfig;
305
286
  codeExecution?: CodeExecConfig;
306
287
  }
@@ -322,13 +303,25 @@ interface ToolCall {
322
303
  type: ToolType;
323
304
  function?: FunctionCall;
324
305
  }
306
+ declare const ResponseFormatTypes: {
307
+ readonly Text: "text";
308
+ readonly JsonObject: "json_object";
309
+ readonly JsonSchema: "json_schema";
310
+ };
311
+ type ResponseFormatType = (typeof ResponseFormatTypes)[keyof typeof ResponseFormatTypes];
312
+ interface ResponseJSONSchemaFormat {
313
+ name: string;
314
+ description?: string;
315
+ schema: Record<string, unknown>;
316
+ strict?: boolean;
317
+ }
318
+ interface ResponseFormat {
319
+ type: ResponseFormatType;
320
+ json_schema?: ResponseJSONSchemaFormat;
321
+ }
325
322
  interface ChatCompletionCreateParams {
326
- /**
327
- * Model to use for the request. Optional - if omitted, the tier's default model is used.
328
- */
329
- model?: KnownModel;
323
+ model: ModelId;
330
324
  messages: NonEmptyArray<ChatMessage>;
331
- provider?: ProviderId;
332
325
  maxTokens?: number;
333
326
  temperature?: number;
334
327
  metadata?: Record<string, string>;
@@ -346,6 +339,11 @@ interface ChatCompletionCreateParams {
346
339
  * When using publishable keys, a customer id is required to mint a frontend token.
347
340
  */
348
341
  customerId?: string;
342
+ /**
343
+ * Structured outputs configuration. When set with type `json_object` or
344
+ * `json_schema`, the backend validates and returns structured JSON.
345
+ */
346
+ responseFormat?: ResponseFormat;
349
347
  /**
350
348
  * Opt out of SSE streaming and request a blocking JSON response.
351
349
  */
@@ -357,7 +355,6 @@ interface ChatCompletionCreateParams {
357
355
  }
358
356
  interface ChatCompletionResponse {
359
357
  id: string;
360
- provider?: ProviderId;
361
358
  content: string[];
362
359
  stopReason?: StopReason;
363
360
  model?: ModelId;
@@ -384,7 +381,6 @@ type TransportErrorKind = "timeout" | "connect" | "request" | "other";
384
381
  interface RequestContext {
385
382
  method: string;
386
383
  path: string;
387
- provider?: ProviderId;
388
384
  model?: ModelId;
389
385
  requestId?: string;
390
386
  responseId?: string;
@@ -432,8 +428,6 @@ declare function mergeMetrics(base?: MetricsCallbacks, override?: MetricsCallbac
432
428
  declare function mergeTrace(base?: TraceCallbacks, override?: TraceCallbacks): TraceCallbacks | undefined;
433
429
  declare function normalizeStopReason(value?: unknown): StopReason | undefined;
434
430
  declare function stopReasonToString(value?: StopReason): string | undefined;
435
- declare function normalizeProvider(value?: unknown): ProviderId | undefined;
436
- declare function providerToString(value?: ProviderId): string | undefined;
437
431
  declare function normalizeModelId(value: unknown): ModelId | undefined;
438
432
  declare function modelToString(value: ModelId): string;
439
433
  type ChatEventType = "message_start" | "message_delta" | "message_stop" | "tool_use_start" | "tool_use_delta" | "tool_use_stop" | "ping" | "custom";
@@ -487,6 +481,12 @@ interface ChatCompletionEvent<T = unknown> {
487
481
  requestId?: string;
488
482
  raw: string;
489
483
  }
484
+ type StructuredJSONRecordType = "start" | "update" | "completion" | "error";
485
+ interface StructuredJSONEvent<T> {
486
+ type: "update" | "completion";
487
+ payload: T;
488
+ requestId?: string;
489
+ }
490
490
  interface APIFrontendToken {
491
491
  token: string;
492
492
  expires_at?: string;
@@ -517,7 +517,6 @@ interface APIChatUsage {
517
517
  }
518
518
  interface APIChatResponse {
519
519
  id?: string;
520
- provider?: string;
521
520
  content?: string | string[];
522
521
  stop_reason?: string;
523
522
  model?: string;
@@ -721,6 +720,13 @@ declare class ChatCompletionsClient {
721
720
  stream: false;
722
721
  }): Promise<ChatCompletionResponse>;
723
722
  create(params: ChatCompletionCreateParams, options?: ChatRequestOptions): Promise<ChatCompletionsStream>;
723
+ /**
724
+ * Stream structured JSON responses using the NDJSON contract defined for
725
+ * /llm/proxy. The request must include a structured responseFormat.
726
+ */
727
+ streamJSON<T>(params: ChatCompletionCreateParams & {
728
+ responseFormat: ResponseFormat;
729
+ }, options?: ChatRequestOptions): Promise<StructuredJSONStream<T>>;
724
730
  }
725
731
  declare class ChatCompletionsStream implements AsyncIterable<ChatCompletionEvent> {
726
732
  private readonly response;
@@ -738,6 +744,21 @@ declare class ChatCompletionsStream implements AsyncIterable<ChatCompletionEvent
738
744
  private enrichContext;
739
745
  private recordFirstToken;
740
746
  }
747
+ declare class StructuredJSONStream<T> implements AsyncIterable<StructuredJSONEvent<T>> {
748
+ private readonly response;
749
+ private readonly requestId?;
750
+ private context;
751
+ private readonly metrics?;
752
+ private readonly trace?;
753
+ private closed;
754
+ private sawTerminal;
755
+ constructor(response: Response, requestId: string | undefined, context: RequestContext, metrics?: MetricsCallbacks, trace?: TraceCallbacks);
756
+ cancel(reason?: unknown): Promise<void>;
757
+ [Symbol.asyncIterator](): AsyncIterator<StructuredJSONEvent<T>>;
758
+ collect(): Promise<T>;
759
+ private parseRecord;
760
+ private traceStructuredEvent;
761
+ }
741
762
 
742
763
  /**
743
764
  * Customer metadata as an arbitrary key-value object.
@@ -780,6 +801,15 @@ interface CustomerUpsertRequest {
780
801
  email: string;
781
802
  metadata?: CustomerMetadata;
782
803
  }
804
+ /**
805
+ * Request to claim a customer by email, setting their external_id.
806
+ * Used when a customer subscribes via Stripe Checkout (email only) and later
807
+ * authenticates to the app, needing to link their identity.
808
+ */
809
+ interface CustomerClaimRequest {
810
+ email: string;
811
+ external_id: string;
812
+ }
783
813
  /**
784
814
  * Request to create a checkout session.
785
815
  */
@@ -834,6 +864,15 @@ declare class CustomersClient {
834
864
  * Otherwise, a new customer is created.
835
865
  */
836
866
  upsert(request: CustomerUpsertRequest): Promise<Customer>;
867
+ /**
868
+ * Claim a customer by email, setting their external_id.
869
+ * Used when a customer subscribes via Stripe Checkout (email only) and later
870
+ * authenticates to the app, needing to link their identity.
871
+ *
872
+ * @throws {APIError} with status 404 if customer not found by email
873
+ * @throws {APIError} with status 409 if customer already claimed or external_id in use
874
+ */
875
+ claim(request: CustomerClaimRequest): Promise<Customer>;
837
876
  /**
838
877
  * Delete a customer by ID.
839
878
  */
@@ -1391,4 +1430,4 @@ declare class ModelRelay {
1391
1430
  constructor(options: ModelRelayOptions);
1392
1431
  }
1393
1432
 
1394
- export { type APIChatResponse, type APIChatUsage, type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, AuthClient, type AuthHeaders, ChatClient, type ChatCompletionCreateParams, type ChatCompletionEvent, type ChatCompletionResponse, ChatCompletionsStream, type ChatEventType, type ChatMessage, type CheckoutSession, type CheckoutSessionRequest, type CodeExecConfig, ConfigError, type Customer, type CustomerCreateRequest, type CustomerMetadata, type CustomerUpsertRequest, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type ErrorCategory, type ErrorCode, ErrorCodes, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenRequest, type FunctionCall, type FunctionCallDelta, type FunctionTool, type HttpRequestMetrics, type JsonSchemaOptions, type KnownModel, type KnownProvider, type KnownStopReason, type MessageDeltaData, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelId, ModelRelay, type ModelRelayBaseOptions, ModelRelayError, type ModelRelayKeyOptions, type ModelRelayOptions, type ModelRelayOptionsLegacy, type ModelRelayTokenOptions, Models, type NonEmptyArray, type PriceInterval, type Project, type ProviderId, Providers, type RequestContext, type RetryConfig, type RetryMetadata, type RetryOptions, SDK_VERSION, type Schema, type StopReason, StopReasons, type StreamFirstTokenMetrics, type SubscriptionStatus, type Tier, TiersClient, type TokenUsageMetrics, type Tool, ToolArgsError, type ToolCall, ToolCallAccumulator, type ToolCallDelta, type ToolChoice, type ToolChoiceType, ToolChoiceTypes, type ToolExecutionResult, type ToolHandler, ToolRegistry, type ToolType, ToolTypes, type TraceCallbacks, TransportError, type TransportErrorKind, type Usage, type UsageSummary, type WebToolConfig, type WebToolMode, type XSearchConfig, type ZodLikeSchema, assistantMessageWithToolCalls, createAccessTokenAuth, createApiKeyAuth, createAssistantMessage, createFunctionCall, createFunctionTool, createFunctionToolFromSchema, createRetryMessages, createSystemMessage, createToolCall, createUsage, createUserMessage, createWebTool, executeWithRetry, firstToolCall, formatToolErrorForModel, getRetryableErrors, hasRetryableErrors, hasToolCalls, isPublishableKey, mergeMetrics, mergeTrace, modelToString, normalizeModelId, normalizeProvider, normalizeStopReason, parseErrorResponse, parseToolArgs, parseToolArgsRaw, providerToString, respondToToolCall, stopReasonToString, toolChoiceAuto, toolChoiceNone, toolChoiceRequired, toolResultMessage, tryParseToolArgs, zodToJsonSchema };
1433
+ export { type APIChatResponse, type APIChatUsage, type APICheckoutSession, type APICustomerRef, APIError, type APIFrontendToken, type APIKey, AuthClient, type AuthHeaders, ChatClient, type ChatCompletionCreateParams, type ChatCompletionEvent, type ChatCompletionResponse, ChatCompletionsStream, type ChatEventType, type ChatMessage, type CheckoutSession, type CheckoutSessionRequest, type CodeExecConfig, ConfigError, type Customer, type CustomerClaimRequest, type CustomerCreateRequest, type CustomerMetadata, type CustomerUpsertRequest, CustomersClient, DEFAULT_BASE_URL, DEFAULT_CLIENT_HEADER, DEFAULT_CONNECT_TIMEOUT_MS, DEFAULT_REQUEST_TIMEOUT_MS, type ErrorCategory, type ErrorCode, ErrorCodes, type FieldError, type FrontendCustomer, type FrontendToken, type FrontendTokenRequest, type FunctionCall, type FunctionCallDelta, type FunctionTool, type HttpRequestMetrics, type JsonSchemaOptions, type KnownStopReason, type MessageDeltaData, type MessageStartData, type MessageStopData, type MetricsCallbacks, type ModelId, ModelRelay, type ModelRelayBaseOptions, ModelRelayError, type ModelRelayKeyOptions, type ModelRelayOptions, type ModelRelayOptionsLegacy, type ModelRelayTokenOptions, type NonEmptyArray, type PriceInterval, type Project, type ProviderId, type RequestContext, type ResponseFormat, type ResponseFormatType, ResponseFormatTypes, type ResponseJSONSchemaFormat, type RetryConfig, type RetryMetadata, type RetryOptions, SDK_VERSION, type Schema, type StopReason, StopReasons, type StreamFirstTokenMetrics, type StructuredJSONEvent, type StructuredJSONRecordType, StructuredJSONStream, type SubscriptionStatus, type Tier, TiersClient, type TokenUsageMetrics, type Tool, ToolArgsError, type ToolCall, ToolCallAccumulator, type ToolCallDelta, type ToolChoice, type ToolChoiceType, ToolChoiceTypes, type ToolExecutionResult, type ToolHandler, ToolRegistry, type ToolType, ToolTypes, type TraceCallbacks, TransportError, type TransportErrorKind, type Usage, type UsageSummary, type WebSearchConfig, type WebToolMode, WebToolModes, type XSearchConfig, type ZodLikeSchema, assistantMessageWithToolCalls, createAccessTokenAuth, createApiKeyAuth, createAssistantMessage, createFunctionCall, createFunctionTool, createFunctionToolFromSchema, createRetryMessages, createSystemMessage, createToolCall, createUsage, createUserMessage, createWebTool, executeWithRetry, firstToolCall, formatToolErrorForModel, getRetryableErrors, hasRetryableErrors, hasToolCalls, isPublishableKey, mergeMetrics, mergeTrace, modelToString, normalizeModelId, normalizeStopReason, parseErrorResponse, parseToolArgs, parseToolArgsRaw, respondToToolCall, stopReasonToString, toolChoiceAuto, toolChoiceNone, toolChoiceRequired, toolResultMessage, tryParseToolArgs, zodToJsonSchema };