@hiper2d/ai-agents 0.1.4 → 0.2.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/README.md +18 -0
- package/dist/index.d.mts +219 -1
- package/dist/index.d.ts +219 -1
- package/dist/index.js +316 -27
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +295 -25
- package/dist/index.mjs.map +1 -1
- package/package.json +5 -3
package/README.md
CHANGED
|
@@ -56,6 +56,24 @@ import { createCatalog } from '@hiper2d/ai-agents';
|
|
|
56
56
|
const catalog = createCatalog({ glm: { temperature: 0.9 } }); // shallow per-model overrides
|
|
57
57
|
```
|
|
58
58
|
|
|
59
|
+
### Voice agents
|
|
60
|
+
|
|
61
|
+
Speech and transcription behind the same factory pattern. Agents are pure — no auth or
|
|
62
|
+
billing — and every result reports its cost so the host decides whom to charge.
|
|
63
|
+
|
|
64
|
+
```ts
|
|
65
|
+
import { VoiceAgentFactory, API_KEY_CONSTANTS } from '@hiper2d/ai-agents';
|
|
66
|
+
|
|
67
|
+
const voice = VoiceAgentFactory.createAgentFromKeys('google', { [API_KEY_CONSTANTS.GOOGLE]: process.env.GOOGLE_API_KEY! });
|
|
68
|
+
const { audio, costUSD } = await voice.speak({ text: 'Night falls.', voice: 'Kore', voiceStyle: 'gravely' }); // WAV
|
|
69
|
+
const { text } = await voice.transcribe({ audio: recording, mimeType: 'audio/webm' });
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
`openai` runs gpt-4o-mini-tts + Whisper, `google` runs Gemini 3.1 Flash TTS + Gemini 3.5
|
|
73
|
+
Transcribe (`VOICE_MODEL_CONSTANTS`, prices in `VOICE_MODEL_PRICING`). The `voiceStyle`
|
|
74
|
+
direction works for both providers: OpenAI takes it as instructions, Gemini gets it folded
|
|
75
|
+
into the prompt ("Say gravely: …").
|
|
76
|
+
|
|
59
77
|
### Logging
|
|
60
78
|
|
|
61
79
|
The library logs through an injectable sink — `setLlmLogger(fn)` — so a host app can route
|
package/dist/index.d.mts
CHANGED
|
@@ -801,6 +801,224 @@ interface MistralTokenUsage {
|
|
|
801
801
|
}
|
|
802
802
|
declare function extractTokenUsageFromResponse(response: any): MistralTokenUsage | null;
|
|
803
803
|
|
|
804
|
+
/**
|
|
805
|
+
* Voice agents: the speech counterpart of the text agents. One agent per
|
|
806
|
+
* provider, chosen through `VoiceAgentFactory` — a caller asks for a provider
|
|
807
|
+
* and gets `speak()` / `transcribe()` without knowing which SDK or model is
|
|
808
|
+
* behind them. Agents are pure: no auth, tier or billing logic. Each result
|
|
809
|
+
* carries what the call produced and what it cost, and the host decides whom
|
|
810
|
+
* to bill.
|
|
811
|
+
*/
|
|
812
|
+
type VoiceProvider = 'openai' | 'google';
|
|
813
|
+
interface SpeechRequest {
|
|
814
|
+
text: string;
|
|
815
|
+
/** A voice id of this provider's set (e.g. OpenAI "onyx", Gemini "Kore"). */
|
|
816
|
+
voice: string;
|
|
817
|
+
/** Delivery direction: a short adverb ("mysteriously") or a longer sentence. */
|
|
818
|
+
voiceStyle?: string;
|
|
819
|
+
}
|
|
820
|
+
interface SpeechUsage {
|
|
821
|
+
/** OpenAI bills speech per input character. */
|
|
822
|
+
characters?: number;
|
|
823
|
+
/** Gemini bills speech per token: text prompt in, audio out. */
|
|
824
|
+
inputTokens?: number;
|
|
825
|
+
outputTokens?: number;
|
|
826
|
+
}
|
|
827
|
+
interface SpeechResult {
|
|
828
|
+
/** WAV audio (24 kHz mono 16-bit from Gemini; OpenAI's default WAV). */
|
|
829
|
+
audio: ArrayBuffer;
|
|
830
|
+
costUSD: number;
|
|
831
|
+
usage: SpeechUsage;
|
|
832
|
+
}
|
|
833
|
+
interface TranscriptionRequest {
|
|
834
|
+
audio: ArrayBuffer;
|
|
835
|
+
/** Container of the recording, e.g. "audio/webm" (browser MediaRecorder) or "audio/wav". */
|
|
836
|
+
mimeType?: string;
|
|
837
|
+
/** Whisper reads the container from the file name's extension. */
|
|
838
|
+
fileName?: string;
|
|
839
|
+
language?: string;
|
|
840
|
+
prompt?: string;
|
|
841
|
+
}
|
|
842
|
+
interface TranscriptionUsage {
|
|
843
|
+
/** Whisper bills per minute of audio. */
|
|
844
|
+
audioSeconds?: number;
|
|
845
|
+
/** Gemini bills per token: audio in (~25/s), text out. */
|
|
846
|
+
inputTokens?: number;
|
|
847
|
+
outputTokens?: number;
|
|
848
|
+
}
|
|
849
|
+
interface TranscriptionResult {
|
|
850
|
+
text: string;
|
|
851
|
+
/** Audio length; Gemini reports none, so it is derived from audio tokens. */
|
|
852
|
+
durationSeconds: number;
|
|
853
|
+
costUSD: number;
|
|
854
|
+
usage: TranscriptionUsage;
|
|
855
|
+
}
|
|
856
|
+
interface VoiceAgent {
|
|
857
|
+
readonly provider: VoiceProvider;
|
|
858
|
+
readonly ttsModel: string;
|
|
859
|
+
readonly sttModel: string;
|
|
860
|
+
speak(request: SpeechRequest): Promise<SpeechResult>;
|
|
861
|
+
transcribe(request: TranscriptionRequest): Promise<TranscriptionResult>;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/** Speech and transcription models behind each voice provider. */
|
|
865
|
+
declare const VOICE_MODEL_CONSTANTS: {
|
|
866
|
+
readonly OPENAI_TTS: "gpt-4o-mini-tts";
|
|
867
|
+
readonly OPENAI_STT: "whisper-1";
|
|
868
|
+
readonly GOOGLE_TTS: "gemini-3.1-flash-tts-preview";
|
|
869
|
+
readonly GOOGLE_STT: "gemini-3.5-transcribe";
|
|
870
|
+
};
|
|
871
|
+
declare const SUPPORTED_VOICE_PROVIDERS: readonly VoiceProvider[];
|
|
872
|
+
/** Which API key (by API_KEY_CONSTANTS name) a voice provider runs on. */
|
|
873
|
+
declare const VOICE_PROVIDER_API_KEY: Record<VoiceProvider, string>;
|
|
874
|
+
interface VoiceModelPricing {
|
|
875
|
+
/** OpenAI TTS: USD per 1M input characters. */
|
|
876
|
+
pricePerMillionCharacters?: number;
|
|
877
|
+
/** Whisper: USD per minute of audio. */
|
|
878
|
+
pricePerMinute?: number;
|
|
879
|
+
/** Gemini TTS: text prompt in, audio tokens out. */
|
|
880
|
+
textInputPricePerM?: number;
|
|
881
|
+
audioOutputPricePerM?: number;
|
|
882
|
+
/** Gemini Transcribe: audio tokens in, text tokens out. */
|
|
883
|
+
audioInputPricePerM?: number;
|
|
884
|
+
textOutputPricePerM?: number;
|
|
885
|
+
}
|
|
886
|
+
/** Prices as of 2026-09 (openai.com/api/pricing, ai.google.dev/gemini-api/docs/pricing). */
|
|
887
|
+
declare const VOICE_MODEL_PRICING: Record<string, VoiceModelPricing>;
|
|
888
|
+
|
|
889
|
+
interface TokenPairUsage {
|
|
890
|
+
inputTokens: number;
|
|
891
|
+
outputTokens: number;
|
|
892
|
+
}
|
|
893
|
+
/** OpenAI TTS: USD for `characterCount` input characters. */
|
|
894
|
+
declare function calculateOpenAiTtsCost(characterCount: number): number;
|
|
895
|
+
/** Whisper: USD for `durationSeconds` of audio. */
|
|
896
|
+
declare function calculateOpenAiSttCost(durationSeconds: number): number;
|
|
897
|
+
/** Gemini TTS: USD for text prompt tokens in and audio tokens out. */
|
|
898
|
+
declare function calculateGeminiTtsCost(usage: TokenPairUsage): number;
|
|
899
|
+
/** Gemini Transcribe: USD for audio tokens in and text tokens out. */
|
|
900
|
+
declare function calculateGeminiSttCost(usage: TokenPairUsage): number;
|
|
901
|
+
|
|
902
|
+
/** The voice counterpart of AgentFactory: provider in, agent out. */
|
|
903
|
+
declare class VoiceAgentFactory {
|
|
904
|
+
/** Build an agent from a key already resolved by the caller. */
|
|
905
|
+
static createAgent(provider: VoiceProvider, apiKey: string): VoiceAgent;
|
|
906
|
+
/**
|
|
907
|
+
* Build an agent from a key map (the shape AgentFactory takes), reading the
|
|
908
|
+
* provider's key by its API_KEY_CONSTANTS name. Throws when the key is missing
|
|
909
|
+
* so the host can report a misconfiguration before any SDK is touched.
|
|
910
|
+
*/
|
|
911
|
+
static createAgentFromKeys(provider: VoiceProvider, apiKeys: ApiKeyMap): VoiceAgent;
|
|
912
|
+
}
|
|
913
|
+
/** Function form of `VoiceAgentFactory.createAgent`. */
|
|
914
|
+
declare function createVoiceAgent(provider: VoiceProvider, apiKey: string): VoiceAgent;
|
|
915
|
+
|
|
916
|
+
/** gpt-4o-mini-tts (billed per character) + Whisper (billed per minute). */
|
|
917
|
+
declare class OpenAiVoiceAgent implements VoiceAgent {
|
|
918
|
+
private readonly apiKey;
|
|
919
|
+
readonly provider: "openai";
|
|
920
|
+
readonly ttsModel: "gpt-4o-mini-tts";
|
|
921
|
+
readonly sttModel: "whisper-1";
|
|
922
|
+
constructor(apiKey: string);
|
|
923
|
+
speak(request: SpeechRequest): Promise<SpeechResult>;
|
|
924
|
+
transcribe(request: TranscriptionRequest): Promise<TranscriptionResult>;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/** Gemini 3.1 Flash TTS + Gemini 3.5 Transcribe, both billed per token. */
|
|
928
|
+
declare class GoogleVoiceAgent implements VoiceAgent {
|
|
929
|
+
private readonly apiKey;
|
|
930
|
+
readonly provider: "google";
|
|
931
|
+
readonly ttsModel: "gemini-3.1-flash-tts-preview";
|
|
932
|
+
readonly sttModel: "gemini-3.5-transcribe";
|
|
933
|
+
constructor(apiKey: string);
|
|
934
|
+
speak(request: SpeechRequest): Promise<SpeechResult>;
|
|
935
|
+
transcribe(request: TranscriptionRequest): Promise<TranscriptionResult>;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
type OpenAiTtsVoice = 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer' | 'ash' | 'ballad' | 'coral' | 'sage';
|
|
939
|
+
interface OpenAiTtsAudioOptions {
|
|
940
|
+
voice?: OpenAiTtsVoice;
|
|
941
|
+
/** Delivery direction; gpt-4o-mini-tts follows it closely. */
|
|
942
|
+
instructions?: string;
|
|
943
|
+
speed?: number;
|
|
944
|
+
format?: 'mp3' | 'wav' | 'opus' | 'aac' | 'flac' | 'pcm';
|
|
945
|
+
}
|
|
946
|
+
/** Core OpenAI TTS call: text + API key in, audio bytes out (WAV by default). */
|
|
947
|
+
declare function generateOpenAiTtsAudio(text: string, apiKey: string, options?: OpenAiTtsAudioOptions): Promise<ArrayBuffer>;
|
|
948
|
+
|
|
949
|
+
interface OpenAiSttOptions {
|
|
950
|
+
language?: string;
|
|
951
|
+
prompt?: string;
|
|
952
|
+
temperature?: number;
|
|
953
|
+
/** Whisper detects the container format from the extension. */
|
|
954
|
+
fileName?: string;
|
|
955
|
+
mimeType?: string;
|
|
956
|
+
}
|
|
957
|
+
interface OpenAiSttResult {
|
|
958
|
+
text: string;
|
|
959
|
+
durationSeconds: number;
|
|
960
|
+
}
|
|
961
|
+
/** Core Whisper call: audio + API key in, transcript + duration out. */
|
|
962
|
+
declare function transcribeWithOpenAi(audioBuffer: ArrayBuffer, apiKey: string, options?: OpenAiSttOptions): Promise<OpenAiSttResult>;
|
|
963
|
+
|
|
964
|
+
interface GoogleTtsAudioOptions {
|
|
965
|
+
/** e.g. "Kore", "Puck" */
|
|
966
|
+
voiceName: string;
|
|
967
|
+
/** "mysteriously", "excitedly", or a longer direction */
|
|
968
|
+
voiceStyle?: string;
|
|
969
|
+
}
|
|
970
|
+
interface GoogleTtsResult {
|
|
971
|
+
/** WAV, 24 kHz mono 16-bit */
|
|
972
|
+
audio: ArrayBuffer;
|
|
973
|
+
/** text prompt tokens / audio tokens — what Gemini bills */
|
|
974
|
+
usage: {
|
|
975
|
+
inputTokens: number;
|
|
976
|
+
outputTokens: number;
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Gemini TTS has no instruction field: delivery is directed in the text itself
|
|
981
|
+
* ("Say cheerfully: Have a wonderful day!" in the docs). A short style (1-3
|
|
982
|
+
* words) becomes that "Say X:" prefix; a longer direction is used as written,
|
|
983
|
+
* ending in the colon that separates it from the line to read. The same style
|
|
984
|
+
* value feeds OpenAI's `instructions`, so one field serves both providers.
|
|
985
|
+
*/
|
|
986
|
+
declare function buildGoogleTtsPrompt(text: string, voiceStyle?: string): string;
|
|
987
|
+
/** Wraps raw 16-bit mono PCM in a WAV header. */
|
|
988
|
+
declare function pcmToWav(pcmData: Uint8Array, sampleRate?: number): ArrayBuffer;
|
|
989
|
+
/**
|
|
990
|
+
* Core Gemini TTS call: text + API key in, WAV + token usage out.
|
|
991
|
+
*
|
|
992
|
+
* Uses generateContent rather than the newer Interactions API the docs show:
|
|
993
|
+
* both serve the 3.1 TTS model (verified 2026-09-05), and this one is typed in
|
|
994
|
+
* the SDK and reports usageMetadata, which billing needs.
|
|
995
|
+
*/
|
|
996
|
+
declare function generateGoogleTtsAudio(text: string, apiKey: string, options: GoogleTtsAudioOptions): Promise<GoogleTtsResult>;
|
|
997
|
+
|
|
998
|
+
interface GoogleSttOptions {
|
|
999
|
+
/** Container of the recording; browsers record audio/webm. */
|
|
1000
|
+
mimeType?: string;
|
|
1001
|
+
}
|
|
1002
|
+
interface GoogleSttResult {
|
|
1003
|
+
text: string;
|
|
1004
|
+
/** Derived from audio tokens (~25/s) — Gemini reports no duration. */
|
|
1005
|
+
durationSeconds: number;
|
|
1006
|
+
/** audio tokens in, text tokens out — what Gemini bills */
|
|
1007
|
+
usage: {
|
|
1008
|
+
inputTokens: number;
|
|
1009
|
+
outputTokens: number;
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
/** From the pricing page footnote: 25 audio tokens per second of input. */
|
|
1013
|
+
declare const GEMINI_AUDIO_TOKENS_PER_SECOND = 25;
|
|
1014
|
+
/**
|
|
1015
|
+
* Core Gemini transcription call: audio + API key in, transcript + usage out.
|
|
1016
|
+
*
|
|
1017
|
+
* Uses the Interactions API: with this model, generateContent returns the
|
|
1018
|
+
* transcript as a non-text part the SDK cannot surface (verified 2026-09-05).
|
|
1019
|
+
*/
|
|
1020
|
+
declare function transcribeWithGemini(audioBuffer: ArrayBuffer, apiKey: string, options?: GoogleSttOptions): Promise<GoogleSttResult>;
|
|
1021
|
+
|
|
804
1022
|
declare abstract class AbstractAgent {
|
|
805
1023
|
name: string;
|
|
806
1024
|
gameId?: string;
|
|
@@ -1202,4 +1420,4 @@ declare class MiniMaxAgent extends AbstractAgent {
|
|
|
1202
1420
|
doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
|
|
1203
1421
|
}
|
|
1204
1422
|
|
|
1205
|
-
export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
|
|
1423
|
+
export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_AUDIO_TOKENS_PER_SECOND, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleSttOptions, type GoogleSttResult, type GoogleTokenUsage, type GoogleTtsAudioOptions, type GoogleTtsResult, GoogleVoiceAgent, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type OpenAiSttOptions, type OpenAiSttResult, type OpenAiTtsAudioOptions, type OpenAiTtsVoice, OpenAiVoiceAgent, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SUPPORTED_VOICE_PROVIDERS, type SpeechRequest, type SpeechResult, type SpeechUsage, SupportedAiKeyNames, SupportedAiModels, type TokenPairUsage, type TokenUsage$1 as TokenUsage, type TranscriptionRequest, type TranscriptionResult, type TranscriptionUsage, VOICE_MODEL_CONSTANTS, VOICE_MODEL_PRICING, VOICE_PROVIDER_API_KEY, type VoiceAgent, VoiceAgentFactory, type VoiceModelPricing, type VoiceProvider, ZodSchemaConverter, buildGoogleTtsPrompt, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGeminiSttCost, calculateGeminiTtsCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, calculateOpenAiSttCost, calculateOpenAiTtsCost, clampReasoningEffort, cleanResponse, createCatalog, createVoiceAgent, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateGoogleTtsAudio, generateOpenAiTtsAudio, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, pcmToWav, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };
|
package/dist/index.d.ts
CHANGED
|
@@ -801,6 +801,224 @@ interface MistralTokenUsage {
|
|
|
801
801
|
}
|
|
802
802
|
declare function extractTokenUsageFromResponse(response: any): MistralTokenUsage | null;
|
|
803
803
|
|
|
804
|
+
/**
|
|
805
|
+
* Voice agents: the speech counterpart of the text agents. One agent per
|
|
806
|
+
* provider, chosen through `VoiceAgentFactory` — a caller asks for a provider
|
|
807
|
+
* and gets `speak()` / `transcribe()` without knowing which SDK or model is
|
|
808
|
+
* behind them. Agents are pure: no auth, tier or billing logic. Each result
|
|
809
|
+
* carries what the call produced and what it cost, and the host decides whom
|
|
810
|
+
* to bill.
|
|
811
|
+
*/
|
|
812
|
+
type VoiceProvider = 'openai' | 'google';
|
|
813
|
+
interface SpeechRequest {
|
|
814
|
+
text: string;
|
|
815
|
+
/** A voice id of this provider's set (e.g. OpenAI "onyx", Gemini "Kore"). */
|
|
816
|
+
voice: string;
|
|
817
|
+
/** Delivery direction: a short adverb ("mysteriously") or a longer sentence. */
|
|
818
|
+
voiceStyle?: string;
|
|
819
|
+
}
|
|
820
|
+
interface SpeechUsage {
|
|
821
|
+
/** OpenAI bills speech per input character. */
|
|
822
|
+
characters?: number;
|
|
823
|
+
/** Gemini bills speech per token: text prompt in, audio out. */
|
|
824
|
+
inputTokens?: number;
|
|
825
|
+
outputTokens?: number;
|
|
826
|
+
}
|
|
827
|
+
interface SpeechResult {
|
|
828
|
+
/** WAV audio (24 kHz mono 16-bit from Gemini; OpenAI's default WAV). */
|
|
829
|
+
audio: ArrayBuffer;
|
|
830
|
+
costUSD: number;
|
|
831
|
+
usage: SpeechUsage;
|
|
832
|
+
}
|
|
833
|
+
interface TranscriptionRequest {
|
|
834
|
+
audio: ArrayBuffer;
|
|
835
|
+
/** Container of the recording, e.g. "audio/webm" (browser MediaRecorder) or "audio/wav". */
|
|
836
|
+
mimeType?: string;
|
|
837
|
+
/** Whisper reads the container from the file name's extension. */
|
|
838
|
+
fileName?: string;
|
|
839
|
+
language?: string;
|
|
840
|
+
prompt?: string;
|
|
841
|
+
}
|
|
842
|
+
interface TranscriptionUsage {
|
|
843
|
+
/** Whisper bills per minute of audio. */
|
|
844
|
+
audioSeconds?: number;
|
|
845
|
+
/** Gemini bills per token: audio in (~25/s), text out. */
|
|
846
|
+
inputTokens?: number;
|
|
847
|
+
outputTokens?: number;
|
|
848
|
+
}
|
|
849
|
+
interface TranscriptionResult {
|
|
850
|
+
text: string;
|
|
851
|
+
/** Audio length; Gemini reports none, so it is derived from audio tokens. */
|
|
852
|
+
durationSeconds: number;
|
|
853
|
+
costUSD: number;
|
|
854
|
+
usage: TranscriptionUsage;
|
|
855
|
+
}
|
|
856
|
+
interface VoiceAgent {
|
|
857
|
+
readonly provider: VoiceProvider;
|
|
858
|
+
readonly ttsModel: string;
|
|
859
|
+
readonly sttModel: string;
|
|
860
|
+
speak(request: SpeechRequest): Promise<SpeechResult>;
|
|
861
|
+
transcribe(request: TranscriptionRequest): Promise<TranscriptionResult>;
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
/** Speech and transcription models behind each voice provider. */
|
|
865
|
+
declare const VOICE_MODEL_CONSTANTS: {
|
|
866
|
+
readonly OPENAI_TTS: "gpt-4o-mini-tts";
|
|
867
|
+
readonly OPENAI_STT: "whisper-1";
|
|
868
|
+
readonly GOOGLE_TTS: "gemini-3.1-flash-tts-preview";
|
|
869
|
+
readonly GOOGLE_STT: "gemini-3.5-transcribe";
|
|
870
|
+
};
|
|
871
|
+
declare const SUPPORTED_VOICE_PROVIDERS: readonly VoiceProvider[];
|
|
872
|
+
/** Which API key (by API_KEY_CONSTANTS name) a voice provider runs on. */
|
|
873
|
+
declare const VOICE_PROVIDER_API_KEY: Record<VoiceProvider, string>;
|
|
874
|
+
interface VoiceModelPricing {
|
|
875
|
+
/** OpenAI TTS: USD per 1M input characters. */
|
|
876
|
+
pricePerMillionCharacters?: number;
|
|
877
|
+
/** Whisper: USD per minute of audio. */
|
|
878
|
+
pricePerMinute?: number;
|
|
879
|
+
/** Gemini TTS: text prompt in, audio tokens out. */
|
|
880
|
+
textInputPricePerM?: number;
|
|
881
|
+
audioOutputPricePerM?: number;
|
|
882
|
+
/** Gemini Transcribe: audio tokens in, text tokens out. */
|
|
883
|
+
audioInputPricePerM?: number;
|
|
884
|
+
textOutputPricePerM?: number;
|
|
885
|
+
}
|
|
886
|
+
/** Prices as of 2026-09 (openai.com/api/pricing, ai.google.dev/gemini-api/docs/pricing). */
|
|
887
|
+
declare const VOICE_MODEL_PRICING: Record<string, VoiceModelPricing>;
|
|
888
|
+
|
|
889
|
+
interface TokenPairUsage {
|
|
890
|
+
inputTokens: number;
|
|
891
|
+
outputTokens: number;
|
|
892
|
+
}
|
|
893
|
+
/** OpenAI TTS: USD for `characterCount` input characters. */
|
|
894
|
+
declare function calculateOpenAiTtsCost(characterCount: number): number;
|
|
895
|
+
/** Whisper: USD for `durationSeconds` of audio. */
|
|
896
|
+
declare function calculateOpenAiSttCost(durationSeconds: number): number;
|
|
897
|
+
/** Gemini TTS: USD for text prompt tokens in and audio tokens out. */
|
|
898
|
+
declare function calculateGeminiTtsCost(usage: TokenPairUsage): number;
|
|
899
|
+
/** Gemini Transcribe: USD for audio tokens in and text tokens out. */
|
|
900
|
+
declare function calculateGeminiSttCost(usage: TokenPairUsage): number;
|
|
901
|
+
|
|
902
|
+
/** The voice counterpart of AgentFactory: provider in, agent out. */
|
|
903
|
+
declare class VoiceAgentFactory {
|
|
904
|
+
/** Build an agent from a key already resolved by the caller. */
|
|
905
|
+
static createAgent(provider: VoiceProvider, apiKey: string): VoiceAgent;
|
|
906
|
+
/**
|
|
907
|
+
* Build an agent from a key map (the shape AgentFactory takes), reading the
|
|
908
|
+
* provider's key by its API_KEY_CONSTANTS name. Throws when the key is missing
|
|
909
|
+
* so the host can report a misconfiguration before any SDK is touched.
|
|
910
|
+
*/
|
|
911
|
+
static createAgentFromKeys(provider: VoiceProvider, apiKeys: ApiKeyMap): VoiceAgent;
|
|
912
|
+
}
|
|
913
|
+
/** Function form of `VoiceAgentFactory.createAgent`. */
|
|
914
|
+
declare function createVoiceAgent(provider: VoiceProvider, apiKey: string): VoiceAgent;
|
|
915
|
+
|
|
916
|
+
/** gpt-4o-mini-tts (billed per character) + Whisper (billed per minute). */
|
|
917
|
+
declare class OpenAiVoiceAgent implements VoiceAgent {
|
|
918
|
+
private readonly apiKey;
|
|
919
|
+
readonly provider: "openai";
|
|
920
|
+
readonly ttsModel: "gpt-4o-mini-tts";
|
|
921
|
+
readonly sttModel: "whisper-1";
|
|
922
|
+
constructor(apiKey: string);
|
|
923
|
+
speak(request: SpeechRequest): Promise<SpeechResult>;
|
|
924
|
+
transcribe(request: TranscriptionRequest): Promise<TranscriptionResult>;
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
/** Gemini 3.1 Flash TTS + Gemini 3.5 Transcribe, both billed per token. */
|
|
928
|
+
declare class GoogleVoiceAgent implements VoiceAgent {
|
|
929
|
+
private readonly apiKey;
|
|
930
|
+
readonly provider: "google";
|
|
931
|
+
readonly ttsModel: "gemini-3.1-flash-tts-preview";
|
|
932
|
+
readonly sttModel: "gemini-3.5-transcribe";
|
|
933
|
+
constructor(apiKey: string);
|
|
934
|
+
speak(request: SpeechRequest): Promise<SpeechResult>;
|
|
935
|
+
transcribe(request: TranscriptionRequest): Promise<TranscriptionResult>;
|
|
936
|
+
}
|
|
937
|
+
|
|
938
|
+
type OpenAiTtsVoice = 'alloy' | 'echo' | 'fable' | 'onyx' | 'nova' | 'shimmer' | 'ash' | 'ballad' | 'coral' | 'sage';
|
|
939
|
+
interface OpenAiTtsAudioOptions {
|
|
940
|
+
voice?: OpenAiTtsVoice;
|
|
941
|
+
/** Delivery direction; gpt-4o-mini-tts follows it closely. */
|
|
942
|
+
instructions?: string;
|
|
943
|
+
speed?: number;
|
|
944
|
+
format?: 'mp3' | 'wav' | 'opus' | 'aac' | 'flac' | 'pcm';
|
|
945
|
+
}
|
|
946
|
+
/** Core OpenAI TTS call: text + API key in, audio bytes out (WAV by default). */
|
|
947
|
+
declare function generateOpenAiTtsAudio(text: string, apiKey: string, options?: OpenAiTtsAudioOptions): Promise<ArrayBuffer>;
|
|
948
|
+
|
|
949
|
+
interface OpenAiSttOptions {
|
|
950
|
+
language?: string;
|
|
951
|
+
prompt?: string;
|
|
952
|
+
temperature?: number;
|
|
953
|
+
/** Whisper detects the container format from the extension. */
|
|
954
|
+
fileName?: string;
|
|
955
|
+
mimeType?: string;
|
|
956
|
+
}
|
|
957
|
+
interface OpenAiSttResult {
|
|
958
|
+
text: string;
|
|
959
|
+
durationSeconds: number;
|
|
960
|
+
}
|
|
961
|
+
/** Core Whisper call: audio + API key in, transcript + duration out. */
|
|
962
|
+
declare function transcribeWithOpenAi(audioBuffer: ArrayBuffer, apiKey: string, options?: OpenAiSttOptions): Promise<OpenAiSttResult>;
|
|
963
|
+
|
|
964
|
+
interface GoogleTtsAudioOptions {
|
|
965
|
+
/** e.g. "Kore", "Puck" */
|
|
966
|
+
voiceName: string;
|
|
967
|
+
/** "mysteriously", "excitedly", or a longer direction */
|
|
968
|
+
voiceStyle?: string;
|
|
969
|
+
}
|
|
970
|
+
interface GoogleTtsResult {
|
|
971
|
+
/** WAV, 24 kHz mono 16-bit */
|
|
972
|
+
audio: ArrayBuffer;
|
|
973
|
+
/** text prompt tokens / audio tokens — what Gemini bills */
|
|
974
|
+
usage: {
|
|
975
|
+
inputTokens: number;
|
|
976
|
+
outputTokens: number;
|
|
977
|
+
};
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Gemini TTS has no instruction field: delivery is directed in the text itself
|
|
981
|
+
* ("Say cheerfully: Have a wonderful day!" in the docs). A short style (1-3
|
|
982
|
+
* words) becomes that "Say X:" prefix; a longer direction is used as written,
|
|
983
|
+
* ending in the colon that separates it from the line to read. The same style
|
|
984
|
+
* value feeds OpenAI's `instructions`, so one field serves both providers.
|
|
985
|
+
*/
|
|
986
|
+
declare function buildGoogleTtsPrompt(text: string, voiceStyle?: string): string;
|
|
987
|
+
/** Wraps raw 16-bit mono PCM in a WAV header. */
|
|
988
|
+
declare function pcmToWav(pcmData: Uint8Array, sampleRate?: number): ArrayBuffer;
|
|
989
|
+
/**
|
|
990
|
+
* Core Gemini TTS call: text + API key in, WAV + token usage out.
|
|
991
|
+
*
|
|
992
|
+
* Uses generateContent rather than the newer Interactions API the docs show:
|
|
993
|
+
* both serve the 3.1 TTS model (verified 2026-09-05), and this one is typed in
|
|
994
|
+
* the SDK and reports usageMetadata, which billing needs.
|
|
995
|
+
*/
|
|
996
|
+
declare function generateGoogleTtsAudio(text: string, apiKey: string, options: GoogleTtsAudioOptions): Promise<GoogleTtsResult>;
|
|
997
|
+
|
|
998
|
+
interface GoogleSttOptions {
|
|
999
|
+
/** Container of the recording; browsers record audio/webm. */
|
|
1000
|
+
mimeType?: string;
|
|
1001
|
+
}
|
|
1002
|
+
interface GoogleSttResult {
|
|
1003
|
+
text: string;
|
|
1004
|
+
/** Derived from audio tokens (~25/s) — Gemini reports no duration. */
|
|
1005
|
+
durationSeconds: number;
|
|
1006
|
+
/** audio tokens in, text tokens out — what Gemini bills */
|
|
1007
|
+
usage: {
|
|
1008
|
+
inputTokens: number;
|
|
1009
|
+
outputTokens: number;
|
|
1010
|
+
};
|
|
1011
|
+
}
|
|
1012
|
+
/** From the pricing page footnote: 25 audio tokens per second of input. */
|
|
1013
|
+
declare const GEMINI_AUDIO_TOKENS_PER_SECOND = 25;
|
|
1014
|
+
/**
|
|
1015
|
+
* Core Gemini transcription call: audio + API key in, transcript + usage out.
|
|
1016
|
+
*
|
|
1017
|
+
* Uses the Interactions API: with this model, generateContent returns the
|
|
1018
|
+
* transcript as a non-text part the SDK cannot surface (verified 2026-09-05).
|
|
1019
|
+
*/
|
|
1020
|
+
declare function transcribeWithGemini(audioBuffer: ArrayBuffer, apiKey: string, options?: GoogleSttOptions): Promise<GoogleSttResult>;
|
|
1021
|
+
|
|
804
1022
|
declare abstract class AbstractAgent {
|
|
805
1023
|
name: string;
|
|
806
1024
|
gameId?: string;
|
|
@@ -1202,4 +1420,4 @@ declare class MiniMaxAgent extends AbstractAgent {
|
|
|
1202
1420
|
doAskText(messages: AIMessage[]): Promise<[string, string, TokenUsage$1?, string?]>;
|
|
1203
1421
|
}
|
|
1204
1422
|
|
|
1205
|
-
export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleTokenUsage, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SupportedAiKeyNames, SupportedAiModels, type TokenUsage$1 as TokenUsage, ZodSchemaConverter, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, clampReasoningEffort, cleanResponse, createCatalog, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, validateResponse };
|
|
1423
|
+
export { type AIMessage, ANTHROPIC_REASONING_EFFORTS, API_KEY_CONSTANTS, AbstractAgent, type AgentActivityData, AgentFactory, type AgentLoggingConfig, type AnthropicReasoningEffort, type AnthropicTokenUsage, type ApiKeyMap, BotResponseError, CACHE_TIER_MARKER, ClaudeAgent, type CostCalculationOptions, DEEPSEEK_PEAK_SCHEDULE, DEEPSEEK_REASONING_EFFORTS, DEFAULT_LOGGING_CONFIG, DEFAULT_MAX_OUTPUT_TOKENS, type DeepSeekReasoningEffort, type DeepSeekTokenUsage, DeepSeekV2Agent, FUGU_REASONING_EFFORTS, FuguAgent, type FuguReasoningEffort, GEMINI_AUDIO_TOKENS_PER_SECOND, GEMINI_REASONING_EFFORTS, GLM_REASONING_EFFORTS, type GeminiReasoningEffort, GlmAgent, type GlmReasoningEffort, GoogleAgent, type GoogleSttOptions, type GoogleSttResult, type GoogleTokenUsage, type GoogleTtsAudioOptions, type GoogleTtsResult, GoogleVoiceAgent, Gpt5Agent, GrokAgent, type GrokTokenUsage, type JsonSchemaOptions, KimiAgent, type KimiTokenUsage, type LLMModel, LLM_CONSTANTS, type LlmLogger, type LoggingConfig, MESSAGE_ROLE, MODEL_PRICING, MiniMaxAgent, MistralAgent, type MistralTokenUsage, type Modality, ModelAuthenticationError, type ModelConfig, ModelError, ModelInvalidResponseError, ModelOverloadError, type ModelPricing, ModelQuotaExceededError, ModelRateLimitError, ModelRefusalError, type ModelTag, ModelUnavailableError, OPENAI_REASONING_EFFORTS, type OpenAIReasoningEffort, type OpenAITokenUsage, type OpenAiSttOptions, type OpenAiSttResult, type OpenAiTtsAudioOptions, type OpenAiTtsVoice, OpenAiVoiceAgent, type PeakPricing, type PricingUnit, type ProviderSchema, type TokenUsage as ProviderTokenUsage, type ProviderType, QwenAgent, REASONING_EFFORT_SCALE, type ReasoningEffort, SUPPORTED_VOICE_PROVIDERS, type SpeechRequest, type SpeechResult, type SpeechUsage, SupportedAiKeyNames, SupportedAiModels, type TokenPairUsage, type TokenUsage$1 as TokenUsage, type TranscriptionRequest, type TranscriptionResult, type TranscriptionUsage, VOICE_MODEL_CONSTANTS, VOICE_MODEL_PRICING, VOICE_PROVIDER_API_KEY, type VoiceAgent, VoiceAgentFactory, type VoiceModelPricing, type VoiceProvider, ZodSchemaConverter, buildGoogleTtsPrompt, calculateAnthropicCost, calculateCost, calculateDeepSeekCost, calculateGeminiSttCost, calculateGeminiTtsCost, calculateGoogleCost, calculateGrokCost, calculateKimiCost, calculateMistralCost, calculateModelCost, calculateOpenAICost, calculateOpenAiSttCost, calculateOpenAiTtsCost, clampReasoningEffort, cleanResponse, createCatalog, createVoiceAgent, extractAnthropicTokenUsage, extractTokenUsageFromResponse$2 as extractAnthropicTokenUsageFromResponse, extractDeepSeekTokenUsage, extractTokenUsageFromResponse$5 as extractDeepSeekTokenUsageFromResponse, extractFirstJsonObject, extractGoogleTokenUsage, extractTokenUsageFromResponse$1 as extractGoogleTokenUsageFromResponse, extractGrokTokenUsage, extractTokenUsageFromResponse$3 as extractGrokTokenUsageFromResponse, extractKimiTokenUsage, extractTokenUsageFromResponse$4 as extractKimiTokenUsageFromResponse, extractMistralTokenUsage, extractTokenUsageFromResponse as extractMistralTokenUsageFromResponse, extractOpenAITokenUsage, extractTokenUsageFromResponse$6 as extractOpenAITokenUsageFromResponse, extractTokenUsage, extractUsageAndCalculateCost, generateGoogleTtsAudio, generateOpenAiTtsAudio, generateSchemaInstructions, getModelConfigByApiName, getModelDisplayName, getModelProviderName, getModelTags, getProviderSignatureFields, isHybridThinkingModel, isInPeakWindow, isPeakBilling, isWeekendAt, logger, mergeThinking, modelHasTag, modelIsFast, needsPromptBasedSchema, parseAndValidateLlmJson, pcmToWav, safeValidateResponse, setLlmLogger, stableHashHex, stripInlineThinking, supportsNativeJsonSchema, toAnthropicEffort, toDeepSeekEffort, toFuguEffort, toGeminiEffort, toGlmEffort, toOpenAIEffort, transcribeWithGemini, transcribeWithOpenAi, validateResponse };
|