Langfuse.HTTP (Langfuse v0.2.0)

View Source

HTTP client for Langfuse API.

This module handles all HTTP communication with the Langfuse API, including authentication, automatic retries with exponential backoff, and telemetry instrumentation.

Authentication

Requests are authenticated using HTTP Basic Auth with the configured public key and secret key.

Retries

Failed requests are automatically retried with exponential backoff. The base delay starts at 1 second and doubles with each attempt, capped at 30 seconds. Random jitter is added to prevent thundering herd.

Telemetry

HTTP requests emit telemetry events. See Langfuse.Telemetry for details.

This module is used internally by the SDK. For direct API access, use Langfuse.Client instead.

Summary

Types

HTTP response result.

Functions

Checks if the connection to Langfuse is working.

Makes a GET request to the Langfuse API.

Fetches a prompt from the prompts API.

Sends a batch of events to the ingestion API.

Makes a POST request to the Langfuse API.

Types

response()

@type response() :: {:ok, map()} | {:error, term()}

HTTP response result.

Functions

auth_check()

@spec auth_check() :: boolean()

Checks if the connection to Langfuse is working.

Makes a simple authenticated request to verify credentials are valid and the Langfuse server is reachable.

Returns true if the connection is successful, false otherwise.

get(path, params \\ [])

@spec get(
  String.t(),
  keyword()
) :: response()

Makes a GET request to the Langfuse API.

Returns {:error, :not_configured} if credentials are not set.

get_prompt(name, opts \\ [])

@spec get_prompt(
  String.t(),
  keyword()
) :: response()

Fetches a prompt from the prompts API.

Used internally by Langfuse.Prompt.

Options

  • :version - Specific version number
  • :label - Label to fetch (e.g., "production")
  • :resolve - Whether to resolve prompt dependencies before returning (defaults to true on server)

ingest(events)

@spec ingest([map()]) :: response()

Sends a batch of events to the ingestion API.

Used internally by Langfuse.Ingestion to flush event batches.

post(path, body)

@spec post(String.t(), map()) :: response()

Makes a POST request to the Langfuse API.

Returns {:error, :not_configured} if credentials are not set.