Novita AI 透過其與 Langfuse 的策略整合,徹底改變了 LLM 應用的開發。透過將 Novita AI 與 Langfuse 的監控能力相結合,開發者現在可以獲得一個全面的解決方案,用於部署和分析 AI 應用程式。本文展示了組織如何利用 Novita AI 與 OpenAI 相容的 API 端點,同時使用 Langfuse 強大的分析工具來簡化開發工作流程,並加速跨產業的創新。
什麼是 Langfuse?
Langfuse 是一個開源的 LLM 工程平台。它能幫助團隊協作開發、監控、評估和除錯 AI 應用程式。Langfuse 可以在幾分鐘內自行託管,並經過實戰考驗。
主要功能
- 高效能推論:Novita AI 利用 vLLM 創新的 PagedAttention 演算法,為大型語言模型提供最佳的推論能力。
- 雲端基礎設施: 該平台透過其可擴展的 GPU 雲端基礎設施,為開發者提供高效能運算資源的存取。
- 開源支援: Novita AI 積極支援開源生態系統,透過簡化 LLaMA 3.1 等模型的部署,促進技術創新。
- 開發者工具: 開發者可以透過 Novita AI 簡單的 API 結構和全面的基準測試工具,獲得更流暢的工作流程。
- 成本效益: 該平台提供經濟實惠且可靠的 GPU 雲端解決方案,用於高效建置和擴展 AI 應用程式。
- 企業整合: 組織可以利用 Novita AI 的基礎設施,在各個產業中建立和擴展突破性的 AI 應用程式。
前置需求
開始之前,請確保您已具備以下條件:
- Novita AI LLM API 金鑰:
- 造訪 Novita AI 網站並建立帳戶。
- 登入後,前往金鑰管理頁面產生您的 API 金鑰。此金鑰用於將 Novita AI 的模型連接到 Langfuse。
2. Langfuse 帳戶:
- 在 Langfuse 註冊一個帳戶,開始建置 AI 應用程式。

整合步驟
步驟 1:安裝相依套件
- 請確定您已安裝必要的 Python 套件。
pip install openai langfuse
步驟 2:設定環境變數
import os
# 從專案設定頁面取得您的金鑰
# 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
# 從專案設定頁面取得您的 Novita AI API 金鑰
os.environ["NOVITA_API_KEY"] = "..."
步驟 3:Langfuse OpenAI 直接取代
- 在此步驟中,我們使用原生的 OpenAI 直接取代,透過從 langfuse.openai 匯入 openai。
- 若要開始使用 Novita AI 搭配 OpenAI 的用戶端函式庫,請將您的 Novita AI API 金鑰傳遞給 api_key 選項,並將 base_url 變更為 https://api.novita.ai/v3/openai:
# 取代原本的 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",
)
注意: OpenAI 直接取代與低階 Langfuse Python SDK 以及 @observe() 裝飾器完全相容,可用於追蹤應用程式的所有部分。
步驟 4:執行範例
- 以下儲存格示範如何使用已追蹤的 OpenAI 用戶端呼叫 Novita AI 的聊天模型。所有 API 呼叫都會由 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.
步驟 5:在 Langfuse 中查看追蹤資訊
- 執行範例模型呼叫後,您可以在 Langfuse 中看到追蹤資訊。您會看到有關 Novita AI API 呼叫的詳細資訊,包括:
- 請求參數(模型、訊息、溫度等)
- 回應內容
- Token 使用統計
- 延遲指標

Langfuse 中的公開範例追蹤連結
有用的連結與資源
為了進一步增強您對 Langfuse 與 Novita AI 的理解與使用,請考慮探索以下有價值的資源:
結論
Novita AI 與 vLLM 已建立策略合作夥伴關係,透過尖端技術徹底改變了 AI 部署。該合作夥伴關係展現了兩家公司致力於推動開源 AI 技術,以及在整個開發生命週期中促進創新的承諾。
常見問題
Novita AI 的 API 結構是否與 Langfuse 的監控能力相容?
是的,Novita AI 提供簡單的 API 結構,非常適合實作 Langfuse 的可觀測性功能。
此整合是否適用於企業級 AI 應用程式?
是的,Novita AI 的基礎設施與 Langfuse 的監控能力相結合,專為幫助組織在各產業中高效擴展其 AI 解決方案而設計。
將 Novita AI 與 Langfuse 整合是否需要複雜的 API 修改?
不需要,Novita AI 的平台設計有簡單的 API 結構。
限時優惠
Novita AI 現提供推薦計畫,這對 Helicone 使用者來說是一項福利:如果有興趣,使用者可以分享他們的邀請連結/代碼,他們和推薦對象都將獲得 $20 的信用額度,可用於 DeepSeek R1 和 V3 API。
關於 Novita AI
Novita AI 是一個 AI 雲端平台,為開發者提供簡單的 API 以便輕鬆部署 AI 模型,同時也提供經濟實惠且可靠的 GPU 雲端,用於建置和擴展。
