Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

🪢 Auto-generated Java Client for Langfuse API

License

NotificationsYou must be signed in to change notification settings

langfuse/langfuse-java

Repository files navigation

This repository contains an auto-generated Langfuse API client for Java based on ourAPI specification.See theLangfuse API reference for more details on the available endpoints.

Note: We recommend to solve tracing via theOpenTelemetry Instrumentation instead of using the Ingestion API directly. You can use theOpenTelemetry Java SDK and export spans to theLangfuse OTel endpoint.This allows for a more detailed and standardized tracing experience without the need to handle batching and updates internally.Check out ourSpring AI Example for more details.

Installation

The recommended way to install the langfuse-java API client is via Maven Central:

<dependency>    <groupId>com.langfuse</groupId>    <artifactId>langfuse-java</artifactId>    <version>0.1.0</version></dependency>

Usage

Instantiate the Langfuse Client with the respective endpoint and your API Keys.

importcom.langfuse.client.LangfuseClient;LangfuseClientclient =LangfuseClient.builder()        .url("https://cloud.langfuse.com")// 🇪🇺 EU data region// .url("https://us.cloud.langfuse.com") // 🇺🇸 US data region// .url("http://localhost:3000") // 🏠 Local deployment        .credentials("pk-lf-...","sk-lf-...")        .build();

Make requests using the clients:

importcom.langfuse.client.core.LangfuseClientApiException;importcom.langfuse.client.resources.prompts.types.PromptMetaListResponse;try {PromptMetaListResponseprompts =client.prompts().list();}catch (LangfuseClientApiExceptionerror) {System.out.println(error.getBody());System.out.println(error.getStatusCode());}

Drafting a Release

Run./mvnw release:prepare -DreleaseVersion= with the version you want to create.Push the changes including the tag.

Publishing to Maven Central

This project is configured to publish to Maven Central.To publish to Maven Central, you need to configure the following secrets in your GitHub repository:

  • OSSRH_USERNAME: Your Sonatype OSSRH username
  • OSSRH_PASSWORD: Your Sonatype OSSRH password
  • GPG_PRIVATE_KEY: Your GPG private key for signing artifacts
  • GPG_PASSPHRASE: The passphrase for your GPG private key

Updating

  1. Ensure that langfuse-java is placed in the same directory as the mainlangfuse repository.
  2. Setup a new Java fern generator using
       -name:fernapi/fern-java-sdkversion:2.20.1output:location:local-file-systempath:../../../../langfuse-java/src/main/java/com/langfuse/client/config:client-class-name:LangfuseClient
  3. Generate the new client code usingnpx fern-api generate --api server.
  4. Manually set thepackage across all files tocom.langfuse.client.
  5. Overwritethis.clientOptionsBuilder.addHeader("Authorization", "Bearer " + encodedToken); toBasic in LangfuseClientBuilder.java.
  6. Commit the changes in langfuse-java and push them to the repository.

[8]ページ先頭

©2009-2025 Movatter.jp