@canarycoders/ai 0.7.0 → 0.8.1

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
@@ -6,7 +6,7 @@ export { b as RealtimeKind, c as RealtimeTool } from './realtime-BWDkXcj9.cjs';
6
6
  type FetchLike = typeof globalThis.fetch;
7
7
 
8
8
  /** Every provider the gateway can route to. */
9
- type ProviderType = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity" | "elevenlabs" | "mlxaudio" | "vision" | "gcvision" | "zhipu" | "moonshot";
9
+ type ProviderType = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity" | "elevenlabs" | "mlxaudio" | "vision" | "gcvision" | "zhipu" | "moonshot" | "ocr" | "ltx";
10
10
  /** Providers that serve text chat / completion. */
11
11
  type ChatProvider = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity" | "zhipu" | "moonshot";
12
12
  type ModelCapability = "chat" | "vision" | "image-generation" | "video-generation" | "text-to-speech" | "speech-to-text" | "image-recognition" | "face-detection" | "web-detection" | "conversation" | "sound-effect" | "music-generation" | "dialogue" | "realtime-voice" | "realtime-translate" | "realtime-transcribe" | "embeddings" | "reasoning";
@@ -66,6 +66,18 @@ interface ApiEnvelope<T> {
66
66
  data: T;
67
67
  message?: string;
68
68
  }
69
+ /**
70
+ * What a call cost you. Present on every task result (chat and media) and on
71
+ * the final chunk of a stream. Absent only on results from older gateways.
72
+ */
73
+ interface CostInfo {
74
+ /** Customer price in USD for this call; 0 when it ran on your own provider key (BYOK). */
75
+ customerPrice: number;
76
+ currency: "USD";
77
+ billing: "metered" | "byok";
78
+ /** True when served from the completion cache. */
79
+ cached?: boolean;
80
+ }
69
81
 
70
82
  type ConversationTemplateType = "interview" | "conversation";
