Skip to main content

How to Configure Langfuse Observability for nanoinfra

nanoinfra can trace supported OpenAI-compatible provider calls through Langfuse's OpenAI SDK wrapper.

What you will build​

  • Langfuse installed in the same Python environment as nanoinfra
  • Langfuse environment variables set before startup
  • one traced nanoinfra model call

When to use this​

Use Langfuse when you need observability for model requests, latency, errors, cost, or prompt behavior during development or production operation.

Install​

Install nanoinfra and prove the agent works:

Quick Start ranks four install methods easiest first. This is the first of them. Use pip, Docker or a source checkout instead if you prefer, and come back here.

uv tool install nanoinfra
nanoinfra onboard --wizard
nanoinfra agent -m "Hello!"

Install Langfuse:

python -m pip install langfuse

Minimal working example​

Set credentials before starting nanoinfra:

export LANGFUSE_SECRET_KEY="sk-lf-..."
export LANGFUSE_PUBLIC_KEY="pk-lf-..."
export LANGFUSE_BASE_URL="https://cloud.langfuse.com"
nanoinfra agent -m "Hello!"

Production notes​

  • Langfuse is configured with environment variables, not config.json.
  • Start services from an environment that exports the same variables.
  • Add tracing after the provider works. Tracing is not the first setup step.
  • Native providers that do not use the OpenAI-compatible client path may not produce Langfuse OpenAI-wrapper traces.

Security notes​

  • Treat Langfuse projects as observability stores for sensitive prompts and outputs.
  • Use separate projects for personal, staging, and production traffic.
  • Keep Langfuse keys out of committed service files.

Troubleshooting​

  • If no traces appear, confirm the service process sees the environment variables.
  • Confirm the provider path is OpenAI-compatible.
  • Run one local nanoinfra agent -m "Hello!" call before debugging service logs.