langfuse

package
v0.4.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 27, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package langfuse provides a Go SDK for Langfuse, an open-source LLM observability platform.

Langfuse uses a batch ingestion API and supports OpenTelemetry-compatible trace export.

Usage:

client, err := langfuse.NewClient(
	langfuse.WithPublicKey("pk-..."),
	langfuse.WithSecretKey("sk-..."),
)
if err != nil {
	log.Fatal(err)
}
defer client.Close()

ctx, trace, _ := client.StartTrace(ctx, "my-trace")
defer trace.End(ctx)

Index

Constants

View Source
const (
	DefaultEndpoint = "https://cloud.langfuse.com"
	USEndpoint      = "https://us.cloud.langfuse.com"
	HIPAAEndpoint   = "https://hipaa.cloud.langfuse.com"
	LocalEndpoint   = "http://localhost:3000"
)

Default endpoints

View Source
const (
	EventTypeTraceCreate      = "trace-create"
	EventTypeSpanCreate       = "span-create"
	EventTypeSpanUpdate       = "span-update"
	EventTypeGenerationCreate = "generation-create"
	EventTypeGenerationUpdate = "generation-update"
	EventTypeScoreCreate      = "score-create"
	EventTypeEventCreate      = "event-create"
)

Event types for batch ingestion.

View Source
const Version = "0.1.0"

Version is the SDK version.

Variables

View Source
var (
	ErrMissingPublicKey   = errors.New("langfuse: missing public key")
	ErrMissingSecretKey   = errors.New("langfuse: missing secret key")
	ErrNoActiveTrace      = errors.New("langfuse: no active trace in context")
	ErrNoActiveSpan       = errors.New("langfuse: no active span in context")
	ErrNoActiveGeneration = errors.New("langfuse: no active generation in context")
	ErrTraceNotFound      = errors.New("langfuse: trace not found")
	ErrDatasetNotFound    = errors.New("langfuse: dataset not found")
	ErrPromptNotFound     = errors.New("langfuse: prompt not found")
)

Sentinel errors.

Functions

func ContextWithClient

func ContextWithClient(ctx context.Context, client *Client) context.Context

ContextWithClient returns a new context with the client attached.

func ContextWithGeneration

func ContextWithGeneration(ctx context.Context, gen *Generation) context.Context

ContextWithGeneration returns a new context with the generation attached.

func ContextWithSpan

func ContextWithSpan(ctx context.Context, span *Span) context.Context

ContextWithSpan returns a new context with the span attached.

func ContextWithTrace

func ContextWithTrace(ctx context.Context, trace *Trace) context.Context

ContextWithTrace returns a new context with the trace attached.

func CurrentSpanID

func CurrentSpanID(ctx context.Context) string

CurrentSpanID returns the current span ID from context.

func CurrentTraceID

func CurrentTraceID(ctx context.Context) string

CurrentTraceID returns the current trace ID from context.

func EndGeneration

func EndGeneration(ctx context.Context, opts ...GenerationOption) error

EndGeneration ends the current generation in context.

func EndSpan

func EndSpan(ctx context.Context, opts ...SpanOption) error

EndSpan ends the current span in context.

func EndTrace

func EndTrace(ctx context.Context, opts ...TraceOption) error

EndTrace ends the current trace in context.

func IsNotFound

func IsNotFound(err error) bool

IsNotFound returns true if the error is a not found error.

func IsRateLimited

func IsRateLimited(err error) bool

IsRateLimited returns true if the error is a rate limit error.

func IsUnauthorized

func IsUnauthorized(err error) bool

IsUnauthorized returns true if the error is an authentication error.

Types

type APIError

type APIError struct {
	StatusCode int
	Message    string
	Details    map[string]any
}

APIError represents an error from the Langfuse API.

func (*APIError) Error

func (e *APIError) Error() string

type BatchIngestionRequest

type BatchIngestionRequest struct {
	Batch    []Event        `json:"batch"`
	Metadata map[string]any `json:"metadata,omitempty"`
}

BatchIngestionRequest is the request body for batch ingestion.

type Client

type Client struct {
	// contains filtered or unexported fields
}

Client is the main Langfuse client.

func ClientFromContext

func ClientFromContext(ctx context.Context) *Client

