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]

798 B
Raw Blame
import { getProxyBaseUrl } from "@/components/networking";
import { useQuery } from "@tanstack/react-query";

export interface BlogPost {
  title: string;
  description: string;
  date: string;
  url: string;
  tags: string[];
}

export interface BlogPostsResponse {
  posts: BlogPost[];
}

async function fetchBlogPosts(): Promise<BlogPostsResponse> {
  const baseUrl = getProxyBaseUrl();
  const response = await fetch(`${baseUrl}/public/litellm_blog_posts`);
  if (!response.ok) {
    throw new Error(`Failed to fetch blog posts: ${response.statusText}`);
  }
  return response.json();
}

export const useBlogPosts = () => {
  return useQuery<BlogPostsResponse>({
    queryKey: ["blogPosts"],
    queryFn: fetchBlogPosts,
    staleTime: 60 * 60 * 1000,
    retry: 1,
    retryDelay: 0,
  });
};