71
83
  interface ConversationQuestion {
@@ -330,6 +342,8 @@ interface CompletionResult {
330
342
  toolCalls?: ToolCall[];
331
343
  citations?: Citation[];
332
344
  metadata?: Record<string, unknown>;
345
+ /** Cost of this call (absent on older gateways). */
346
+ cost?: CostInfo;
333
347
  }
334
348
  /** Raw chunk shape emitted by the native `/queue/stream` endpoint. */
335
349
  interface StreamChunk {
@@ -338,6 +352,8 @@ interface StreamChunk {
338
352
  finishReason?: string;
339
353
  toolCallDeltas?: ToolCallDelta[];
340
354
  metadata?: Record<string, unknown>;
355
+ /** Final chunk only: cost of the call. */
356
+ cost?: CostInfo;
341
357
  }
342
358
  /** Normalized streaming event, identical across every wire protocol. */
343
359
  type ChatStreamEvent = {
@@ -366,6 +382,7 @@ type ChatStreamEvent = {
366
382
  type: "done";
367
383
  finishReason?: string;
368
384
  usage?: TokenUsage;
385
+ cost?: CostInfo;
369
386
  raw?: unknown;
370
387
  } | {
371
388
  type: "raw";
@@ -488,17 +505,30 @@ interface ImageGenerationResult {
488
505
  images: GeneratedImage[];
489
506
  model: string;
490
507
  provider: string;
508
+ /** Cost of this call (absent on older gateways). */
509
+ cost?: CostInfo;
491
510
  }
492
511
  interface VideoGenerateParams {
493
- provider: "gemini" | "vertex" | "xai";
512
+ /** gemini/vertex = Veo 3.1, xai = Grok Imagine, ltx = local LTX-2 (no provider cost). */
513
+ provider: "gemini" | "vertex" | "xai" | "ltx";
494
514
  prompt: string;
495
515
  model?: string;
516
+ /**
517
+ * gemini/vertex/xai: "16:9" or "9:16". ltx: any "W:H"; picks a 64-grid size
518
+ * (16:9 = 768x448, 9:16 = 448x768) unless `resolution` is set.
519
+ */
496
520
  aspectRatio?: string;
521
+ /**
522
+ * gemini/vertex: "720p" | "1080p". xai: "480p" | "720p". ltx: pixels "WxH"
523
+ * (e.g. "768x512"), each side snapped to a multiple of 64 (256..1536).
524
+ */
497
525
  resolution?: string;
498
526
  durationSeconds?: number;
499
527
  numberOfVideos?: number;
500
- /** public URL of a seed image */
528
+ /** public URL (or data URI) of the start frame for image-to-video */
501
529
  imageUrl?: string;
530
+ /** Veo only: final frame, interpolates first to last. Rejected by ltx. */
531
+ lastFrameUrl?: string;
502
532
  /** id from `video.upload()` for image-to-video */
503
533
  fileId?: string;
504
534
  tag?: string;
@@ -513,6 +543,8 @@ interface VideoGenerationResult {
513
543
  videos: GeneratedVideo[];
514
544
  model: string;
515
545
  provider: string;
546
+ /** Cost of this call (absent on older gateways). */
547
+ cost?: CostInfo;
516
548
  }
517
549
  interface VideoUploadResult {
518
550
  fileId: string;
@@ -548,6 +580,8 @@ interface TTSResult {
548
580
  model: string;
549
581
  provider: string;
550
582
  characterCount?: number;
583
+ /** Cost of this call (absent on older gateways). */
584
+ cost?: CostInfo;
551
585
  }
552
586
  interface TranscribeParams {
553
587
  provider: "elevenlabs" | "mlxaudio";
@@ -576,6 +610,8 @@ interface STTResult {
576
610
  words?: TranscriptWord[];
577
611
  model: string;
578
612
  provider: string;
613
+ /** Cost of this call (absent on older gateways). */
614
+ cost?: CostInfo;
579
615
  }
580
616
  interface SoundEffectParams {
581
617
  text: string;
@@ -591,6 +627,8 @@ interface SoundEffectResult {
591
627
  mimeType: string;
592
628
  model: string;
593
629
  provider: string;
630
+ /** Cost of this call (absent on older gateways). */
631
+ cost?: CostInfo;
594
632
  }
595
633
  interface MusicParams {
596
634
  prompt: string;
@@ -605,6 +643,8 @@ interface MusicResult {
605
643
  mimeType: string;
606
644
  model: string;
607
645
  provider: string;
646
+ /** Cost of this call (absent on older gateways). */
647
+ cost?: CostInfo;
608
648
  }
609
649
  interface DialogueInput {
610
650
  text: string;
@@ -626,6 +666,8 @@ interface DialogueResult {
626
666
  mimeType: string;
627
667
  model: string;
628
668
  provider: string;
669
+ /** Cost of this call (absent on older gateways). */
670
+ cost?: CostInfo;
629
671
  }
630
672
  interface EmbeddingParams {
631
673
  provider: "lmstudio";
@@ -649,6 +691,8 @@ interface EmbeddingResult {
649
691
  inputTokens: number;
650
692
  totalTokens: number;
651
693
  };
694
+ /** Cost of this call (absent on older gateways). */
695
+ cost?: CostInfo;
652
696
  }
653
697
 
654
698
  declare class AudioResource extends BaseResource {
@@ -909,12 +953,16 @@ interface ImageRecognitionResult {
909
953
  model: string;
910
954
  width?: number;
911
955
  height?: number;
956
+ /** Cost of this call (absent on older gateways). */
957
+ cost?: CostInfo;
912
958
  }
913
959
  interface FaceDetectionResult {
914
960
  faces: Detection[];
915
961
  /** base64-encoded image with faces blurred (when `blur: true`) */
916
962
  blurredImage?: string;
917
963
  model: string;
964
+ /** Cost of this call (absent on older gateways). */
965
+ cost?: CostInfo;
918
966
  }
919
967
  interface WebEntity {
920
968
  description?: string;
@@ -924,6 +972,8 @@ interface WebDetectionResult {
924
972
  entities: WebEntity[];
925
973
  pages?: unknown[];
926
974
  matchingImages?: unknown[];
975
+ /** Cost of this call (absent on older gateways). */
976
+ cost?: CostInfo;
927
977
  }
928
978
  interface AutoLabelParams {
929
979
  images: string[];
@@ -1033,6 +1083,8 @@ interface OcrResult {
1033
1083
  width: number;
1034
1084
  height: number;
1035
1085
  };
1086
+ /** Cost of this call (absent on older gateways). */
1087
+ cost?: CostInfo;
1036
1088
  }
1037
1089
  interface RedactParams {
1038
1090
  /** base64-encoded image bytes (max ~50MB) */
@@ -1082,6 +1134,8 @@ interface RedactResult {
1082
1134
  width: number;
1083
1135
  height: number;
1084
1136
  };
1137
+ /** Cost of this call (absent on older gateways). */
1138
+ cost?: CostInfo;
1085
1139
  }
1086
1140
  interface OcrLanguages {
1087
1141
  recognitionLevels: Record<string, string[]>;
@@ -1207,4 +1261,4 @@ interface StreamAdapterOptions extends SSEOptions {
1207
1261
 
1208
1262
  // @ts-ignore
1209
1263
  export = CanaryCodersAI;
1210
- export { APIConnectionError, APIConnectionTimeoutError, APIError, type ApiEnvelope, type AudioOutputFormat, AuthenticationError, type AutoLabelParams, type AutoLabelResult, type AutoTrainParams, BadRequestError, type BoundingBox, BrokeredCredential, CanaryCodersAI, type CanaryCodersAIOptions, CanaryCodersAI as CanaryLLM, type CanaryCodersAIOptions as CanaryLLMOptions, type ChatProvider, type ChatStreamEvent, type ChatStreamOptions, type Citation, CompatTarget, type CompleteParams, type CompletionResult, ConflictError, type ContentPart, type ConversationQuestion, type ConversationSession, type ConversationSessionRecord, type ConversationTemplate, type ConversationTemplateParams, type ConversationTemplateType, type ConversationTemplateUpdate, type ConversationTool, type ConversationVoiceSettings, type CreateConversationSessionParams, CreateRealtimeSessionParams, type DetectParams, type Detection, type DialogueInput, type DialogueParams, type DialogueResult, type DocumentContent, type EmbeddingParams, type EmbeddingResult, type FaceDetectParams, type FaceDetectionResult, FinalizeRealtimeParams, type GeneratedImage, type GeneratedVideo, type ImageContent, type ImageGenerateParams, type ImageGenerationResult, type ImageRecognitionResult, InternalServerError, Job, type JobSnapshot, type JobStatus, type JobStreamOptions, type KeyInfo, type KeyValidation, type Message, type MessageContent, type MessageRole, type ModelCapability, type ModelInfo, type MusicParams, type MusicResult, NotFoundError, type OcrGranularity, type OcrLanguages, type OcrLine, type OcrRecognitionLevel, type OcrRecognizeParams, type OcrResult, type OcrWord, PermissionError, type PollOptions, type PortalPeriod, type ProviderType, RateLimitError, RealtimeSession, RealtimeSessionRecord, type RedactParams, type RedactPreset, type RedactResult, type RedactStyle, type RedactionDetection, type ResponseFormat, type STTResult, type SignedUrlParams, type SignedUrlResult, type SoundEffectParams, type SoundEffectResult, type SpeechParams, type StreamAdapterOptions, type StreamChunk, type StreamProtocol, type TTSResult, type TaskKind, type TextContent, type ThinkingMode, type TokenUsage, type ToolCall, type ToolCallDelta, type ToolChoice, type ToolDefinition, type TrainParams, type TrainingJob, type TranscribeParams, type TranscriptWord, UnprocessableEntityError, type UsageSummary, type VideoContent, type VideoGenerateParams, type VideoGenerationResult, type VideoUploadOptions, type VideoUploadResult, type VisionModel, type VoiceInfo, type VoiceSettings, type WebDetectParams, type WebDetectionResult, type WebEntity, type WebSearchOptions, type ZeroShotDetectParams, toBrokeredCredential };
1264
+ export { APIConnectionError, APIConnectionTimeoutError, APIError, type ApiEnvelope, type AudioOutputFormat, AuthenticationError, type AutoLabelParams, type AutoLabelResult, type AutoTrainParams, BadRequestError, type BoundingBox, BrokeredCredential, CanaryCodersAI, type CanaryCodersAIOptions, CanaryCodersAI as CanaryLLM, type CanaryCodersAIOptions as CanaryLLMOptions, type ChatProvider, type ChatStreamEvent, type ChatStreamOptions, type Citation, CompatTarget, type CompleteParams, type CompletionResult, ConflictError, type ContentPart, type ConversationQuestion, type ConversationSession, type ConversationSessionRecord, type ConversationTemplate, type ConversationTemplateParams, type ConversationTemplateType, type ConversationTemplateUpdate, type ConversationTool, type ConversationVoiceSettings, type CostInfo, type CreateConversationSessionParams, CreateRealtimeSessionParams, type DetectParams, type Detection, type DialogueInput, type DialogueParams, type DialogueResult, type DocumentContent, type EmbeddingParams, type EmbeddingResult, type FaceDetectParams, type FaceDetectionResult, FinalizeRealtimeParams, type GeneratedImage, type GeneratedVideo, type ImageContent, type ImageGenerateParams, type ImageGenerationResult, type ImageRecognitionResult, InternalServerError, Job, type JobSnapshot, type JobStatus, type JobStreamOptions, type KeyInfo, type KeyValidation, type Message, type MessageContent, type MessageRole, type ModelCapability, type ModelInfo, type MusicParams, type MusicResult, NotFoundError, type OcrGranularity, type OcrLanguages, type OcrLine, type OcrRecognitionLevel, type OcrRecognizeParams, type OcrResult, type OcrWord, PermissionError, type PollOptions, type PortalPeriod, type ProviderType, RateLimitError, RealtimeSession, RealtimeSessionRecord, type RedactParams, type RedactPreset, type RedactResult, type RedactStyle, type RedactionDetection, type ResponseFormat, type STTResult, type SignedUrlParams, type SignedUrlResult, type SoundEffectParams, type SoundEffectResult, type SpeechParams, type StreamAdapterOptions, type StreamChunk, type StreamProtocol, type TTSResult, type TaskKind, type TextContent, type ThinkingMode, type TokenUsage, type ToolCall, type ToolCallDelta, type ToolChoice, type ToolDefinition, type TrainParams, type TrainingJob, type TranscribeParams, type TranscriptWord, UnprocessableEntityError, type UsageSummary, type VideoContent, type VideoGenerateParams, type VideoGenerationResult, type VideoUploadOptions, type VideoUploadResult, type VisionModel, type VoiceInfo, type VoiceSettings, type WebDetectParams, type WebDetectionResult, type WebEntity, type WebSearchOptions, type ZeroShotDetectParams, toBrokeredCredential };
package/dist/index.d.ts CHANGED
@@ -6,7 +6,7 @@ export { b as RealtimeKind, c as RealtimeTool } from './realtime-BWDkXcj9.js';
6
6
  type FetchLike = typeof globalThis.fetch;
7
7
 
8
8
  /** Every provider the gateway can route to. */
9
- type ProviderType = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity" | "elevenlabs" | "mlxaudio" | "vision" | "gcvision" | "zhipu" | "moonshot";
9
+ type ProviderType = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity" | "elevenlabs" | "mlxaudio" | "vision" | "gcvision" | "zhipu" | "moonshot" | "ocr" | "ltx";
10
10
  /** Providers that serve text chat / completion. */
11
11
  type ChatProvider = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity" | "zhipu" | "moonshot";
12
12
  type ModelCapability = "chat" | "vision" | "image-generation" | "video-generation" | "text-to-speech" | "speech-to-text" | "image-recognition" | "face-detection" | "web-detection" | "conversation" | "sound-effect" | "music-generation" | "dialogue" | "realtime-voice" | "realtime-translate" | "realtime-transcribe" | "embeddings" | "reasoning";
@@ -66,6 +66,18 @@ interface ApiEnvelope<T> {
66
66
  data: T;
67
67
  message?: string;
68
68
  }
69
+ /**
70
+ * What a call cost you. Present on every task result (chat and media) and on
71
+ * the final chunk of a stream. Absent only on results from older gateways.
72
+ */
73
+ interface CostInfo {
74
+ /** Customer price in USD for this call; 0 when it ran on your own provider key (BYOK). */
75
+ customerPrice: number;
76
+ currency: "USD";
77
+ billing: "metered" | "byok";
78
+ /** True when served from the completion cache. */
79
+ cached?: boolean;
80
+ }
69
81
 
70
82
  type ConversationTemplateType = "interview" | "conversation";
71
83
  interface ConversationQuestion {
@@ -330,6 +342,8 @@ interface CompletionResult {
330
342
  toolCalls?: ToolCall[];
331
343
  citations?: Citation[];
332
344
  metadata?: Record<string, unknown>;
345
+ /** Cost of this call (absent on older gateways). */
346
+ cost?: CostInfo;
333
347
  }
334
348
  /** Raw chunk shape emitted by the native `/queue/stream` endpoint. */
335
349
  interface StreamChunk {
@@ -338,6 +352,8 @@ interface StreamChunk {
338
352
  finishReason?: string;
339
353
  toolCallDeltas?: ToolCallDelta[];
340
354
  metadata?: Record<string, unknown>;
355
+ /** Final chunk only: cost of the call. */
356
+ cost?: CostInfo;
341
357
  }
342
358
  /** Normalized streaming event, identical across every wire protocol. */
343
359
  type ChatStreamEvent = {
@@ -366,6 +382,7 @@ type ChatStreamEvent = {
366
382
  type: "done";
367
383
  finishReason?: string;
368
384
  usage?: TokenUsage;
385
+ cost?: CostInfo;
369
386
  raw?: unknown;
370
387
  } | {
371
388
  type: "raw";
@@ -488,17 +505,30 @@ interface ImageGenerationResult {
488
505
  images: GeneratedImage[];
489
506
  model: string;
490
507
  provider: string;
508
+ /** Cost of this call (absent on older gateways). */
509
+ cost?: CostInfo;
491
510
  }
492
511
  interface VideoGenerateParams {
493
- provider: "gemini" | "vertex" | "xai";
512
+ /** gemini/vertex = Veo 3.1, xai = Grok Imagine, ltx = local LTX-2 (no provider cost). */
513
+ provider: "gemini" | "vertex" | "xai" | "ltx";
494
514
  prompt: string;
495
515
  model?: string;
516
+ /**
517
+ * gemini/vertex/xai: "16:9" or "9:16". ltx: any "W:H"; picks a 64-grid size
518
+ * (16:9 = 768x448, 9:16 = 448x768) unless `resolution` is set.
519
+ */
496
520
  aspectRatio?: string;
521
+ /**
522
+ * gemini/vertex: "720p" | "1080p". xai: "480p" | "720p". ltx: pixels "WxH"
523
+ * (e.g. "768x512"), each side snapped to a multiple of 64 (256..1536).
524
+ */
497
525
  resolution?: string;
498
526
  durationSeconds?: number;
499
527
  numberOfVideos?: number;
500
- /** public URL of a seed image */
528
+ /** public URL (or data URI) of the start frame for image-to-video */
501
529
  imageUrl?: string;
530
+ /** Veo only: final frame, interpolates first to last. Rejected by ltx. */
531
+ lastFrameUrl?: string;
502
532
  /** id from `video.upload()` for image-to-video */
503
533
  fileId?: string;
504
534
  tag?: string;
@@ -513,6 +543,8 @@ interface VideoGenerationResult {
513
543
  videos: GeneratedVideo[];
514
544
  model: string;
515
545
  provider: string;
546
+ /** Cost of this call (absent on older gateways). */
547
+ cost?: CostInfo;
516
548
  }
517
549
  interface VideoUploadResult {
518
550
  fileId: string;
@@ -548,6 +580,8 @@ interface TTSResult {
548
580
  model: string;
549
581
  provider: string;
550
582
  characterCount?: number;
583
+ /** Cost of this call (absent on older gateways). */
584
+ cost?: CostInfo;
551
585
  }
552
586
  interface TranscribeParams {
553
587
  provider: "elevenlabs" | "mlxaudio";
@@ -576,6 +610,8 @@ interface STTResult {
576
610
  words?: TranscriptWord[];
577
611
  model: string;
578
612
  provider: string;
613
+ /** Cost of this call (absent on older gateways). */
614
+ cost?: CostInfo;
579
615
  }
580
616
  interface SoundEffectParams {
581
617
  text: string;
@@ -591,6 +627,8 @@ interface SoundEffectResult {
591
627
  mimeType: string;
592
628
  model: string;
593
629
  provider: string;
630
+ /** Cost of this call (absent on older gateways). */
631
+ cost?: CostInfo;
594
632
  }
595
633
  interface MusicParams {
596
634
  prompt: string;
@@ -605,6 +643,8 @@ interface MusicResult {
605
643
  mimeType: string;
606
644
  model: string;
607
645
  provider: string;
646
+ /** Cost of this call (absent on older gateways). */
647
+ cost?: CostInfo;
608
648
  }
609
649
  interface DialogueInput {
610
650
  text: string;
@@ -626,6 +666,8 @@ interface DialogueResult {
626
666
  mimeType: string;
627
667
  model: string;
628
668
  provider: string;
669
+ /** Cost of this call (absent on older gateways). */
670
+ cost?: CostInfo;
629
671
  }
630
672
  interface EmbeddingParams {
631
673
  provider: "lmstudio";
@@ -649,6 +691,8 @@ interface EmbeddingResult {
649
691
  inputTokens: number;
650
692
  totalTokens: number;
651
693
  };
694
+ /** Cost of this call (absent on older gateways). */
695
+ cost?: CostInfo;
652
696
  }
653
697
 
654
698
  declare class AudioResource extends BaseResource {
@@ -909,12 +953,16 @@ interface ImageRecognitionResult {
909
953
  model: string;
910
954
  width?: number;
911
955
  height?: number;
956
+ /** Cost of this call (absent on older gateways). */
957
+ cost?: CostInfo;
912
958
  }
913
959
  interface FaceDetectionResult {
914
960
  faces: Detection[];
915
961
  /** base64-encoded image with faces blurred (when `blur: true`) */
916
962
  blurredImage?: string;
917
963
  model: string;
964
+ /** Cost of this call (absent on older gateways). */
965
+ cost?: CostInfo;
918
966
  }
919
967
  interface WebEntity {
920
968
  description?: string;
@@ -924,6 +972,8 @@ interface WebDetectionResult {
924
972
  entities: WebEntity[];
925
973
  pages?: unknown[];
926
974
  matchingImages?: unknown[];
975
+ /** Cost of this call (absent on older gateways). */
976
+ cost?: CostInfo;
927
977
  }
928
978
  interface AutoLabelParams {
929
979
  images: string[];
@@ -1033,6 +1083,8 @@ interface OcrResult {
1033
1083
  width: number;
1034
1084
  height: number;
1035
1085
  };
1086
+ /** Cost of this call (absent on older gateways). */
1087
+ cost?: CostInfo;
1036
1088
  }
1037
1089
  interface RedactParams {
1038
1090
  /** base64-encoded image bytes (max ~50MB) */
@@ -1082,6 +1134,8 @@ interface RedactResult {
1082
1134
  width: number;
1083
1135
  height: number;
1084
1136
  };
1137
+ /** Cost of this call (absent on older gateways). */
1138
+ cost?: CostInfo;
1085
1139
  }
1086
1140
  interface OcrLanguages {
1087
1141
  recognitionLevels: Record<string, string[]>;
@@ -1205,4 +1259,4 @@ interface StreamAdapterOptions extends SSEOptions {
1205
1259
  includeRaw?: boolean;
1206
1260
  }
1207
1261
 
1208
- export { APIConnectionError, APIConnectionTimeoutError, APIError, type ApiEnvelope, type AudioOutputFormat, AuthenticationError, type AutoLabelParams, type AutoLabelResult, type AutoTrainParams, BadRequestError, type BoundingBox, BrokeredCredential, CanaryCodersAI, type CanaryCodersAIOptions, CanaryCodersAI as CanaryLLM, type CanaryCodersAIOptions as CanaryLLMOptions, type ChatProvider, type ChatStreamEvent, type ChatStreamOptions, type Citation, CompatTarget, type CompleteParams, type CompletionResult, ConflictError, type ContentPart, type ConversationQuestion, type ConversationSession, type ConversationSessionRecord, type ConversationTemplate, type ConversationTemplateParams, type ConversationTemplateType, type ConversationTemplateUpdate, type ConversationTool, type ConversationVoiceSettings, type CreateConversationSessionParams, CreateRealtimeSessionParams, type DetectParams, type Detection, type DialogueInput, type DialogueParams, type DialogueResult, type DocumentContent, type EmbeddingParams, type EmbeddingResult, type FaceDetectParams, type FaceDetectionResult, FinalizeRealtimeParams, type GeneratedImage, type GeneratedVideo, type ImageContent, type ImageGenerateParams, type ImageGenerationResult, type ImageRecognitionResult, InternalServerError, Job, type JobSnapshot, type JobStatus, type JobStreamOptions, type KeyInfo, type KeyValidation, type Message, type MessageContent, type MessageRole, type ModelCapability, type ModelInfo, type MusicParams, type MusicResult, NotFoundError, type OcrGranularity, type OcrLanguages, type OcrLine, type OcrRecognitionLevel, type OcrRecognizeParams, type OcrResult, type OcrWord, PermissionError, type PollOptions, type PortalPeriod, type ProviderType, RateLimitError, RealtimeSession, RealtimeSessionRecord, type RedactParams, type RedactPreset, type RedactResult, type RedactStyle, type RedactionDetection, type ResponseFormat, type STTResult, type SignedUrlParams, type SignedUrlResult, type SoundEffectParams, type SoundEffectResult, type SpeechParams, type StreamAdapterOptions, type StreamChunk, type StreamProtocol, type TTSResult, type TaskKind, type TextContent, type ThinkingMode, type TokenUsage, type ToolCall, type ToolCallDelta, type ToolChoice, type ToolDefinition, type TrainParams, type TrainingJob, type TranscribeParams, type TranscriptWord, UnprocessableEntityError, type UsageSummary, type VideoContent, type VideoGenerateParams, type VideoGenerationResult, type VideoUploadOptions, type VideoUploadResult, type VisionModel, type VoiceInfo, type VoiceSettings, type WebDetectParams, type WebDetectionResult, type WebEntity, type WebSearchOptions, type ZeroShotDetectParams, CanaryCodersAI as default, toBrokeredCredential };
1262
+ export { APIConnectionError, APIConnectionTimeoutError, APIError, type ApiEnvelope, type AudioOutputFormat, AuthenticationError, type AutoLabelParams, type AutoLabelResult, type AutoTrainParams, BadRequestError, type BoundingBox, BrokeredCredential, CanaryCodersAI, type CanaryCodersAIOptions, CanaryCodersAI as CanaryLLM, type CanaryCodersAIOptions as CanaryLLMOptions, type ChatProvider, type ChatStreamEvent, type ChatStreamOptions, type Citation, CompatTarget, type CompleteParams, type CompletionResult, ConflictError, type ContentPart, type ConversationQuestion, type ConversationSession, type ConversationSessionRecord, type ConversationTemplate, type ConversationTemplateParams, type ConversationTemplateType, type ConversationTemplateUpdate, type ConversationTool, type ConversationVoiceSettings, type CostInfo, type CreateConversationSessionParams, CreateRealtimeSessionParams, type DetectParams, type Detection, type DialogueInput, type DialogueParams, type DialogueResult, type DocumentContent, type EmbeddingParams, type EmbeddingResult, type FaceDetectParams, type FaceDetectionResult, FinalizeRealtimeParams, type GeneratedImage, type GeneratedVideo, type ImageContent, type ImageGenerateParams, type ImageGenerationResult, type ImageRecognitionResult, InternalServerError, Job, type JobSnapshot, type JobStatus, type JobStreamOptions, type KeyInfo, type KeyValidation, type Message, type MessageContent, type MessageRole, type ModelCapability, type ModelInfo, type MusicParams, type MusicResult, NotFoundError, type OcrGranularity, type OcrLanguages, type OcrLine, type OcrRecognitionLevel, type OcrRecognizeParams, type OcrResult, type OcrWord, PermissionError, type PollOptions, type PortalPeriod, type ProviderType, RateLimitError, RealtimeSession, RealtimeSessionRecord, type RedactParams, type RedactPreset, type RedactResult, type RedactStyle, type RedactionDetection, type ResponseFormat, type STTResult, type SignedUrlParams, type SignedUrlResult, type SoundEffectParams, type SoundEffectResult, type SpeechParams, type StreamAdapterOptions, type StreamChunk, type StreamProtocol, type TTSResult, type TaskKind, type TextContent, type ThinkingMode, type TokenUsage, type ToolCall, type ToolCallDelta, type ToolChoice, type ToolDefinition, type TrainParams, type TrainingJob, type TranscribeParams, type TranscriptWord, UnprocessableEntityError, type UsageSummary, type VideoContent, type VideoGenerateParams, type VideoGenerationResult, type VideoUploadOptions, type VideoUploadResult, type VisionModel, type VoiceInfo, type VoiceSettings, type WebDetectParams, type WebDetectionResult, type WebEntity, type WebSearchOptions, type ZeroShotDetectParams, CanaryCodersAI as default, toBrokeredCredential };
package/dist/index.js CHANGED
@@ -678,6 +678,7 @@ async function* nativeQueueAdapter(frames, includeRaw) {
678
678
  const raw = (v) => includeRaw ? v : void 0;
679
679
  let lastUsage;
680
680
  let lastFinish;
681
+ let lastCost;
681
682
  for await (const frame of frames) {
682
683
  switch (frame.event) {
683
684
  case "start":
@@ -686,11 +687,12 @@ async function* nativeQueueAdapter(frames, includeRaw) {
686
687
  case "error":
687
688
  throw streamError(tryParse(frame.data));
688
689
  case "done":
689
- yield { type: "done", finishReason: lastFinish, usage: lastUsage };
690
+ yield { type: "done", finishReason: lastFinish, usage: lastUsage, cost: lastCost };
690
691
  return;
691
692
  case "chunk": {
692
693
  const chunk = tryParse(frame.data);
693
694
  if (!chunk) break;
695
+ if (chunk.cost) lastCost = chunk.cost;
694
696
  if (chunk.usage) {
695
697
  lastUsage = chunk.usage;
696
698
  yield { type: "usage", usage: chunk.usage, raw: raw(chunk) };
@@ -718,7 +720,7 @@ async function* nativeQueueAdapter(frames, includeRaw) {
718
720
  }
719
721
  }
720
722
  }
721
- yield { type: "done", finishReason: lastFinish, usage: lastUsage };
723
+ yield { type: "done", finishReason: lastFinish, usage: lastUsage, cost: lastCost };
722
724
  }
723
725
  async function* openAIAdapter(frames, includeRaw) {
724
726
  const raw = (v) => includeRaw ? v : void 0;