Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions components-mdx/get-started/js-openai-sdk.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
**Install package**
**Install packages**

Install the Langfuse OpenAI wrapper, the official OpenAI SDK, and the Langfuse OpenTelemetry integration required for tracing.

```sh
npm install @langfuse/openai
npm install @langfuse/openai @langfuse/otel
```

**Add credentials**
Expand Down
21 changes: 21 additions & 0 deletions components-mdx/setup-otel-js.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,27 @@ Install the OpenTelemetry SDK, which the Langfuse integration uses under the hoo
npm install @opentelemetry/sdk-node
```

**Configure OpenTelemetry environment variables**

Before initializing the SDK, you need to set up the OpenTelemetry exporter environment variables. These tell OpenTelemetry where to send the traces and how to authenticate with Langfuse.

Add the following environment variables to your `.env` file or environment:

```bash filename=".env"
OTEL_EXPORTER_OTLP_ENDPOINT="https://cloud.langfuse.com/api/public/otel" # 🇪🇺 EU region
# OTEL_EXPORTER_OTLP_ENDPOINT="https://us.cloud.langfuse.com/api/public/otel" # 🇺🇸 US region

OTEL_EXPORTER_OTLP_HEADERS="Authorization=Basic <base64_encoded_auth>"
```

To generate the base64 encoded authentication string, use the following command in your terminal:

```bash
echo -n "pk-lf-...:sk-lf-..." | base64
```

Replace `pk-lf-...` and `sk-lf-...` with your actual `LANGFUSE_PUBLIC_KEY` and `LANGFUSE_SECRET_KEY` values. Then replace `<base64_encoded_auth>` in the `OTEL_EXPORTER_OTLP_HEADERS` with the output from the command above.

Next is initializing the Node SDK. You can do that either in a dedicated instrumentation file or directly at the top of your main file.


Expand Down