LLM architecture

Route. Observe. Test.
One stack, three distinct jobs.

LiteLLM handles model access. Langfuse explains what happened. Promptfoo checks whether the system behaves as expected. OpenTelemetry and OTLP connect their telemetry.

Side-by-side comparisonDirect OTLP exportProduction + evaluation flows
01 / Model gateway & SDK

LiteLLM

“How do we call and control our models?”

Primary jobProvide a common model API and route requests across providers.
Key functionality
  • Unified provider interface
  • Routing, retries and fallbacks
  • Gateway keys and access controls
  • Budgets, rate limits and spend tracking
Where it runsIn application code as an SDK, or between your app and providers as a proxy.
Main outputModel responses, usage information and request telemetry.
OTel / OTLP roleTrace producer. Its OpenTelemetry integration exports model-call spans to a backend such as Langfuse.
Choose it whenYou need shared model access, routing and operational controls.
02 / LLM observability

Langfuse

“What happened, and why?”

Primary jobRecord and inspect application traces, usage, cost and quality.
Key functionality
  • Nested traces and debugging
  • Latency, token and cost analysis
  • Prompt management and versioning
  • Datasets, experiments and evaluation scores
Where it runsA cloud or self-hosted backend; SDKs and instrumentation run inside your app.
Main outputTrace timelines, dashboards, prompts and evaluation records.
OTel / OTLP roleTrace receiver. Accepts OTLP over HTTP directly. Its SDKs create and export application spans.
Choose it whenYou need to understand real requests and monitor quality over time.
03 / Evaluation & red teaming

Promptfoo

“Does this pass our tests?”

Primary jobRun repeatable quality and security tests against prompts, models or apps.
Key functionality
  • Prompt and model comparisons
  • Assertions and grading
  • Regression tests in CI
  • Red-team attack scenarios
Where it runsA local or CI test runner, with a UI to inspect evaluation results.
Main outputPass/fail results, scores, comparisons and security findings.
OTel / OTLP roleTest-time trace receiver. Its built-in OTLP receiver links app traces to evaluations; trace-aware checks can inspect execution.
Choose it whenYou need measurable checks before shipping or after a change.
Shared telemetry foundation

OpenTelemetry + OTLP Supporting all three, with different roles

OpenTelemetry (OTel) provides APIs, SDKs and instrumentation to create spans and export telemetry.

OTLP is the protocol that transports that telemetry to a compatible receiver. Here, the diagrams focus on traces over HTTP.

Keep the connections separate: model requests use model or application APIs; traces use OTLP. W3C traceparent propagates trace identity between services. OTLP itself does not route model calls, execute tests or manage prompts.

How the pieces connect

Both Mermaid flows are shown below. Solid arrows carry requests and responses; dotted arrows carry telemetry.

Production: route requests, observe the whole application

Instrument the app for workflow spans and LiteLLM for gateway/model spans.

Your app / agentOTel SDK · workflow spans LiteLLM gatewayRouting · model-call spans Model providersOpenAI · Anthropic · others Model APIProvider API LangfuseDirect OTLP/HTTP ingestion App spans · OTLPModel spans · OTLPSame trace when context is propagated.Responses return along the request path.
Mermaid flow diagram source
flowchart TB
  A["Your app / agent"] <-->|"Model requests / responses"| L["LiteLLM gateway"]
  L <-->|"Provider requests / responses"| M["Model providers"]
  A -.->|"App spans · OTLP/HTTP"| F["Langfuse"]
  L -.->|"Model spans · OTLP/HTTP"| F
  classDef app fill:#f8fafc,stroke:#c7d2e2,color:#172438
  classDef lite fill:#eef4ff,stroke:#8aafe8,color:#172438
  classDef lang fill:#f5f0ff,stroke:#b79bdc,color:#172438
  class A,M app
  class L lite
  class F lang
Requests & responsesDirect telemetry export

Trace continuity: inject and extract traceparent between the app and gateway. Enable supported LiteLLM tracing. Gateway-only tracing covers model requests; app instrumentation adds retrieval, tools and business logic.

Evaluation: run tests and inspect the execution

Promptfoo exercises the same app path and receives traces through its built-in receiver.

Promptfoo runnerTests · assertions · gradingYour app / agentInstrumented with OTelLiteLLMModel gatewayModelsProvider APIsTest callAPIAPI Promptfoo trace receiverBuilt in · trace-aware evaluationsApp spans · OTLPModel spans · OTLPCorrelate tracewith test caseOptional second exporters:also send spans to Langfuse.
Mermaid flow diagram source
flowchart TB
  P["Promptfoo test runner"] <-->|"Test inputs / app outputs"| A["Your app / agent"]
  A <-->|"Model requests / responses"| L["LiteLLM gateway"]
  L <-->|"Provider requests / responses"| M["Model providers"]
  A -.->|"App spans · OTLP/HTTP"| R["Promptfoo built-in trace receiver"]
  L -.->|"Model spans · OTLP/HTTP"| R
  R -->|"Trace context for grading"| P
  classDef app fill:#f8fafc,stroke:#c7d2e2,color:#172438
  classDef lite fill:#eef4ff,stroke:#8aafe8,color:#172438
  classDef test fill:#edf8f5,stroke:#85beae,color:#172438
  class A,M app
  class L lite
  class P,R test
Test / model requests & responsesDirect telemetry exportTrace-to-test correlation

Enable Promptfoo tracing, start its built-in OTLP receiver and configure app/gateway exporters to reach it. Preserve the test's traceparent. To keep the same spans in Langfuse too, configure a second exporter in each emitting process; a single endpoint setting does not fan out.

Where functionality overlaps

Several features appear in more than one tool. Choose by the job you need to complete: serving model traffic, understanding production behavior, or testing a change. These are practical recommendations based on each tool's main workflow.

Shared areaHow the roles differGood fit — and why
Model access & comparisonLiteLLM provides shared model access and routing. Promptfoo runs the same test cases across models or prompts.LiteLLM for serving: centralize providers and fallbacks.
Promptfoo for selection: compare quality on repeatable examples before choosing a model.
Usage, cost & latencyLiteLLM tracks gateway spend and applies budgets or limits. Langfuse analyzes usage and timing across instrumented workflows. Promptfoo compares test results.LiteLLM for spend control: enforce policy in the request path.
Langfuse for diagnosis: connect cost and slow steps to real requests.
Promptfoo for benchmarks: compare changes under a common test workload.
Traces & debuggingLiteLLM emits gateway/model spans. Langfuse stores and explores application traces. Promptfoo connects traces to test cases.Langfuse for production debugging: inspect nested operations and failures over time.
Promptfoo for failing tests: use execution details in trace-aware checks.
LiteLLM for gateway visibility: see the model-call portion of the flow.
Quality evaluationsLangfuse offers datasets, experiments and scores alongside traces. Promptfoo offers assertions, grading and repeatable evaluation runs.Langfuse for a production feedback loop: keep quality evidence with observed behavior.
Promptfoo for regression checks: turn expected behavior into reproducible pass/fail tests in CI.
Prompt iterationLangfuse centrally stores and versions prompts. Promptfoo evaluates prompt alternatives.Langfuse for prompt lifecycle: manage versions and deployment labels, and link versions to traces.
Promptfoo for choosing wording: test candidate prompts against the same examples.
Security & safeguardsLiteLLM applies gateway access controls and can integrate runtime guardrails. Promptfoo generates adversarial tests and security findings.LiteLLM for runtime policy: control model access at the gateway.
Promptfoo for red teaming: probe failure modes and test safeguards with attack scenarios. Use both to enforce and test.
OTel / OTLP supportLiteLLM produces traces. Langfuse receives and analyzes them. Promptfoo can receive them during evaluations.OTLP for interoperability: transport spans in a shared format.
Langfuse for ongoing observability; Promptfoo for test-time evidence. Each uses the traces for a different purpose.
Start with LiteLLM

“We need reliable model access.”

Good when several applications or teams need common provider access, routing, budgets and controls.

Start with Langfuse

“We need to understand our app.”

Good when you need production traces, prompt versioning and quality analysis tied to real behavior.

Start with Promptfoo

“We need confidence in a change.”

Good when you need model comparisons, regression tests or repeatable security testing.

Use all three when you need the full loop: LiteLLM serves model traffic, Langfuse reveals production behavior, and Promptfoo tests improvements before release. A production failure can become a regression test; its trace helps explain why it failed.

Official documentation
LiteLLM request lifecycle ↗LiteLLM OpenTelemetry ↗Langfuse observability ↗Langfuse prompt management ↗Langfuse OTLP ↗Promptfoo overview ↗Promptfoo tracing ↗OpenTelemetry ↗