Typescript SDK Reference
Introduction
This document covers the design and developer experience of the TypeScript client library for Galileo. Here is the full Galileo TypeScript SDK (latest release).
Note: This library is in pre-release mode and may not be stable.
Installation
Initialization/Authentication
You can configure Galileo using environment variables:
In Node.js, you can use process.env
to specify these variables:
Logging
OpenAI Client Wrapper
The simplest way to get started is to use our OpenAI client wrapper. This example will automatically produce a single-span trace in the Logstream UI:
Log Function Wrapper
The log
function wrapper allows you to wrap functions with spans of different types. This is useful for creating workflow spans with nested LLM calls or tool spans.
Span Types
Here are the different span types:
- Workflow: A span that can have child spans, useful for nesting several child spans to denote a thread within a trace. If you wrap a parent function with
log
, calls that are made within that scope are automatically logged in the same trace. - Llm: Captures the input, output, and settings of an LLM call. This span gets automatically created when our client library wrappers (OpenAI and Anthropic) are used. Cannot have nested children.
- Retriever: Contains the output documents of a retrieval operation.
- Tool: Captures the input and output of a tool call. Used to decorate functions that are invoked as tools.
GalileoLogger
For more advanced use cases, you can use the GalileoLogger directly:
Prompts
Create and use a prompt template:
You can also use an existing template:
Datasets
Creating and Using Datasets
You can create and use datasets for experiments:
Experiments
Evaluating with Runner Function
You can use a runner function to run an experiment with a dataset:
Running an Experiment with a Prompt Template
Running an Experiment with Custom Dataset
You can also use a locally generated dataset with a runner function: