langfuse_client/client

HTTP client for a Langfuse project. Holds the base URL and API key pair used to authenticate against /api/public/* endpoints. Domain-specific modules (e.g. langfuse_client/score) drive the actual requests via send_get.

The pure pieces (types, new) compile on both the Erlang and JavaScript targets; the HTTP-issuing pieces are Erlang-only because they depend on gleam_httpc.

Types

Credentials and host for a Langfuse project.

pub type Client {
  Client(
    base_url: String,
    public_key: String,
    secret_key: String,
  )
}

Constructors

  • Client(base_url: String, public_key: String, secret_key: String)

Failure modes returned by send_get and its callers.

pub type Error {
  HttpError(String)
  BadStatus(status: Int, body: String)
  BadUrl(String)
  DecodeError(json.DecodeError)
}

Constructors

  • HttpError(String)

    Transport-level failure (DNS, TCP, TLS, etc.) — body is the underlying error inspected as a string so the type stays target-agnostic.

  • BadStatus(status: Int, body: String)

    Langfuse returned a non-2xx status.

  • BadUrl(String)

    Could not assemble a valid request URL from base_url <> path.

  • DecodeError(json.DecodeError)

    Response body did not match the expected JSON shape.

Values

pub fn new(
  base_url base_url: String,
  public_key public_key: String,
  secret_key secret_key: String,
) -> Client

Build a client. Trailing slashes on base_url are stripped so callers can pass either form.

Search Document