Integrations
DeepSeek
Trace DeepSeek calls in Muster via the OpenAI-compatible API.
The DeepSeek API is OpenAI-compatible. Trace it in Muster by pointing the Muster OpenAI wrapper at the DeepSeek base URL.
Setup
%pip install langfuse openai --upgradeimport os
os.environ["LANGFUSE_PUBLIC_KEY"] = "pk-lf-..."
os.environ["LANGFUSE_SECRET_KEY"] = "sk-lf-..."
os.environ["LANGFUSE_BASE_URL"] = "https://app.getmuster.io"
os.environ["DEEPSEEK_API_KEY"] = "sk-..."from langfuse.openai import OpenAI
from langfuse import observe
client = OpenAI(
base_url="https://api.deepseek.com",
api_key=os.environ["DEEPSEEK_API_KEY"],
)Basic chat completion
completion = client.chat.completions.create(
model="deepseek-chat",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Why is AI cool? Answer in 20 words or less."},
],
)
print(completion.choices[0].message.content)Wrap with @observe()
@observe()
def generate_story():
completion = client.chat.completions.create(
name="story-generator",
model="deepseek-chat",
messages=[
{"role": "system", "content": "You are a creative storyteller."},
{"role": "user", "content": "Tell me a short story about a curious robot."},
],
metadata={"genre": "adventure"},
)
return completion.choices[0].message.content
story = generate_story()