obol

package module
v0.1.1-rc.3 Latest Latest
Warning

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

Go to latest
Published: Jun 5, 2026 License: Apache-2.0 Imports: 11 Imported by: 0

README

obol-go

Go binding for obol — a library that reads agent transcripts (Claude Code, Codex, Pi) and estimates their USD cost.

import "github.com/prime-radiant-inc/obol-go"

This is a generated repository

The source of truth lives in the main repo under bindings/go/. This repository is populated automatically by obol's release workflow: each vX.Y.Z release assembles the Go source together with the prebuilt native libraries and tags a matching release here, so go get resolves a self-contained module.

Status

Bootstrap. The first tagged release is pending; until a vX.Y.Z tag exists here, go get has nothing to resolve. Watch the main repo for the release that seeds this module.

How it works (once released)

The binding loads obol's native library at runtime via puregono cgo, no C toolchain required (CGO_ENABLED=0 works). The platform's native library is embedded in the module and used directly, so a plain go get is all a consumer needs on macOS (arm64/x64) and Linux (x64/arm64).

License

Apache-2.0. See LICENSE and NOTICE.

Documentation

Overview

Package obol is a thin purego binding over obol-core's C ABI. The Rust core owns all accounting; this package only marshals C strings and unmarshals JSON. No cgo: the native library is loaded at runtime via github.com/ebitengine/purego (CGO_ENABLED=0 works).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Version

func Version() string

Version returns the obol core library version (static C string; not freed).

Types

type Approximation

type Approximation struct {
	Kind   string `json:"kind"`
	Detail string `json:"detail,omitempty"`
}

type CostEstimate

type CostEstimate struct {
	TotalUSD       float64         `json:"total_usd"`
	PerModel       []ModelCost     `json:"per_model"`
	Tokens         TokenBuckets    `json:"tokens"`
	UnpricedModels []string        `json:"unpriced_models"`
	Approximations []Approximation `json:"approximations"`
	PricingAsOf    string          `json:"pricing_as_of"`
}

func EstimateBytes

func EstimateBytes(data []byte, dialect string) (*CostEstimate, error)

EstimateBytes estimates in-memory transcript bytes. dialect "" means auto-detect.

func EstimatePath

func EstimatePath(path, dialect string) (*CostEstimate, error)

EstimatePath estimates a transcript file's cost. dialect "" means auto-detect.

type ModelCost

type ModelCost struct {
	Model       string       `json:"model"`
	Provider    string       `json:"provider"`
	Tokens      TokenBuckets `json:"tokens"`
	SubtotalUSD float64      `json:"subtotal_usd"`
}

type ObolError

type ObolError struct {
	Code    int    `json:"code"`
	Kind    string `json:"kind"`
	Message string `json:"message"`
}

ObolError carries the FFI error envelope.

func (*ObolError) Error

func (e *ObolError) Error() string

type RefreshReport

type RefreshReport struct {
	Models    uint64 `json:"models"`
	AsOf      string `json:"as_of"`
	WrittenTo string `json:"written_to"`
}

func Refresh

func Refresh(asOf string) (*RefreshReport, error)

Refresh pulls fresh pricing tables. asOf is the caller's date string.

type TokenBuckets

type TokenBuckets struct {
	Input      uint64 `json:"input"`
	Output     uint64 `json:"output"`
	CacheRead  uint64 `json:"cache_read"`
	CacheWrite uint64 `json:"cache_write"`
}

Jump to

Keyboard shortcuts

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