import { AIErrorInfo } from './errorTypes.js'; export declare class BaseResult { success: boolean; startTime: Date; endTime: Date; errorMessage: string; exception: any; /** * Structured error information for better error handling and retry logic */ errorInfo?: AIErrorInfo; get timeElapsed(): number; constructor(success: boolean, startTime: Date, endTime: Date); } export declare class BaseParams { /** * Model name, required. */ model: string; /** * Model temperature, optional. */ temperature?: number; /** * Specifies the format that the model should output. Not all models support all formats. If not specified, the default is 'Any'. */ responseFormat?: 'Any' | 'Text' | 'Markdown' | 'JSON' | 'ModelSpecific'; /** * The standard response formats may not be sufficient for all models. This field allows for a model-specific response format to be specified. For this field to be used, responseFormat must be set to 'ModelSpecific'. */ modelSpecificResponseFormat?: any; /** * Model max output response tokens, optional. */ maxOutputTokens?: number; /** * Model max budget tokens that we may use for reasoning in reasoning models, optional. */ reasoningBudgetTokens?: number; /** * Optional seed for reproducible outputs. * Not all models support seeding, but when supported, using the same seed * with the same inputs should produce identical outputs. */ seed?: number; /** * Optional array of sequences where the model will stop generating further tokens. * The returned text will not contain the stop sequence. */ stopSequences?: string[]; } /** * Represents token usage and cost information for an AI model execution. * * This class tracks the number of tokens used in both the prompt (input) and * completion (output) phases of an AI model execution, along with optional * cost information when provided by the AI provider. * * @class ModelUsage * @since 2.43.0 */ export declare class ModelUsage { /** * Creates a new ModelUsage instance. * * @param {number} promptTokens - Number of tokens used in the prompt/input * @param {number} completionTokens - Number of tokens generated in the completion/output * @param {number} [cost] - Optional cost of the execution * @param {string} [costCurrency] - Optional currency code for the cost (e.g., 'USD', 'EUR', 'GBP') */ constructor(promptTokens: number, completionTokens: number, cost?: number, costCurrency?: string); /** * Number of UNCACHED ("net-new") input tokens — i.e. prompt/input tokens that were NOT served * from the provider's prompt cache. This is normalized to the SAME meaning across every provider * (uniform across all providers): cached tokens are never counted here. * * Provider adapters are responsible for normalizing into this shape: * - Anthropic already reports `input_tokens` excluding cached tokens → use as-is. * - OpenAI/Gemini/Groq/Cerebras/Fireworks include cached tokens in their prompt count → * subtract: promptTokens = prompt_tokens − cacheReadTokens (clamp at 0). * * The cache buckets ({@link cacheReadTokens}, {@link cacheWriteTokens}) are DISJOINT from this. * Total input the provider processed = {@link totalInputTokens}. */ promptTokens: number; /** * Number of tokens generated by the model in its response. * This represents the length of the model's output. */ completionTokens: number; /** * Optional cost of this execution. * The currency is specified in the costCurrency field. * Some providers (like Anthropic) provide this information directly in their API responses. */ cost?: number; /** * Optional ISO 4217 currency code for the cost field. * Examples: 'USD', 'EUR', 'GBP', 'JPY', etc. * If not specified when cost is provided, the currency is provider-specific. */ costCurrency?: string; /** * Optional queue time in milliseconds before the model started processing the request. * This is a provider-specific timing metric that may not be available from all providers. */ queueTime?: number; /** * Optional time in milliseconds for the model to ingest and process the prompt. * This is a provider-specific timing metric that may not be available from all providers. */ promptTime?: number; /** * Optional time in milliseconds for the model to generate the completion/response tokens. * This is a provider-specific timing metric that may not be available from all providers. */ completionTime?: number; /** * Number of input tokens served from the provider's prompt cache (a cache READ / hit). * These are billed at a steep discount versus normal input tokens (e.g. Anthropic ~0.1x, * OpenAI ~0.5x, Gemini ~0.1x) and are the primary source of prompt-caching savings. * * DISJOINT from {@link promptTokens} (which is uncached/net-new only) on EVERY provider — the * adapter normalizes to guarantee this. So `totalInputTokens = promptTokens + cacheReadTokens + * cacheWriteTokens` holds uniformly. * * Optional/additive: declared optional so existing object-literal `ModelUsage` construction * sites keep compiling. `new ModelUsage(...)` instances default it to 0; treat `undefined` as 0. */ cacheReadTokens?: number; /** * Number of input tokens written to the provider's prompt cache (a cache WRITE / creation). * Some providers charge a premium for cache writes (e.g. Anthropic ~1.25x normal input); * others (OpenAI, Gemini, Groq, Cerebras, Fireworks) do not bill/report writes separately, so * this stays 0. DISJOINT from {@link promptTokens} and {@link cacheReadTokens}. */ cacheWriteTokens?: number; /** * Total input tokens the provider processed: uncached ({@link promptTokens}) + cache reads + * cache writes. This is the figure to price at the input rate (until cache-aware per-bucket * pricing is added) and equals what the provider's native "prompt token" count was before * normalization. Use THIS (not promptTokens) for cost so cached tokens aren't dropped. */ get totalInputTokens(): number; /** * Total UNCACHED tokens for the call: uncached input ({@link promptTokens}) + completion. * * Deliberately EXCLUDES the cache buckets so the MemberJunction invariant * `TokensUsed === TokensPrompt + TokensCompletion` (enforced by AIPromptRun's CK_AIPromptRun_Tokens * constraint + generated validation) continues to hold once promptTokens is net-new. The full * token count INCLUDING cache is `totalInputTokens + completionTokens` — use {@link totalInputTokens} * for cost so cached tokens are still billed. * * @returns {number} promptTokens + completionTokens */ get totalTokens(): number; } /** * Base AI model class, used for everything else in the MemberJunction AI environment */ export declare abstract class BaseModel { private _apiKey; /** * Only sub-classes can access the API key */ protected get apiKey(): string; constructor(apiKey: string); } //# sourceMappingURL=baseModel.d.ts.map