Skip to content

Add Go package support for native LLM cost calculation in Go agents #407

Description

@VinozzZ

Summary

I'd like to propose a Go implementation of genai-prices so that Go applications can calculate LLM inference costs using the same price data and matching logic as the existing Python and JavaScript/TypeScript packages.

Motivation

Go is widely used for backend services and infrastructure tooling, including AI-powered applications that call LLM inference APIs. Currently, Go developers who want to track or estimate LLM costs have no first-party option from this project and would need to either:

  • Manually parse prices/data.json without the matching logic
  • Use a subprocess to call the Python or JS CLI

A native Go package would allow Go applications to integrate cost calculation directly, without any runtime dependencies on Python or Node.js.

Proposed scope

The Go package would aim for feature parity with the existing Python and JS/TS packages.

The price data could be embedded at build time using Go's embed package so consumers don't need to manage the JSON files separately.

Contribution offer

I'm happy to contribute an initial implementation if the maintainers are open to this feature

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions