Skip to content

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]

673 B
Raw Blame
"use client";

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ApiError } from "@/lib/http/client";

const MAX_RETRIES = 3;

const isRetryable = (error: unknown): boolean => !(error instanceof ApiError) || error.status >= 500;

export const shouldRetry = (failureCount: number, error: unknown): boolean =>
  isRetryable(error) && failureCount < MAX_RETRIES;

export const queryClient = new QueryClient({ defaultOptions: { queries: { retry: shouldRetry } } });

export default function ReactQueryProvider({ children }: { children: React.ReactNode }) {
  return <QueryClientProvider client={queryClient}>{children}</QueryClientProvider>;
}