The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
const PRECISION_FIELDS: ReadonlySet<string> = new Set(["tpm_limit", "rpm_limit", "max_budget"]);
const roundToPrecision = (value: number): number => {
const shifted = Number(`${Math.abs(value)}e2`);
if (!Number.isFinite(shifted)) {
return value;
}
const rounded = Number(`${Math.round(shifted)}e-2`);
return value < 0 ? -rounded : rounded;
};
export const applyBudgetPrecision = <TValues extends Record<string, unknown>>(formValues: TValues): TValues =>
Object.fromEntries(
Object.entries(formValues).map(([key, value]) => [
key,
PRECISION_FIELDS.has(key) && typeof value === "number" ? roundToPrecision(value) : value,
]),
) as TValues;