ClientFromContext returns the client from the context, or nil if none.

func NewClient

func NewClient(opts ...Option) (*Client, error)

NewClient creates a new Langfuse client.

func (*Client) Close

func (c *Client) Close() error

Close flushes pending events and closes the client.

func (*Client) CreateDataset

func (c *Client) CreateDataset(ctx context.Context, name string, opts ...DatasetOption) (*Dataset, error)

CreateDataset creates a new dataset.

func (*Client) CreateDatasetItem

func (c *Client) CreateDatasetItem(ctx context.Context, datasetName string, item DatasetItem) (*DatasetItem, error)

CreateDatasetItem creates an item in a dataset.

func (*Client) CreateDatasetRun

func (c *Client) CreateDatasetRun(ctx context.Context, datasetName, runName string, opts ...DatasetRunOption) (*DatasetRun, error)

CreateDatasetRun creates a dataset run (experiment).

func (*Client) Flush

func (c *Client) Flush(ctx context.Context) error

Flush sends all pending events to Langfuse.

func (*Client) GetDataset

func (c *Client) GetDataset(ctx context.Context, name string) (*Dataset, error)

GetDataset retrieves a dataset by name.

func (*Client) GetDatasetItems

func (c *Client) GetDatasetItems(ctx context.Context, datasetName string, limit, page int) ([]DatasetItem, error)

GetDatasetItems retrieves items from a dataset.

func (*Client) GetDatasetRuns

func (c *Client) GetDatasetRuns(ctx context.Context, datasetName string, limit, page int) ([]DatasetRun, error)

GetDatasetRuns retrieves runs for a dataset.

func (*Client) LinkTraceToDatasetItem

func (c *Client) LinkTraceToDatasetItem(ctx context.Context, datasetItemID, traceID string, runName string, observationID string) error

LinkTraceToDatasetItem links a trace to a dataset item for a run.

func (*Client) ListDatasets

func (c *Client) ListDatasets(ctx context.Context, limit, page int) ([]Dataset, error)

ListDatasets lists datasets with pagination.

func (*Client) StartTrace

func (c *Client) StartTrace(ctx context.Context, name string, opts ...TraceOption) (context.Context, *Trace, error)

StartTrace creates a new trace.

type Dataset

type Dataset struct {
	ID          string         `json:"id"`
	Name        string         `json:"name"`
	Description string         `json:"description,omitempty"`
	Metadata    map[string]any `json:"metadata,omitempty"`
	CreatedAt   time.Time      `json:"createdAt"`
	UpdatedAt   time.Time      `json:"updatedAt"`
}

Dataset represents a dataset.

type DatasetItem

type DatasetItem struct {
	ID                  string         `json:"id"`
	DatasetID           string         `json:"datasetId"`
	Input               any            `json:"input,omitempty"`
	ExpectedOutput      any            `json:"expectedOutput,omitempty"`
	Metadata            map[string]any `json:"metadata,omitempty"`
	SourceTraceID       string         `json:"sourceTraceId,omitempty"`
	SourceObservationID string         `json:"sourceObservationId,omitempty"`
	Status              string         `json:"status,omitempty"` // ACTIVE, ARCHIVED
	CreatedAt           time.Time      `json:"createdAt"`
	UpdatedAt           time.Time      `json:"updatedAt"`
}

DatasetItem represents an item in a dataset.

type DatasetOption

type DatasetOption func(*datasetConfig)

DatasetOption configures dataset creation.

func WithDatasetDescription

func WithDatasetDescription(desc string) DatasetOption

WithDatasetDescription sets the dataset description.

func WithDatasetMetadata

func WithDatasetMetadata(metadata map[string]any) DatasetOption

WithDatasetMetadata sets dataset metadata.

type DatasetRun

