@canarycoders/ai 0.4.0 → 0.6.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
@@ -6,15 +6,18 @@ 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";
9
+ type ProviderType = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity" | "elevenlabs" | "mlxaudio" | "vision" | "gcvision" | "zhipu" | "moonshot";
10
10
  /** Providers that serve text chat / completion. */
11
- type ChatProvider = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity";
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";
13
13
  interface TokenUsage {
14
14
  inputTokens: number;
15
15
  outputTokens: number;
16
16
  totalTokens: number;
17
+ /** Cache-read tokens (subset of inputTokens), billed at the cached-input rate. */
17
18
  cachedTokens?: number;
19
+ /** Anthropic only: cache-write tokens (billed at 1.25x input). */
20
+ cacheCreationTokens?: number;
18
21
  reasoningTokens?: number;
19
22
  }
20
23
  interface ModelInfo {
@@ -57,7 +60,7 @@ interface Citation {
57
60
  startIndex?: number;
58
61
  endIndex?: number;
59
62
  }
60
- /** The standard CanaryLLM success envelope: `{ success: true, data: T }`. */
63
+ /** The standard CanaryCoders AI success envelope: `{ success: true, data: T }`. */
61
64
  interface ApiEnvelope<T> {
62
65
  success: boolean;
63
66
  data: T;
@@ -124,6 +127,12 @@ interface CreateConversationSessionParams {
124
127
  interface ConversationSession {
125
128
  session: ConversationSessionRecord;
126
129
  signedUrl: string;
130
+ /**
131
+ * Pass verbatim into the ElevenLabs client's `Conversation.startSession({ dynamicVariables })`
132
+ * so the post-call webhook correlates this session deterministically. Contains
133
+ * `canary_session_id` (this session's id).
134
+ */
135
+ dynamicVariables: Record<string, string>;
127
136
  /** seconds until the signed URL expires (≈900) */
128
137
  expiresIn: number;
129
138
  textOnly: boolean;
@@ -291,6 +300,15 @@ interface CompleteParams {
291
300
  tools?: ToolDefinition[];
292
301
  toolChoice?: ToolChoice;
293
302
  thinkingMode?: ThinkingMode;
303
+ /**
304
+ * Anthropic only: opt into prompt caching. The gateway places cache_control
305
+ * breakpoints on the system prompt and the last message (5-minute TTL).
306
+ */
307
+ promptCaching?: boolean;
308
+ /** OpenAI only: stable cache-routing key (per conversation/workload) to raise automatic cache hits. */
309
+ promptCacheKey?: string;
310
+ /** OpenAI only: stable end-user identifier, also used for cache routing. */
311
+ safetyIdentifier?: string;
294
312
  webSearch?: WebSearchOptions;
295
313
  cache?: {
296
314
  enabled?: boolean;
@@ -971,7 +989,7 @@ declare class VisionResource extends BaseResource {
971
989
  }>;
972
990
  }
973
991
 
974
- interface CanaryLLMOptions {
992
+ interface CanaryCodersAIOptions {
975
993
  /** API key. Defaults to `process.env.CANARY_AI_API_KEY` (legacy `CANARYLLM_API_KEY` still read). */
976
994
  apiKey?: string;
977
995
  /** Base URL. Defaults to `https://api.ai.canarycoders.es`. */
@@ -990,7 +1008,7 @@ interface CanaryLLMOptions {
990
1008
  /** Default polling behavior for queued operations. */
991
1009
  poll?: PollOptions;
992
1010
  }
993
- declare class CanaryLLM {
1011
+ declare class CanaryCodersAI {
994
1012
  readonly chat: ChatResource;
995
1013
  readonly queue: QueueResource;
996
1014
  readonly images: ImagesResource;
@@ -1009,7 +1027,7 @@ declare class CanaryLLM {
1009
1027
  private readonly transport;
1010
1028
  private readonly baseURL;
1011
1029
  private readonly apiKey?;
1012
- constructor(options?: CanaryLLMOptions);
1030
+ constructor(options?: CanaryCodersAIOptions);
1013
1031
  /** Targets to plug into the official `openai` / `@anthropic-ai/sdk` clients. */
1014
1032
  get compat(): {
1015
1033
  openai: () => CompatTarget;
@@ -1081,5 +1099,5 @@ interface StreamAdapterOptions extends SSEOptions {
1081
1099
  }
1082
1100
 
1083
1101
  // @ts-ignore
1084
- export = CanaryLLM;
1085
- export { APIConnectionError, APIConnectionTimeoutError, APIError, type ApiEnvelope, type AudioOutputFormat, AuthenticationError, type AutoLabelParams, type AutoLabelResult, type AutoTrainParams, BadRequestError, type BoundingBox, BrokeredCredential, CanaryLLM, type 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, PermissionError, type PollOptions, type PortalPeriod, type ProviderType, RateLimitError, RealtimeSession, RealtimeSessionRecord, 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 };
1102
+ export = CanaryCodersAI;
1103
+ 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, PermissionError, type PollOptions, type PortalPeriod, type ProviderType, RateLimitError, RealtimeSession, RealtimeSessionRecord, 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,15 +6,18 @@ 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";
9
+ type ProviderType = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity" | "elevenlabs" | "mlxaudio" | "vision" | "gcvision" | "zhipu" | "moonshot";
10
10
  /** Providers that serve text chat / completion. */
11
- type ChatProvider = "gemini" | "vertex" | "openai" | "anthropic" | "xai" | "lmstudio" | "ollama" | "perplexity";
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";
13
13
  interface TokenUsage {
14
14
  inputTokens: number;
15
15
  outputTokens: number;
16
16
  totalTokens: number;
17
+ /** Cache-read tokens (subset of inputTokens), billed at the cached-input rate. */
17
18
  cachedTokens?: number;
19
+ /** Anthropic only: cache-write tokens (billed at 1.25x input). */
20
+ cacheCreationTokens?: number;
18
21
  reasoningTokens?: number;
19
22
  }
20
23
  interface ModelInfo {
@@ -57,7 +60,7 @@ interface Citation {
57
60
  startIndex?: number;
58
61
  endIndex?: number;
59
62
  }
60
- /** The standard CanaryLLM success envelope: `{ success: true, data: T }`. */
63
+ /** The standard CanaryCoders AI success envelope: `{ success: true, data: T }`. */
61
64
  interface ApiEnvelope<T> {
62
65
  success: boolean;
63
66
  data: T;
@@ -124,6 +127,12 @@ interface CreateConversationSessionParams {
124
127
  interface ConversationSession {
125
128
  session: ConversationSessionRecord;
126
129
  signedUrl: string;
130
+ /**
131
+ * Pass verbatim into the ElevenLabs client's `Conversation.startSession({ dynamicVariables })`
132
+ * so the post-call webhook correlates this session deterministically. Contains
133
+ * `canary_session_id` (this session's id).
134
+ */
135
+ dynamicVariables: Record<string, string>;
127
136
  /** seconds until the signed URL expires (≈900) */
128
137
  expiresIn: number;
129
138
  textOnly: boolean;
@@ -291,6 +300,15 @@ interface CompleteParams {
291
300
  tools?: ToolDefinition[];
292
301
  toolChoice?: ToolChoice;
293
302
  thinkingMode?: ThinkingMode;
303
+ /**
304
+ * Anthropic only: opt into prompt caching. The gateway places cache_control
305
+ * breakpoints on the system prompt and the last message (5-minute TTL).
306
+ */
307
+ promptCaching?: boolean;
308
+ /** OpenAI only: stable cache-routing key (per conversation/workload) to raise automatic cache hits. */
309
+ promptCacheKey?: string;
310
+ /** OpenAI only: stable end-user identifier, also used for cache routing. */
311
+ safetyIdentifier?: string;
294
312
  webSearch?: WebSearchOptions;
295
313
  cache?: {
296
314
  enabled?: boolean;
@@ -971,7 +989,7 @@ declare class VisionResource extends BaseResource {
971
989
  }>;
972
990
  }
973
991
 
974
- interface CanaryLLMOptions {
992
+ interface CanaryCodersAIOptions {
975
993
  /** API key. Defaults to `process.env.CANARY_AI_API_KEY` (legacy `CANARYLLM_API_KEY` still read). */
976
994
  apiKey?: string;
977
995
  /** Base URL. Defaults to `https://api.ai.canarycoders.es`. */
@@ -990,7 +1008,7 @@ interface CanaryLLMOptions {
990
1008
  /** Default polling behavior for queued operations. */
991
1009
  poll?: PollOptions;
992
1010
  }
993
- declare class CanaryLLM {
1011
+ declare class CanaryCodersAI {
994
1012
  readonly chat: ChatResource;
995
1013
  readonly queue: QueueResource;
996
1014
  readonly images: ImagesResource;
@@ -1009,7 +1027,7 @@ declare class CanaryLLM {
1009
1027
  private readonly transport;
1010
1028
  private readonly baseURL;
1011
1029
  private readonly apiKey?;
1012
- constructor(options?: CanaryLLMOptions);
1030
+ constructor(options?: CanaryCodersAIOptions);
1013
1031
  /** Targets to plug into the official `openai` / `@anthropic-ai/sdk` clients. */
1014
1032
  get compat(): {
1015
1033
  openai: () => CompatTarget;
@@ -1080,4 +1098,4 @@ interface StreamAdapterOptions extends SSEOptions {
1080
1098
  includeRaw?: boolean;
1081
1099
  }
1082
1100
 
1083
- export { APIConnectionError, APIConnectionTimeoutError, APIError, type ApiEnvelope, type AudioOutputFormat, AuthenticationError, type AutoLabelParams, type AutoLabelResult, type AutoTrainParams, BadRequestError, type BoundingBox, BrokeredCredential, CanaryLLM, type 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, PermissionError, type PollOptions, type PortalPeriod, type ProviderType, RateLimitError, RealtimeSession, RealtimeSessionRecord, 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, CanaryLLM as default, toBrokeredCredential };
1101
+ 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, PermissionError, type PollOptions, type PortalPeriod, type ProviderType, RateLimitError, RealtimeSession, RealtimeSessionRecord, 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
@@ -1590,7 +1590,7 @@ function readEnv(key) {
1590
1590
  if (typeof process !== "undefined" && process.env) return process.env[key];
1591
1591
  return void 0;
1592
1592
  }
1593
- var CanaryLLM = class {
1593
+ var CanaryCodersAI = class {
1594
1594
  chat;
1595
1595
  queue;
1596
1596
  images;
@@ -1649,8 +1649,8 @@ var CanaryLLM = class {
1649
1649
  };
1650
1650
 
1651
1651
  // src/index.ts
1652
- var src_default = CanaryLLM;
1652
+ var src_default = CanaryCodersAI;
1653
1653
 
1654
- export { APIConnectionError, APIConnectionTimeoutError, APIError, AuthenticationError, BadRequestError, CanaryLLM, ConflictError, InternalServerError, Job, NotFoundError, PermissionError, RateLimitError, UnprocessableEntityError, anthropicTarget, src_default as default, openaiTarget, toBrokeredCredential };
1654
+ export { APIConnectionError, APIConnectionTimeoutError, APIError, AuthenticationError, BadRequestError, CanaryCodersAI, CanaryCodersAI as CanaryLLM, ConflictError, InternalServerError, Job, NotFoundError, PermissionError, RateLimitError, UnprocessableEntityError, anthropicTarget, src_default as default, openaiTarget, toBrokeredCredential };
1655
1655
  //# sourceMappingURL=index.js.map
1656
1656
  //# sourceMappingURL=index.js.map