@canarycoders/ai 0.7.0 → 0.8.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.cjs +4 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +44 -1
- package/dist/index.d.ts +44 -1
- package/dist/index.js +4 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -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,6 +505,8 @@ 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
512
|
provider: "gemini" | "vertex" | "xai";
|
|
@@ -513,6 +532,8 @@ interface VideoGenerationResult {
|
|
|
513
532
|
videos: GeneratedVideo[];
|
|
514
533
|
model: string;
|
|
515
534
|
provider: string;
|
|
535
|
+
/** Cost of this call (absent on older gateways). */
|
|
536
|
+
cost?: CostInfo;
|
|
516
537
|
}
|
|
517
538
|
interface VideoUploadResult {
|
|
518
539
|
fileId: string;
|
|
@@ -548,6 +569,8 @@ interface TTSResult {
|
|
|
548
569
|
model: string;
|
|
549
570
|
provider: string;
|
|
550
571
|
characterCount?: number;
|
|
572
|
+
/** Cost of this call (absent on older gateways). */
|
|
573
|
+
cost?: CostInfo;
|
|
551
574
|
}
|
|
552
575
|
interface TranscribeParams {
|
|
553
576
|
provider: "elevenlabs" | "mlxaudio";
|
|
@@ -576,6 +599,8 @@ interface STTResult {
|
|
|
576
599
|
words?: TranscriptWord[];
|
|
577
600
|
model: string;
|
|
578
601
|
provider: string;
|
|
602
|
+
/** Cost of this call (absent on older gateways). */
|
|
603
|
+
cost?: CostInfo;
|
|
579
604
|
}
|
|
580
605
|
interface SoundEffectParams {
|
|
581
606
|
text: string;
|
|
@@ -591,6 +616,8 @@ interface SoundEffectResult {
|
|
|
591
616
|
mimeType: string;
|
|
592
617
|
model: string;
|
|
593
618
|
provider: string;
|
|
619
|
+
/** Cost of this call (absent on older gateways). */
|
|
620
|
+
cost?: CostInfo;
|
|
594
621
|
}
|
|
595
622
|
interface MusicParams {
|
|
596
623
|
prompt: string;
|
|
@@ -605,6 +632,8 @@ interface MusicResult {
|
|
|
605
632
|
mimeType: string;
|
|
606
633
|
model: string;
|
|
607
634
|
provider: string;
|
|
635
|
+
/** Cost of this call (absent on older gateways). */
|
|
636
|
+
cost?: CostInfo;
|
|
608
637
|
}
|
|
609
638
|
interface DialogueInput {
|
|
610
639
|
text: string;
|
|
@@ -626,6 +655,8 @@ interface DialogueResult {
|
|
|
626
655
|
mimeType: string;
|
|
627
656
|
model: string;
|
|
628
657
|
provider: string;
|
|
658
|
+
/** Cost of this call (absent on older gateways). */
|
|
659
|
+
cost?: CostInfo;
|
|
629
660
|
}
|
|
630
661
|
interface EmbeddingParams {
|
|
631
662
|
provider: "lmstudio";
|
|
@@ -649,6 +680,8 @@ interface EmbeddingResult {
|
|
|
649
680
|
inputTokens: number;
|
|
650
681
|
totalTokens: number;
|
|
651
682
|
};
|
|
683
|
+
/** Cost of this call (absent on older gateways). */
|
|
684
|
+
cost?: CostInfo;
|
|
652
685
|
}
|
|
653
686
|
|
|
654
687
|
declare class AudioResource extends BaseResource {
|
|
@@ -909,12 +942,16 @@ interface ImageRecognitionResult {
|
|
|
909
942
|
model: string;
|
|
910
943
|
width?: number;
|
|
911
944
|
height?: number;
|
|
945
|
+
/** Cost of this call (absent on older gateways). */
|
|
946
|
+
cost?: CostInfo;
|
|
912
947
|
}
|
|
913
948
|
interface FaceDetectionResult {
|
|
914
949
|
faces: Detection[];
|
|
915
950
|
/** base64-encoded image with faces blurred (when `blur: true`) */
|
|
916
951
|
blurredImage?: string;
|
|
917
952
|
model: string;
|
|
953
|
+
/** Cost of this call (absent on older gateways). */
|
|
954
|
+
cost?: CostInfo;
|
|
918
955
|
}
|
|
919
956
|
interface WebEntity {
|
|
920
957
|
description?: string;
|
|
@@ -924,6 +961,8 @@ interface WebDetectionResult {
|
|
|
924
961
|
entities: WebEntity[];
|
|
925
962
|
pages?: unknown[];
|
|
926
963
|
matchingImages?: unknown[];
|
|
964
|
+
/** Cost of this call (absent on older gateways). */
|
|
965
|
+
cost?: CostInfo;
|
|
927
966
|
}
|
|
928
967
|
interface AutoLabelParams {
|
|
929
968
|
images: string[];
|
|
@@ -1033,6 +1072,8 @@ interface OcrResult {
|
|
|
1033
1072
|
width: number;
|
|
1034
1073
|
height: number;
|
|
1035
1074
|
};
|
|
1075
|
+
/** Cost of this call (absent on older gateways). */
|
|
1076
|
+
cost?: CostInfo;
|
|
1036
1077
|
}
|
|
1037
1078
|
interface RedactParams {
|
|
1038
1079
|
/** base64-encoded image bytes (max ~50MB) */
|
|
@@ -1082,6 +1123,8 @@ interface RedactResult {
|
|
|
1082
1123
|
width: number;
|
|
1083
1124
|
height: number;
|
|
1084
1125
|
};
|
|
1126
|
+
/** Cost of this call (absent on older gateways). */
|
|
1127
|
+
cost?: CostInfo;
|
|
1085
1128
|
}
|
|
1086
1129
|
interface OcrLanguages {
|
|
1087
1130
|
recognitionLevels: Record<string, string[]>;
|
|
@@ -1207,4 +1250,4 @@ interface StreamAdapterOptions extends SSEOptions {
|
|
|
1207
1250
|
|
|
1208
1251
|
// @ts-ignore
|
|
1209
1252
|
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 };
|
|
1253
|
+
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
|
@@ -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,6 +505,8 @@ 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
512
|
provider: "gemini" | "vertex" | "xai";
|
|
@@ -513,6 +532,8 @@ interface VideoGenerationResult {
|
|
|
513
532
|
videos: GeneratedVideo[];
|
|
514
533
|
model: string;
|
|
515
534
|
provider: string;
|
|
535
|
+
/** Cost of this call (absent on older gateways). */
|
|
536
|
+
cost?: CostInfo;
|
|
516
537
|
}
|
|
517
538
|
interface VideoUploadResult {
|
|
518
539
|
fileId: string;
|
|
@@ -548,6 +569,8 @@ interface TTSResult {
|
|
|
548
569
|
model: string;
|
|
549
570
|
provider: string;
|
|
550
571
|
characterCount?: number;
|
|
572
|
+
/** Cost of this call (absent on older gateways). */
|
|
573
|
+
cost?: CostInfo;
|
|
551
574
|
}
|
|
552
575
|
interface TranscribeParams {
|
|
553
576
|
provider: "elevenlabs" | "mlxaudio";
|
|
@@ -576,6 +599,8 @@ interface STTResult {
|
|
|
576
599
|
words?: TranscriptWord[];
|
|
577
600
|
model: string;
|
|
578
601
|
provider: string;
|
|
602
|
+
/** Cost of this call (absent on older gateways). */
|
|
603
|
+
cost?: CostInfo;
|
|
579
604
|
}
|
|
580
605
|
interface SoundEffectParams {
|
|
581
606
|
text: string;
|
|
@@ -591,6 +616,8 @@ interface SoundEffectResult {
|
|
|
591
616
|
mimeType: string;
|
|
592
617
|
model: string;
|
|
593
618
|
provider: string;
|
|
619
|
+
/** Cost of this call (absent on older gateways). */
|
|
620
|
+
cost?: CostInfo;
|
|
594
621
|
}
|
|
595
622
|
interface MusicParams {
|
|
596
623
|
prompt: string;
|
|
@@ -605,6 +632,8 @@ interface MusicResult {
|
|
|
605
632
|
mimeType: string;
|
|
606
633
|
model: string;
|
|
607
634
|
provider: string;
|
|
635
|
+
/** Cost of this call (absent on older gateways). */
|
|
636
|
+
cost?: CostInfo;
|
|
608
637
|
}
|
|
609
638
|
interface DialogueInput {
|
|
610
639
|
text: string;
|
|
@@ -626,6 +655,8 @@ interface DialogueResult {
|
|
|
626
655
|
mimeType: string;
|
|
627
656
|
model: string;
|
|
628
657
|
provider: string;
|
|
658
|
+
/** Cost of this call (absent on older gateways). */
|
|
659
|
+
cost?: CostInfo;
|
|
629
660
|
}
|
|
630
661
|
interface EmbeddingParams {
|
|
631
662
|
provider: "lmstudio";
|
|
@@ -649,6 +680,8 @@ interface EmbeddingResult {
|
|
|
649
680
|
inputTokens: number;
|
|
650
681
|
totalTokens: number;
|
|
651
682
|
};
|
|
683
|
+
/** Cost of this call (absent on older gateways). */
|
|
684
|
+
cost?: CostInfo;
|
|
652
685
|
}
|
|
653
686
|
|
|
654
687
|
declare class AudioResource extends BaseResource {
|
|
@@ -909,12 +942,16 @@ interface ImageRecognitionResult {
|
|
|
909
942
|
model: string;
|
|
910
943
|
width?: number;
|
|
911
944
|
height?: number;
|
|
945
|
+
/** Cost of this call (absent on older gateways). */
|
|
946
|
+
cost?: CostInfo;
|
|
912
947
|
}
|
|
913
948
|
interface FaceDetectionResult {
|
|
914
949
|
faces: Detection[];
|
|
915
950
|
/** base64-encoded image with faces blurred (when `blur: true`) */
|
|
916
951
|
blurredImage?: string;
|
|
917
952
|
model: string;
|
|
953
|
+
/** Cost of this call (absent on older gateways). */
|
|
954
|
+
cost?: CostInfo;
|
|
918
955
|
}
|
|
919
956
|
interface WebEntity {
|
|
920
957
|
description?: string;
|
|
@@ -924,6 +961,8 @@ interface WebDetectionResult {
|
|
|
924
961
|
entities: WebEntity[];
|
|
925
962
|
pages?: unknown[];
|
|
926
963
|
matchingImages?: unknown[];
|
|
964
|
+
/** Cost of this call (absent on older gateways). */
|
|
965
|
+
cost?: CostInfo;
|
|
927
966
|
}
|
|
928
967
|
interface AutoLabelParams {
|
|
929
968
|
images: string[];
|
|
@@ -1033,6 +1072,8 @@ interface OcrResult {
|
|
|
1033
1072
|
width: number;
|
|
1034
1073
|
height: number;
|
|
1035
1074
|
};
|
|
1075
|
+
/** Cost of this call (absent on older gateways). */
|
|
1076
|
+
cost?: CostInfo;
|
|
1036
1077
|
}
|
|
1037
1078
|
interface RedactParams {
|
|
1038
1079
|
/** base64-encoded image bytes (max ~50MB) */
|
|
@@ -1082,6 +1123,8 @@ interface RedactResult {
|
|
|
1082
1123
|
width: number;
|
|
1083
1124
|
height: number;
|
|
1084
1125
|
};
|
|
1126
|
+
/** Cost of this call (absent on older gateways). */
|
|
1127
|
+
cost?: CostInfo;
|
|
1085
1128
|
}
|
|
1086
1129
|
interface OcrLanguages {
|
|
1087
1130
|
recognitionLevels: Record<string, string[]>;
|
|
@@ -1205,4 +1248,4 @@ interface StreamAdapterOptions extends SSEOptions {
|
|
|
1205
1248
|
includeRaw?: boolean;
|
|
1206
1249
|
}
|
|
1207
1250
|
|
|
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 };
|
|
1251
|
+
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;
|