type DatasetRun struct {
	ID        string         `json:"id"`
	Name      string         `json:"name"`
	DatasetID string         `json:"datasetId"`
	Metadata  map[string]any `json:"metadata,omitempty"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
}

DatasetRun represents a dataset run (experiment).

type DatasetRunItem

type DatasetRunItem struct {
	ID            string    `json:"id"`
	DatasetRunID  string    `json:"datasetRunId"`
	DatasetItemID string    `json:"datasetItemId"`
	TraceID       string    `json:"traceId"`
	ObservationID string    `json:"observationId,omitempty"`
	CreatedAt     time.Time `json:"createdAt"`
}

DatasetRunItem represents an item in a dataset run.

type DatasetRunOption

type DatasetRunOption func(*datasetRunConfig)

DatasetRunOption configures dataset run creation.

func WithRunMetadata

func WithRunMetadata(metadata map[string]any) DatasetRunOption

WithRunMetadata sets the run metadata.

type Event

type Event struct {
	ID        string    `json:"id"`
	Type      string    `json:"type"`
	Timestamp time.Time `json:"timestamp"`
	Body      any       `json:"body"`
}

Event represents a single event in the batch.

type Generation

type Generation struct {
	// contains filtered or unexported fields
}

Generation represents an LLM generation (call) within a trace.

func GenerationFromContext

func GenerationFromContext(ctx context.Context) *Generation

GenerationFromContext returns the generation from the context, or nil if none.

func StartGeneration

func StartGeneration(ctx context.Context, name string, opts ...GenerationOption) (context.Context, *Generation, error)

StartGeneration starts a generation from the current context.

func (*Generation) End

func (g *Generation) End(ctx context.Context, opts ...GenerationOption) error

End ends the generation.

func (*Generation) EndTime

func (g *Generation) EndTime() *time.Time

EndTime returns the end time.

func (*Generation) ID

func (g *Generation) ID() string

ID returns the generation ID.

func (*Generation) MarkCompletionStart

func (g *Generation) MarkCompletionStart()

MarkCompletionStart marks when the first token was received (for streaming).

func (*Generation) Model

func (g *Generation) Model() string

Model returns the model name.

func (*Generation) Name

func (g *Generation) Name() string

Name returns the generation name.

func (*Generation) ParentSpanID

func (g *Generation) ParentSpanID() string

ParentSpanID returns the parent span ID.

func (*Generation) Score

func (g *Generation) Score(ctx context.Context, name string, value float64, opts ...ScoreOption) error

Score adds a score to the generation.

func (*Generation) SetOutput

func (g *Generation) SetOutput(output any) error

SetOutput sets the generation output.

func (*Generation) SetUsage

func (g *Generation) SetUsage(promptTokens, completionTokens, totalTokens int) error

SetUsage sets token usage.

func (*Generation) StartTime

func (g *Generation) StartTime() time.Time

StartTime returns the start time.

func (*Generation) TraceID

func (g *Generation) TraceID() string

TraceID returns the parent trace ID.

func (*Generation) Update

func (g *Generation) Update(ctx context.Context, opts ...GenerationOption) error

Update updates the generation.

type GenerationBody

type GenerationBody struct {
	ID                  string         `json:"id"`
	TraceID             string         `json:"traceId"`
	ParentObservationID string         `json:"parentObservationId,omitempty"`
	Name                string         `json:"name,omitempty"`
	StartTime           time.Time      `json:"startTime"`
	EndTime             *time.Time     `json:"endTime,omitempty"`
	CompletionStartTime *time.Time     `json:"completionStartTime,omitempty"`
	Model               string         `json:"model,omitempty"`
	ModelParameters     map[string]any `json:"modelParameters,omitempty"`
	Input               any            `json:"input,omitempty"`
	Output              any            `json:"output,omitempty"`
	Metadata            map[string]any `json:"metadata,omitempty"`
	Usage               *Usage         `json:"usage,omitempty"`
	Level               string         `json:"level,omitempty"`
	PromptName          string         `json:"promptName,omitempty"`
	PromptVersion       int            `json:"promptVersion,omitempty"`
	StatusMessage       string         `json:"statusMessage,omitempty"`
}

GenerationBody represents the body of a generation event (LLM call).

type GenerationOption

type GenerationOption func(*generationConfig)

GenerationOption configures generation creation.

func WithCompletionStart

func WithCompletionStart(t time.Time) GenerationOption

WithCompletionStart sets the completion start time.

func WithGenerationInput

func WithGenerationInput(input any) GenerationOption

WithGenerationInput sets generation input.

func WithGenerationMetadata

func WithGenerationMetadata(metadata map[string]any) GenerationOption

WithGenerationMetadata sets generation metadata.

func WithGenerationOutput

func WithGenerationOutput(output any) GenerationOption

WithGenerationOutput sets generation output.

func WithModel

func WithModel(model string) GenerationOption

WithModel sets the model name.

func WithModelParameters

func WithModelParameters(params map[string]any) GenerationOption

WithModelParameters sets model parameters.

func WithPromptName

func WithPromptName(name string) GenerationOption

WithPromptName sets the prompt name.

func WithPromptVersion

func WithPromptVersion(version int) GenerationOption

WithPromptVersion sets the prompt version.

func WithUsage

func WithUsage(promptTokens, completionTokens, totalTokens int) GenerationOption

WithUsage sets token usage.

type Observation

type Observation struct {
	ID            string         `json:"id"`
	TraceID       string         `json:"traceId"`
	Type          string         `json:"type"` // SPAN, GENERATION, EVENT
	Name          string         `json:"name"`
	StartTime     time.Time      `json:"startTime"`
	EndTime       *time.Time     `json:"endTime,omitempty"`
	Model         string         `json:"model,omitempty"`
	Input         any            `json:"input,omitempty"`
	Output        any            `json:"output,omitempty"`
	Metadata      map[string]any `json:"metadata,omitempty"`
	Usage         *Usage         `json:"usage,omitempty"`
	Level         string         `json:"level,omitempty"`
	PromptName    string         `json:"promptName,omitempty"`
	PromptVersion int            `json:"promptVersion,omitempty"`
}

Observation represents an observation from the API.

type Option

type Option func(*Client)

Option configures the client.

func WithBatchSize

func WithBatchSize(size int) Option

WithBatchSize sets the batch size for event ingestion.

func WithDebug

func WithDebug(debug bool) Option

WithDebug enables debug mode.

func WithDisabled

func WithDisabled(disabled bool) Option

WithDisabled disables tracing.

func WithEndpoint

func WithEndpoint(endpoint string) Option

WithEndpoint sets the Langfuse API endpoint.

func WithFlushPeriod

func WithFlushPeriod(period time.Duration) Option

WithFlushPeriod sets the flush interval for batched events.

func WithHTTPClient

func WithHTTPClient(client *http.Client) Option

WithHTTPClient sets a custom HTTP client.

func WithPublicKey

func WithPublicKey(key string) Option

WithPublicKey sets the Langfuse public key.

func WithSecretKey

func WithSecretKey(key string) Option

WithSecretKey sets the Langfuse secret key.

func WithTimeout

func WithTimeout(timeout time.Duration) Option

WithTimeout sets the request timeout.

type PaginatedResponse

type PaginatedResponse[T any] struct {
	Data []T            `json:"data"`
	Meta PaginationMeta `json:"meta"`
}

PaginatedResponse is a generic paginated response.

type PaginationMeta

type PaginationMeta struct {
	Page       int `json:"page"`
	Limit      int `json:"limit"`
	TotalItems int `json:"totalItems"`
	TotalPages int `json:"totalPages"`
}

PaginationMeta contains pagination metadata.

type Project

type Project struct {
	ID        string    `json:"id"`
	Name      string    `json:"name"`
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Project represents a project.

type Prompt

type Prompt struct {
	ID        string         `json:"id"`
	Name      string         `json:"name"`
	Version   int            `json:"version"`
	Template  string         `json:"prompt"` // The actual template content
	Config    map[string]any `json:"config,omitempty"`
	Labels    []string       `json:"labels,omitempty"`
	Tags      []string       `json:"tags,omitempty"`
	IsActive  bool           `json:"isActive,omitempty"`
	CreatedAt time.Time      `json:"createdAt"`
	UpdatedAt time.Time      `json:"updatedAt"`
}

Prompt represents a prompt template.

type Score

type Score struct {
	ID            string    `json:"id"`
	TraceID       string    `json:"traceId"`
	ObservationID string    `json:"observationId,omitempty"`
	Name          string    `json:"name"`
	Value         float64   `json:"value,omitempty"`
	StringValue   string    `json:"stringValue,omitempty"`
	DataType      string    `json:"dataType,omitempty"`
	Comment       string    `json:"comment,omitempty"`
	Source        string    `json:"source,omitempty"`
	Timestamp     time.Time `json:"timestamp,omitempty"`
}

Score represents a score from the API.

type ScoreBody

type ScoreBody struct {
	ID            string  `json:"id"`
	TraceID       string  `json:"traceId"`
	ObservationID string  `json:"observationId,omitempty"`
	Name          string  `json:"name"`
	Value         float64 `json:"value,omitempty"`
	StringValue   string  `json:"stringValue,omitempty"`
	DataType      string  `json:"dataType,omitempty"` // NUMERIC, CATEGORICAL, BOOLEAN
	Comment       string  `json:"comment,omitempty"`
	Source        string  `json:"source,omitempty"` // API, ANNOTATION, EVAL
}

ScoreBody represents the body of a score event.

type ScoreOption

type ScoreOption func(*scoreConfig)

ScoreOption configures score creation.

func WithScoreComment

func WithScoreComment(comment string) ScoreOption

WithScoreComment sets the score comment.

func WithScoreDataType

func WithScoreDataType(dataType string) ScoreOption

WithScoreDataType sets the score data type.

func WithScoreSource

func WithScoreSource(source string) ScoreOption

WithScoreSource sets the score source.

type Span

type Span struct {
	// contains filtered or unexported fields
}

Span represents a span within a trace.

func SpanFromContext

func SpanFromContext(ctx context.Context) *Span

SpanFromContext returns the span from the context, or nil if none.

func StartSpan

func StartSpan(ctx context.Context, name string, opts ...SpanOption) (context.Context, *Span, error)

StartSpan starts a span from the current context. If there's an active span, creates a child span. If there's only a trace, creates a direct child of the trace.

func (*Span) End

func (s *Span) End(ctx context.Context, opts ...SpanOption) error

End ends the span.

func (*Span) EndTime

func (s *Span) EndTime() *time.Time

EndTime returns the end time.

func (*Span) Generation

func (s *Span) Generation(ctx context.Context, name string, opts ...GenerationOption) (context.Context, *Generation, error)

Generation creates an LLM generation within this span.

func (*Span) ID

func (s *Span) ID() string

ID returns the span ID.

func (*Span) Name

func (s *Span) Name() string

Name returns the span name.

func (*Span) ParentSpanID

func (s *Span) ParentSpanID() string

ParentSpanID returns the parent span ID.

func (*Span) Score

func (s *Span) Score(ctx context.Context, name string, value float64, opts ...ScoreOption) error

Score adds a score to the span.

func (*Span) Span

func (s *Span) Span(ctx context.Context, name string, opts ...SpanOption) (context.Context, *Span, error)

Span creates a child span.

func (*Span) StartTime

func (s *Span) StartTime() time.Time

StartTime returns the start time.

func (*Span) TraceID

func (s *Span) TraceID() string

TraceID returns the parent trace ID.

func (*Span) Update

func (s *Span) Update(ctx context.Context, opts ...SpanOption) error

Update updates the span.

type SpanBody

type SpanBody struct {
	ID                  string         `json:"id"`
	TraceID             string         `json:"traceId"`
	ParentObservationID string         `json:"parentObservationId,omitempty"`
	Name                string         `json:"name,omitempty"`
	StartTime           time.Time      `json:"startTime"`
	EndTime             *time.Time     `json:"endTime,omitempty"`
	Metadata            map[string]any `json:"metadata,omitempty"`
	Input               any            `json:"input,omitempty"`
	Output              any            `json:"output,omitempty"`
	Level               string         `json:"level,omitempty"` // DEBUG, DEFAULT, WARNING, ERROR
	Version             string         `json:"version,omitempty"`
	StatusMessage       string         `json:"statusMessage,omitempty"`
}

SpanBody represents the body of a span event.

type SpanOption

type SpanOption func(*spanConfig)

SpanOption configures span creation.

func WithLevel

func WithLevel(level string) SpanOption

WithLevel sets the log level.

func WithSpanInput

func WithSpanInput(input any) SpanOption

WithSpanInput sets the span input.

func WithSpanMetadata

func WithSpanMetadata(metadata map[string]any) SpanOption

WithSpanMetadata sets span metadata.

func WithSpanOutput

func WithSpanOutput(output any) SpanOption

WithSpanOutput sets the span output.

func WithVersion

func WithVersion(version string) SpanOption

WithVersion sets the version.

type Trace

type Trace struct {
	// contains filtered or unexported fields
}

Trace represents an execution trace.

func TraceFromContext

func TraceFromContext(ctx context.Context) *Trace

TraceFromContext returns the trace from the context, or nil if none.

func (*Trace) End

func (t *Trace) End(ctx context.Context, opts ...TraceOption) error

End ends the trace.

func (*Trace) EndTime

func (t *Trace) EndTime() *time.Time

EndTime returns the end time.

func (*Trace) Generation

func (t *Trace) Generation(ctx context.Context, name string, opts ...GenerationOption) (context.Context, *Generation, error)

Generation creates an LLM generation span.

func (*Trace) ID

func (t *Trace) ID() string

ID returns the trace ID.

func (*Trace) Name

func (t *Trace) Name() string

Name returns the trace name.

func (*Trace) Score

func (t *Trace) Score(ctx context.Context, name string, value float64, opts ...ScoreOption) error

Score adds a score to the trace.

func (*Trace) Span

func (t *Trace) Span(ctx context.Context, name string, opts ...SpanOption) (context.Context, *Span, error)

Span creates a child span.

func (*Trace) StartTime

func (t *Trace) StartTime() time.Time

StartTime returns the start time.

func (*Trace) Update

func (t *Trace) Update(ctx context.Context, opts ...TraceOption) error

Update updates the trace.

type TraceBody

type TraceBody struct {
	ID        string         `json:"id"`
	Name      string         `json:"name,omitempty"`
	Timestamp time.Time      `json:"timestamp"`
	Metadata  map[string]any `json:"metadata,omitempty"`
	Tags      []string       `json:"tags,omitempty"`
	UserID    string         `json:"userId,omitempty"`
	SessionID string         `json:"sessionId,omitempty"`
	Input     any            `json:"input,omitempty"`
	Output    any            `json:"output,omitempty"`
	Public    bool           `json:"public,omitempty"`
}

TraceBody represents the body of a trace event.

type TraceInfo

type TraceInfo struct {
	ID           string         `json:"id"`
	Name         string         `json:"name"`
	Timestamp    time.Time      `json:"timestamp"`
	Metadata     map[string]any `json:"metadata,omitempty"`
	Tags         []string       `json:"tags,omitempty"`
	UserID       string         `json:"userId,omitempty"`
	SessionID    string         `json:"sessionId,omitempty"`
	Input        any            `json:"input,omitempty"`
	Output       any            `json:"output,omitempty"`
	Public       bool           `json:"public,omitempty"`
	Observations []Observation  `json:"observations,omitempty"`
	Scores       []Score        `json:"scores,omitempty"`
}

TraceInfo represents trace information from the API.

type TraceOption

type TraceOption func(*traceConfig)

TraceOption configures trace creation.

func WithInput

func WithInput(input any) TraceOption

WithInput sets the trace input.

func WithMetadata

func WithMetadata(metadata map[string]any) TraceOption

WithMetadata sets trace metadata.

func WithOutput

func WithOutput(output any) TraceOption

WithOutput sets the trace output.

func WithPublic

func WithPublic(public bool) TraceOption

WithPublic sets whether the trace is public.

func WithSessionID

func WithSessionID(sessionId string) TraceOption

WithSessionID sets the session ID.

func WithTags

func WithTags(tags ...string) TraceOption

WithTags sets trace tags.

func WithUserID

func WithUserID(userId string) TraceOption

WithUserID sets the user ID.

type Usage

type Usage struct {
	PromptTokens     int     `json:"promptTokens,omitempty"`
	CompletionTokens int     `json:"completionTokens,omitempty"`
	TotalTokens      int     `json:"totalTokens,omitempty"`
	Input            int     `json:"input,omitempty"`  // Alternative field
	Output           int     `json:"output,omitempty"` // Alternative field
	Total            int     `json:"total,omitempty"`  // Alternative field
	Unit             string  `json:"unit,omitempty"`   // TOKENS, CHARACTERS, etc.
	InputCost        float64 `json:"inputCost,omitempty"`
	OutputCost       float64 `json:"outputCost,omitempty"`
	TotalCost        float64 `json:"totalCost,omitempty"`
}

Usage represents token usage for a generation.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL