UNPKG

@juspay/neurolink

Version:

The pipe layer of an AI nervous system: one interface connecting provider neurons to your application, across three inference types — generate, stream and decide. `decide` returns typed, calibrated judgements from a non-generative model (~400ms, ~$0.00002

54 lines (53 loc) • 2.23 kB
/** * Provider-specific token limit utilities * Provides safe maxTokens values based on provider and model capabilities */ import { PROVIDER_MAX_TOKENS } from "../core/constants.js"; /** * Get the safe maximum tokens for a provider and model */ export declare function getSafeMaxTokens(provider: keyof typeof PROVIDER_MAX_TOKENS | string, model?: string, requestedMaxTokens?: number): number | undefined; /** * Maximum output tokens supported by a given Anthropic Claude model. * * The native Vertex+Claude and native Anthropic message paths send `max_tokens` * straight to the Anthropic API, which returns 400 if the value exceeds the * model's published output ceiling. (The AI-SDK path clamps automatically; * these native paths do not.) This table lets those paths default to the * model's real ceiling — 64K for Sonnet/Haiku 4.x, 32K for Opus 4.x — instead of * the legacy 4096 that silently truncated large structured responses. * * Unknown identifiers fall back to a safe modern floor (8192). */ export declare function getClaudeMaxOutputTokens(model: string | undefined): number; /** * Resolve the `max_tokens` to send on a native Anthropic/Claude request: honour * the caller's value but clamp it to the model's published ceiling, and default * to that ceiling when the caller did not specify one. Prevents both silent * truncation (the legacy 4096 default) and 400s from over-large requests. */ export declare function resolveClaudeMaxTokens(model: string | undefined, requested?: number): number; /** * Validate if maxTokens is safe for a provider/model combination */ export declare function validateMaxTokens(provider: keyof typeof PROVIDER_MAX_TOKENS | string, model?: string, maxTokens?: number): { isValid: boolean; recommendedMaxTokens?: number; warning?: string; }; /** * Get provider-specific token limit recommendations */ export declare function getTokenLimitRecommendations(provider: string): { conservative: number; balanced: number; maximum: number; models: Record<string, number>; }; /** * Get all provider limits summary */ export declare function getAllProviderLimits(): Record<string, { default: number; models: Record<string, number>; }>;