Tracing and evaluation for OpenDunes requests with Langfuse — sent for you, or from your own code.
Langfuse is an open-source LLM observability platform that logs traces, measures quality, and tracks cost over time. Your OpenDunes requests reach it two ways.
Add Langfuse as a destination once, with a management key, and every request appears in your Langfuse project as a trace — model, provider, tokens, cost in DA, input and output, and the user and session_id you sent — with no change to your code:
curl https://opendunes.com/v1/observability/destinations \
-H "Authorization: Bearer $OPENDUNES_MANAGEMENT_KEY" \
-H "Content-Type: application/json" \
-d '{
"name": "Langfuse",
"type": "langfuse",
"config": { "publicKey": "pk-lf-…", "secretKey": "sk-lf-…" }
}'The settings — your region's or your own instance's address among them — are on the Langfuse destination page.
To shape the traces yourself, instrument your OpenDunes calls with the Langfuse SDK directly:
import os
from openai import OpenAI
from langfuse import Langfuse
from langfuse.decorators import observe, langfuse_context
langfuse = Langfuse(
public_key=os.environ["LANGFUSE_PUBLIC_KEY"],
secret_key=os.environ["LANGFUSE_SECRET_KEY"],
host=os.environ.get("LANGFUSE_HOST", "https://cloud.langfuse.com"),
)
client = OpenAI(
base_url="https://opendunes.com/v1",
api_key=os.environ["OPENDUNES_API_KEY"],
)
@observe(as_type="generation")
def ask(prompt: str, model: str = "anthropic/claude-sonnet-5") -> str:
langfuse_context.update_current_observation(
model=model,
input=prompt,
)
resp = client.chat.completions.create(
model=model,
messages=[{"role": "user", "content": prompt}],
)
text = resp.choices[0].message.content
langfuse_context.update_current_observation(
output=text,
usage={
"input": resp.usage.prompt_tokens,
"output": resp.usage.completion_tokens,
},
)
return text
result = ask("What are the official languages of Algeria?")
print(result)
langfuse.flush()import OpenAI from "openai";
import { Langfuse } from "langfuse";
const langfuse = new Langfuse({
publicKey: process.env.LANGFUSE_PUBLIC_KEY!,
secretKey: process.env.LANGFUSE_SECRET_KEY!,
});
const client = new OpenAI({
baseURL: "https://opendunes.com/v1",
apiKey: process.env.OPENDUNES_API_KEY,
});
const trace = langfuse.trace({ name: "chat" });
const generation = trace.generation({
name: "completion",
model: "google/gemini-2.5-pro",
input: [{ role: "user", content: "What is Tamazight?" }],
});
const resp = await client.chat.completions.create({
model: "google/gemini-2.5-pro",
messages: [{ role: "user", content: "What is Tamazight?" }],
});
generation.end({
output: resp.choices[0].message.content,
usage: {
input: resp.usage?.prompt_tokens,
output: resp.usage?.completion_tokens,
},
});
await langfuse.flushAsync();Langfuse can be self-hosted on your own infrastructure. Set LANGFUSE_HOST to your instance URL. This is useful for data residency requirements under Algeria's Law 18-07.