The Galileo TypeScript SDK (latest release) provides a comprehensive set of tools for logging, evaluating, and experimenting with LLM applications. It’s designed to be easy to use while providing powerful features for monitoring and improving your AI applications.

Visit the Galileo NPM package page for more installation options and version information.

Logging Methods

The TypeScript SDK allows you to log all prompts, responses, and statistics around your LLM usage. There are three main ways to log your application:

  1. Using a wrapper (Recommended) - Instead of importing LLM clients directly like openai, use Galileo’s wrapper which automatically logs everything with no other code changes required!
  2. Using the log function wrapper - By wrapping a function that calls an LLM with the log function wrapper, you can create workflow spans with nested LLM calls and tool spans.
  3. Directly using the GalileoLogger class (Manual) - For more advanced use cases, you can use the GalileoLogger directly to have full control over the logging process.

Regardless of which logging method you choose, you will need to initialize your API keys and install the Galileo SDK by following the steps below.

Installation

npm install galileo

Key Features

  • Logging: Capture LLM interactions, tool usage, and workflow execution
  • Experimentation: Run experiments to evaluate and improve your LLM applications
  • Datasets: Create and manage datasets for testing and evaluation
  • Prompts: Create, version, and test prompt templates

Getting Started

The simplest way to get started is to use our OpenAI client wrapper:

import { OpenAI } from "openai";
import { wrapOpenAI, flush, init } from "galileo";

// Initialize Galileo
init({
  projectName: "my-project",
  logStreamName: "development",
});

const openai = wrapOpenAI(new OpenAI({ apiKey: process.env.OPENAI_API_KEY }));

async function callOpenAI() {
  const response = await openai.chat.completions.create({
    model: "gpt-4o",
    messages: [{ content: "Say hello world!", role: "user" }],
  });

  // Flush logs before exiting
  await flush();

  return response;
}

// Call the function
callOpenAI();

Authentication

Make sure you have a Galileo API key and configure Galileo using environment variables:

# Scoped to an Organization
GALILEO_API_KEY=...

# Optional, set a default Project
GALILEO_PROJECT=...

# Optional, set a default Log Stream
GALILEO_LOG_STREAM=...

SDK Components

The Galileo TypeScript SDK consists of several components:

  • Wrappers: Easily integrate with popular LLM providers like OpenAI
  • Core Logging: Log LLM interactions, tool usage, and workflow execution
  • Experiments: Run experiments to evaluate and improve your LLM applications
  • Datasets: Create and manage datasets for testing and evaluation
  • Prompts: Create, version, and test prompt templates

Check out the individual component documentation for more details.