Using Langfuse with Novita AI: A Comprehensive Guide

Using Langfuse with Novita AI

Novita AI has revolutionized LLM application development through its strategic integration with Langfuse. By combining Novita AI with Langfuse’s monitoring capabilities, developers now have access to a comprehensive solution for deploying and analyzing AI applications. This article demonstrates how organizations can harness Novita AI’s OpenAI-compatible API endpoints while utilizing Langfuse’s powerful analytics tools to streamline their development workflow and accelerate innovation across industries.

What is Langfuse?

Langfuse is an open-source LLM engineering platform. It helps teams collaboratively develop, monitor, evaluate, and debug AI applications. Langfuse can be self-hosted in minutes and is battle-tested.

Key Features

  1. High-Performance Inference: Novita AI leverages vLLM’s innovative PagedAttention algorithm to deliver optimized inference capabilities for large language models.
  2. Cloud Infrastructure: The platform provides developers with access to high-performance compute resources through its scalable GPU cloud infrastructure.
  3. Open-Source Support: Novita AI actively supports the open-source ecosystem by enabling easy deployment of models like LLaMA 3.1 and fostering technological innovation.
  4. Developer Tools: Developers benefit from a streamlined workflow through Novita AI’s simple API structure and comprehensive benchmarking tools.
  5. Cost Efficiency: The platform offers an affordable and reliable GPU cloud solution for building and scaling AI applications efficiently.
  6. Enterprise Integration: Organizations can leverage Novita AI’s infrastructure to create and scale groundbreaking AI applications across various industries.

Prerequisites

Before you begin, make sure you have the following:

1. Novita AI LLM API Key:

  • Visit Novita AI’s website and create an account.
  • After logging in, go to the Key Management page to generate your API Key. This key is required to connect Novita AI’s models to Langfuse.

2. Langfuse Account:

  • Sign up for a Langfuse account at Langfuse to start building AI applications.

Integration Steps

Step 1: Install Dependencies

  • Make sure you have installed the necessary Python packages.
pip install openai langfuse

Step 2: Set Up Environment Variables

import os

# Get keys for your project from the project settings page
# https://cloud.langfuse.com

os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-..." # DOCS EXAMPLE KEYS
os.environ["LANGFUSE_SECRET_KEY"] = "sk-..." # DOCS EXAMPLE KEYS
os.environ["LANGFUSE_HOST"] = "https://cloud.langfuse.com" # 🇪🇺 EU region
# os.environ["LANGFUSE_HOST"] = "https://us.cloud.langfuse.com" # 🇺🇸 US region


# Get your Novita AI API key from the project settings page
os.environ["NOVITA_API_KEY"] = "..."

Step 3: Langfuse OpenAI drop-in Replacement

# instead of import openai:
from langfuse.openai import openai

client = openai.OpenAI(
  api_key=os.environ.get("NOVITA_API_KEY"),
  base_url="https://api.novita.ai/v3/openai",
)

Note: The OpenAI drop-in replacement is fully compatible with the Low-Level Langfuse Python SDKs and @observe() decorator to trace all parts of your application.

Step 4: Run An Example

  • The following cell demonstrates how to call Novita AI’s chat model using the traced OpenAI client. All API calls will be automatically traced by Langfuse.
client = openai.OpenAI(
  api_key=os.environ.get("NOVITA_API_KEY"),
  base_url="https://api.novita.ai/v3/openai",
)

response = client.chat.completions.create(
  model="meta-llama/llama-3.1-70b-instruct",
  messages=[
    {"role": "system", "content": "Act like you are a helpful assistant."},
    {"role": "user", "content": "What are the famous attractions in San Francisco?"},
  ]
)

print(response.choices[0].message.content)
San Francisco, one of the most iconic cities in the world, is home to a plethora of famous attractions that cater to all interests and ages. Here are some of the most popular attractions in San Francisco:

1. **Golden Gate Bridge**: An engineering marvel and a symbol of San Francisco, the Golden Gate Bridge is a must-visit attraction. Take a walk or bike ride across the bridge for spectacular views of the city and the Bay.
2. **Alcatraz Island**: Explore the infamous former prison turned national park, which once housed notorious inmates like Al Capone. Take a ferry to the island and enjoy a guided tour of the prison and its surroundings.
3. **Fisherman's Wharf**: A bustling waterfront district, Fisherman's Wharf is famous for its seafood restaurants, street performers, and stunning views of the Bay Bridge and Alcatraz Island. Don't miss the sea lions at Pier 39!
4. **Chinatown**: San Francisco's Chinatown is one of the largest and oldest in the United States. Explore the colorful streets, try some authentic Chinese cuisine, and shop for unique souvenirs.
5. **Golden Gate Park**: A sprawling urban park that's home to several attractions, including the de Young Museum, the California Academy of Sciences, and the Japanese Tea Garden.
6. **Cable Cars**: A classic San Francisco experience, the cable cars offer a fun and historic way to explore the city. Take a ride on the Powell-Mason line to Fisherman's Wharf, or the Powell-Hyde line to Lombard Street.
7. **Lombard Street**: Known as the "crookedest street in the world," Lombard Street is a scenic and winding road that offers stunning views of the city.
8. **Union Square**: A vibrant public square in the heart of the city, Union Square is surrounded by shopping, dining, and entertainment options. Catch a show at the historic Curran Theatre or take a stroll through the square.
9. **The Painted Ladies**: A row of colorful Victorian houses on Alamo Square, the Painted Ladies are a iconic symbol of San Francisco's architecture. Take a photo in front of these stunning homes.
10. **The Exploratorium**: A museum of science, art, and human perception, the Exploratorium is a great place to learn and have fun. With interactive exhibits and stunning views of the Bay, it's a must-visit for families and science enthusiasts.
11. **Pier 39**: A popular shopping and dining destination, Pier 39 offers stunning views of the Bay Bridge, Alcatraz Island, and the sea lions that call the pier home.
12. **The de Young Museum**: A fine arts museum located in Golden Gate Park, the de Young Museum features a diverse collection of art and cultural exhibitions from around the world.

These are just a few of the many famous attractions in San Francisco. Whether you're interested in history, culture, science, or entertainment, San Francisco has something for everyone.

Step 5: See Traces in Langfuse

  • After running the example model call, you can see the traces in Langfuse. You will see detailed information about your Novita AI API calls, including:
    • Request parameters (model, messages, temperature, etc.)
    • Response content
    • Token usage statistics
    • Latency metrics

To further enhance your understanding and usage of Langfuse with Novita AI, consider exploring these valuable resources:

Conclusion

Novita AI and vLLM have formed a strategic partnership that revolutionizes AI deployment through cutting-edge technology. The partnership demonstrates both companies’ commitment to advancing open-source AI technology and fostering innovation throughout the entire development lifecycle.

Frequently Asked Questions

Is Novita AI’s API structure compatible with Langfuse’s monitoring capabilities?

Yes, Novita AI provides a simple API structure which makes it ideal for implementing Langfuse’s observability features.

Is the integration suitable for enterprise-scale AI applications?

Yes, the combination of Novita AI’s infrastructure and Langfuse’s monitoring capabilities is specifically designed to help organizations scale their AI solutions efficiently across industries.

Does integrating Novita AI with Langfuse require complex API modifications?


No, Novita AI’s platform is designed with a simple API structure.

Limited-time Offer

Novita AI now offers a Referral Program which can be a benefit for Helicone users: If someone is interested, users can share their invitation link/code, and both they and their referrals will receive $20 in credits to use with the DeepSeek R1 & V3 APIs.

About Novita AI

Novita AI is an AI cloud platform that offers developers an easy way to deploy AI models using our simple API, while also providing an affordable and reliable GPU cloud for building and scaling.


Discover more from Novita

Subscribe to get the latest posts sent to your email.

Leave a Comment

Scroll to Top

Discover more from Novita

Subscribe now to keep reading and get access to the full archive.

Continue reading