API Reference
Complete reference for every public symbol in the dexcost Go SDK, grouped by function.
Initialization
dexcost.Init()
func Init(cfg Config) errorInitialize the global SDK. Must be called before StartTask, EndTask, RecordCost, or any Wrap* function. Safe to call multiple times — only the first call takes effect.
Returns an error if the API key format is invalid, the buffer directory cannot be created, or the pricing engine fails to load.
| Parameter | Type | Description |
|---|---|---|
cfg | Config | SDK configuration. See Configuration. |
dexcost.Close()
func Close()Stop the background sync worker, finalize idle sessions, restore http.DefaultTransport if global HTTP tracking was enabled, and release all resources. Call via defer at application shutdown.
dexcost.Flush()
func Flush()Force an immediate synchronous push of all buffered events to the Control Layer. No-op in local-only mode or when the SDK is not initialized. Push errors are written to the standard logger.
dexcost.Tracker()
func Tracker() *core.TrackerReturn the global *core.Tracker for advanced usage. Panics if Init has not been called.
dexcost.ValidateAPIKey()
func ValidateAPIKey(key string) (string, error)Validate API key format. Returns "live", "test", or "" for an empty key. Returns ErrInvalidAPIKey when the key does not start with dx_live_ or dx_test_.
dexcost.SetContext()
func SetContext(ctx context.Context, customerID, projectID string) context.ContextAttach customer and project attribution to ctx. Returns a derived context. Attribution flows to HTTP adapters and wrapper clients when no explicit task is present.
dexcost.SetContextWithMetadata()
func SetContextWithMetadata(ctx context.Context, customerID, projectID, agent string, metadata map[string]interface{}) context.ContextAttach customer attribution plus an agent name and arbitrary metadata to ctx.
dexcost.GetContext()
func GetContext(ctx context.Context) *core.ContextDataReturn the *core.ContextData stored in ctx, or nil.
dexcost.ClearContext()
func ClearContext(ctx context.Context) context.ContextReturn a context with all dexcost attribution removed.
Tasks
dexcost.StartTask()
func StartTask(ctx context.Context, taskType string, opts ...TaskOption) (context.Context, *TrackedTask)Begin tracking a new task. Returns a derived context with the task attached and a *TrackedTask for recording costs. The parent task (if any) is linked automatically from the incoming context via parent_task_id.
| Parameter | Type | Description |
|---|---|---|
ctx | context.Context | Parent context. Any dexcost task or attribution already in ctx is used for parent linking and attribution inheritance. |
taskType | string | Identifier for the kind of task (e.g. "resolve_ticket"). |
opts | ...TaskOption | Optional functional options — see TaskOption values below. |
Panics if Init has not been called.
dexcost.EndTask()
func EndTask(ctx context.Context, status TaskStatus) errorEnd the task attached to ctx. Convenience wrapper for core.GetCurrentTrackedTask(ctx).End(status). Returns errNoActiveTask if no task is found.
TrackedTask.End()
func (tt *TrackedTask) End(status TaskStatus) errorClose the task, aggregate all event costs into the task totals, and persist. Returns core.ErrTaskAlreadyEnded if called more than once.
| Parameter | Type | Description |
|---|---|---|
status | TaskStatus | One of dexcost.StatusPending, dexcost.StatusRunning, dexcost.StatusSuccess, dexcost.StatusFailed. |
dexcost.GetCurrentTask()
func GetCurrentTask(ctx context.Context) *core.TaskReturn the *core.Task currently active in ctx, or nil.
dexcost.SetCurrentTask()
func SetCurrentTask(ctx context.Context, task *core.Task) context.ContextAttach a *core.Task to ctx and return the derived context.
dexcost.LinkTrace()
func LinkTrace(ctx context.Context, provider, traceID string) errorAttach an external trace link to the active task in ctx. Returns errNoActiveTask if no task is found. The top-level convenience mirrors TrackedTask.LinkTrace.
TrackedTask.LinkTrace()
func (tt *TrackedTask) LinkTrace(provider, traceID string)Attach an external trace link stored in tt.Task.Metadata["_trace_links"].
TrackedTask.GetTraceLinks()
func (tt *TrackedTask) GetTraceLinks() []map[string]stringReturn all linked traces as a slice of {"provider": ..., "trace_id": ...} maps.
TaskOption values
TaskOption is func(*taskConfig). The following constructors are available at the dexcost package level:
| Constructor | Description |
|---|---|
WithCustomer(id string) | Set customer_id on the task. |
WithProject(id string) | Set project_id on the task. |
WithMetadata(m map[string]interface{}) | Attach arbitrary metadata to the task. |
WithExperiment(id string) | Set experiment_id on the task. |
WithVariant(v string) | Set the variant label on the task. |
Recording costs
dexcost.RecordCost()
func RecordCost(ctx context.Context, service string, operation string, costUSD decimal.Decimal, opts ...EventOption) errorRecord a non-LLM cost against the active task in ctx. Returns errNoActiveTask if no task is attached to ctx.
| Parameter | Type | Description |
|---|---|---|
ctx | context.Context | Context holding the active task. |
service | string | Service name (e.g. "pinecone"). |
operation | string | Operation label (e.g. "query"). Pass "" to omit. |
costUSD | decimal.Decimal | Cost in USD. |
opts | ...EventOption | Optional EventOption overrides. |
TrackedTask.RecordCost()
func (tt *TrackedTask) RecordCost(service string, costUSD decimal.Decimal, opts ...EventOption) errorRecord a non-LLM cost directly on this task. Returns core.ErrTaskAlreadyEnded if the task has already been ended.
| Parameter | Type | Description |
|---|---|---|
service | string | Service name. |
costUSD | decimal.Decimal | Cost in USD. |
opts | ...EventOption | Optional EventOption overrides — see EventOption values below. |
TrackedTask.RecordUsage()
func (tt *TrackedTask) RecordUsage(service string, units int) errorLook up service in the rate registry, multiply by units, and record an external_cost event. When no rate is registered the event is recorded with cost_usd=0 and cost_confidence="unknown".
| Parameter | Type | Description |
|---|---|---|
service | string | Service name matching a registered rate. |
units | int | Number of units consumed. |
TrackedTask.RecordLLMCall()
func (tt *TrackedTask) RecordLLMCall(provider, model string, inputTokens, outputTokens int, opts ...LLMCallOption) errorRecord an llm_call event. When no explicit cost is supplied via WithCost, cost is auto-computed by the pricing engine from the bundled LiteLLM pricing data.
| Parameter | Type | Description |
|---|---|---|
provider | string | Provider name (e.g. "openai"). |
model | string | Model identifier (e.g. "gpt-4o"). |
inputTokens | int | Number of input tokens. |
outputTokens | int | Number of output tokens. |
opts | ...LLMCallOption | Optional LLMCallOption values — see below. |
TrackedTask.MarkRetry()
func (tt *TrackedTask) MarkRetry(reason string, opts ...RetryOption) errorCreate a retry_marker event that increments the task's retry_count and retry_cost_usd.
| Parameter | Type | Description |
|---|---|---|
reason | string | Why the retry occurred (e.g. "rate_limit", "timeout"). |
opts | ...RetryOption | Optional RetryOption values — see below. |
TrackedTask.MarkNotRetry()
func (tt *TrackedTask) MarkNotRetry(eventID uuid.UUID) errorClear the retry flag on a retry-marked event. Pass uuid.Nil to un-flag the most recent retry event for this task. No-op if no matching retry event is found.
dexcost.RecordLiteLLM()
func RecordLiteLLM(ctx context.Context, response map[string]interface{}) (Event, error)Record an llm_call event from a LiteLLM-style response map against the active task in ctx. The map must contain "model" (string) and "usage" (map with "prompt_tokens" and "completion_tokens"). Returns errNoActiveTask if no task is active.
EventOption values
EventOption is satisfied by any type that implements applyEventConfig(*eventConfig). The following option constructors are available:
| Constructor | Description |
|---|---|
WithEventType(t EventType) | Override the event type (default EventTypeExternalCost). |
WithOperation(op string) | Set the operation name stored in event.Details["operation"]. |
WithCostConfidence(cc CostConfidence) | Override the cost confidence. Also satisfies LLMCallOption. |
WithPricingSource(ps PricingSource) | Override the pricing source. Also satisfies LLMCallOption. |
WithPricingVersion(pv string) | Set the pricing version string. Also satisfies LLMCallOption. |
WithDetails(d map[string]interface{}) | Merge arbitrary key-value pairs into event.Details. Also satisfies LLMCallOption. |
LLMCallOption values
| Constructor | Description |
|---|---|
WithCost(cost decimal.Decimal) | Explicit cost in USD; skips auto-pricing. |
WithCachedTokens(n int) | Prompt-cache read token count (discounted rate). |
WithCacheCreationTokens(n int) | Anthropic prompt-cache write token count (charged at cache creation rate). |
WithLatency(ms int) | Response latency in milliseconds. |
WithErrorType(t string) | Transient error class (e.g. "rate_limit", "timeout") stored in Details["error_type"] for heuristic retry detection. |
RetryOption values
| Constructor | Description |
|---|---|
WithRetryCost(cost decimal.Decimal) | Explicit cost incurred by the retry. |
WithRetryOf(id uuid.UUID) | UUID of the original event this retry supersedes. |
Instrumentation
dexcost.WrapOpenAI()
func WrapOpenAI(inner interface{}) *clients.TrackedOpenAICreate a TrackedOpenAI wrapper around an OpenAI-compatible client. The wrapper records one llm_call event per CreateChatCompletion call. Panics if Init has not been called.
dexcost.WrapAnthropic()
func WrapAnthropic(inner interface{}) *clients.TrackedAnthropicCreate a TrackedAnthropic wrapper. Records one llm_call event per message creation call. Panics if Init has not been called.
dexcost.WrapGemini()
func WrapGemini(inner interface{}) *clients.TrackedGeminiCreate a TrackedGemini wrapper. Records one llm_call event per generation call. Panics if Init has not been called.
dexcost.WrapBedrock()
func WrapBedrock(inner interface{}) *clients.TrackedBedrockCreate a TrackedBedrock wrapper around an AWS Bedrock client. Records one llm_call event per invocation. Panics if Init has not been called.
dexcost.WrapCohere()
func WrapCohere(inner interface{}) *clients.TrackedCohereCreate a TrackedCohere wrapper. Records one llm_call event per generation call. Panics if Init has not been called.
dexcost.WrapGroq()
func WrapGroq(inner interface{}) *clients.TrackedGroqCreate a TrackedGroq wrapper. Records one llm_call event per completion call. Panics if Init has not been called.
adapters.TrackHTTP()
func TrackHTTP(client *http.Client) *http.ClientReturn a new *http.Client whose Transport is wrapped with trackingTransport. The original client is not mutated.
adapters.EnableGlobalHTTPTracking() / DisableGlobalHTTPTracking()
func EnableGlobalHTTPTracking()
func DisableGlobalHTTPTracking()Wrap / restore http.DefaultTransport for process-wide HTTP cost capture. Both functions are idempotent. dexcost.Close() calls DisableGlobalHTTPTracking automatically.
adapters.RegisterDomainRate()
func RegisterDomainRate(domain string, costUSD decimal.Decimal, per string)Register a per-request cost for domain (host[:port]). User-registered rates take precedence over the service catalog.
adapters.StartBrowserSession() / TrackBrowser()
func StartBrowserSession(ctx context.Context, pageURL string, ratePerMinute decimal.Decimal) *BrowserSession
func TrackBrowser(ctx context.Context, pageURL string, ratePerMinute decimal.Decimal, fn func() error) errorTrack wall-clock time for a browser automation session and record a compute_cost event on End(). Pass decimal.Zero for ratePerMinute to use adapters.DefaultBrowserRatePerMinute ($0.01/min). TrackBrowser always calls End(), even if fn panics or returns an error.
middleware.GinMiddleware()
func GinMiddleware(tracker *core.Tracker, taskType string, opts ...core.TaskOption) gin.HandlerFuncGin middleware that starts a dexcost task per request and ends it with StatusSuccess for responses below 500 or StatusFailed for 5xx responses and panics.
middleware.EchoMiddleware()
func EchoMiddleware(tracker *core.Tracker, taskType string, opts ...core.TaskOption) echo.MiddlewareFuncEcho v4 middleware with the same lifecycle as GinMiddleware. The task ends with StatusFailed when the handler returns a non-nil error or the response status is ≥ 500.
middleware.HTTPMiddleware()
func HTTPMiddleware(tracker *core.Tracker, taskType string, opts ...core.TaskOption) func(http.Handler) http.HandlerStandard net/http middleware wrapper. middleware.HTTPMiddlewareFunc is a convenience variant for http.HandlerFunc.
integrations.NewDexcostCallbackHandler()
func NewDexcostCallbackHandler(buffer core.Buffer, engine *pricing.Engine) *DexcostCallbackHandlerCreate a langchaingo callback handler that records llm_call events on HandleLLMEnd and HandleLLMGenerateContentEnd. All other callbacks.Handler methods are no-ops. Use handler.WithModel("model-name") to set a default model fallback.
clients.RecordMCPResponse()
func RecordMCPResponse(buffer core.Buffer, rates *pricing.RateRegistry, taskID uuid.UUID, info MCPCallInfo) (core.Event, error)Record an external_cost event for an MCP tool call. Cost is resolved via the rate registry ("mcp:<tool_name>" key), then the MCPToolMap catalog mapping, then falls back to zero with confidence="unknown".
| Parameter | Type | Description |
|---|---|---|
buffer | core.Buffer | Storage backend (from dexcost.Tracker().Buffer()). |
rates | *pricing.RateRegistry | Rate registry (from dexcost.Tracker().Rates()). |
taskID | uuid.UUID | Task to attribute the event to. |
info | MCPCallInfo | Tool name, server identifier, latency, and error flag. |
Pricing & rates
pricing.Engine
Calculates LLM costs from model name and token counts. Loaded from the embedded model_cost_map.json at Init time.
pricing.NewEngine()
func NewEngine() (*Engine, error)Load the embedded pricing data and return a new Engine.
Engine.GetCost()
func (e *Engine) GetCost(model string, inputTokens, outputTokens, cachedTokens, cacheCreationTokens int) CostResultCompute the cost for an LLM call. Model resolution: exact match → provider-prefix strip → date-suffix fallback. Returns CostResult with CostConfidence="unknown" when the model is not found.
| Parameter | Type | Description |
|---|---|---|
model | string | Model identifier (e.g. "gpt-4o", "openai/gpt-4o"). |
inputTokens | int | Total input tokens. |
outputTokens | int | Output tokens. |
cachedTokens | int | Prompt-cache read tokens (charged at the discounted cache-read rate). |
cacheCreationTokens | int | Anthropic prompt-cache write tokens (charged at the cache-creation rate). |
Engine.SetCustomPricing()
func (e *Engine) SetCustomPricing(model string, inputPer1k, outputPer1k decimal.Decimal)Override bundled pricing for model with custom per-1k-token rates. Custom pricing takes precedence over the bundled data.
Engine.PricingVersion()
func (e *Engine) PricingVersion() stringReturn the 12-character SHA-256 hex prefix of the loaded pricing data. Changes when pricing data is refreshed.
Engine.RefreshFromServer()
func (e *Engine) RefreshFromServer(endpoint string) errorFetch the latest pricing data from <endpoint>/v1/api/pricing-data/latest, parse it, and atomically replace the engine's model map. Existing data is unchanged on error.
Engine.StartBackgroundRefresh() / StopBackgroundRefresh()
func (e *Engine) StartBackgroundRefresh(endpoint string, interval time.Duration)
func (e *Engine) StopBackgroundRefresh()Start/stop a goroutine that calls RefreshFromServer on every interval tick. StartBackgroundRefresh performs an initial refresh before the first tick. Idempotent.
pricing.RateRegistry
Stores per-service cost rates for non-LLM services.
pricing.NewRateRegistry()
func NewRateRegistry() *RateRegistryReturn an empty RateRegistry.
RateRegistry.Register()
func (r *RateRegistry) Register(service, per string, costUSD decimal.Decimal)Add or update a rate for service.
RateRegistry.Get()
func (r *RateRegistry) Get(service string) *RateEntryReturn the *RateEntry for service, or nil if not found.
RateRegistry.GetAll()
func (r *RateRegistry) GetAll() map[string]RateEntryReturn a copy of all registered rates.
RateRegistry.LoadYAML()
func (r *RateRegistry) LoadYAML(path string) errorLoad rates from a YAML file. Canonical format: entries nested under a top-level rates: key with per and cost_usd sub-keys. A legacy flat mapping is also accepted.
RateRegistry.ExportYAML()
func (r *RateRegistry) ExportYAML(path string) errorExport all registered rates to a YAML file in the canonical format.
RateRegistry.PricingVersion()
func (r *RateRegistry) PricingVersion() stringReturn a deterministic 12-character SHA-256 hex hash of all registered rates. Changes on any Register or LoadYAML call.
pricing.ServiceCatalog
Manages the bundled 163-service pricing catalog.
pricing.NewServiceCatalog()
func NewServiceCatalog() (*ServiceCatalog, error)Load the embedded service_prices.json and return a new ServiceCatalog.
ServiceCatalog.Lookup()
func (c *ServiceCatalog) Lookup(rawURL string) *ServiceEntryReturn the *ServiceEntry whose domains match the hostname in rawURL, or nil.
ServiceCatalog.ExtractCost()
func (c *ServiceCatalog) ExtractCost(entry *ServiceEntry, headers map[string]string, body map[string]interface{}) *CostExtractionResultExtract cost from an HTTP response for a matched catalog entry. Returns nil when no pricing rule applies.
ServiceCatalog.RefreshFromURL()
func (c *ServiceCatalog) RefreshFromURL(url string) errorDownload an updated catalog JSON from url and merge it into the existing entries.
ServiceCatalog.CatalogVersion()
func (c *ServiceCatalog) CatalogVersion() stringReturn the catalog's version string.
Types
Config
type Config struct {
APIKey string
Storage string
BatchSize int
FlushIntervalSeconds float64
BufferDir string
RedactFields []string
HashCustomerID bool
Environment string
TrackHTTP bool
ServiceCatalogURL string
EnableRetryHeuristics bool
RetryHeuristicWindow float64
RetryHeuristicThreshold float64
}Global SDK configuration. See Configuration for field descriptions and defaults.
Key methods on Config:
| Method | Returns | Description |
|---|---|---|
StorageMode() | string | "cloud" when API key is set and Storage != "local", otherwise "local". |
KeyType() | string | "live", "test", or "". |
IsSandbox() | bool | true when using a dx_test_ key. |
IsDev() | bool | true when Environment == "development". |
TrackedTask
dexcost.TrackedTask is an alias for core.TrackedTask. It wraps a Task and provides all cost-recording methods.
| Field / Method | Description |
|---|---|
Task | The underlying core.Task struct. |
RecordCost(service string, costUSD decimal.Decimal, opts ...EventOption) error | Record an external_cost event. |
RecordUsage(service string, units int) error | Compute cost from the rate registry and record. |
RecordLLMCall(provider, model string, inputTokens, outputTokens int, opts ...LLMCallOption) error | Record an llm_call event. |
MarkRetry(reason string, opts ...RetryOption) error | Create a retry_marker event. |
MarkNotRetry(eventID uuid.UUID) error | Clear the retry flag on an event. |
LinkTrace(provider, traceID string) | Attach an external trace link. |
GetTraceLinks() []map[string]string | Return all linked traces. |
End(status TaskStatus) error | Finalize and persist the task. |
Task
The struct persisted to SQLite for each tracked task.
| Field | Type | Description |
|---|---|---|
TaskID | uuid.UUID | Unique task identifier. |
TaskType | string | Kind of task (e.g. "resolve_ticket"). |
CustomerID | string | Customer attribution. |
ProjectID | string | Project attribution. |
ExperimentID | string | Experiment identifier. |
Variant | string | Variant label. |
ParentTaskID | *uuid.UUID | Set automatically for nested tasks. |
Status | TaskStatus | Current task status. |
StartedAt | time.Time | UTC timestamp when the task was created. |
EndedAt | *time.Time | UTC timestamp when the task was closed, or nil if still running. |
TotalCostUSD | decimal.Decimal | Sum of all event costs. |
LLMCostUSD | decimal.Decimal | Sum of llm_call event costs. |
ExternalCostUSD | decimal.Decimal | Sum of external_cost event costs. |
ComputeCostUSD | decimal.Decimal | Sum of compute_cost event costs. |
TotalInputTokens | int | Aggregate input tokens across all LLM calls. |
TotalOutputTokens | int | Aggregate output tokens across all LLM calls. |
TotalCachedTokens | int | Aggregate cached tokens across all LLM calls. |
RetryCount | int | Number of events flagged as retries. |
RetryCostUSD | decimal.Decimal | Sum of retry event costs. |
FailureCount | int | 1 when task status is failed, otherwise 0. |
Metadata | map[string]interface{} | Arbitrary metadata, including "_trace_links". |
Event
The struct persisted for each individual cost event within a task.
| Field | Type | Description |
|---|---|---|
EventID | uuid.UUID | Unique event identifier. |
TaskID | uuid.UUID | Task this event belongs to. |
EventType | EventType | One of EventTypeLLMCall, EventTypeExternalCost, EventTypeComputeCost, EventTypeRetryMarker. |
CostUSD | decimal.Decimal | Cost in USD. |
CostConfidence | CostConfidence | One of CostConfidenceExact, CostConfidenceComputed, CostConfidenceEstimated, CostConfidenceUnknown. |
PricingSource | PricingSource | Source of pricing data. |
PricingVersion | string | Hash of the pricing snapshot used. |
ServiceName | string | Service name for non-LLM events. |
Provider | string | LLM provider name for llm_call events. |
Model | string | Model identifier for llm_call events. |
InputTokens | *int | Input tokens (LLM calls). |
OutputTokens | *int | Output tokens (LLM calls). |
CachedTokens | *int | Cached tokens (LLM calls). |
LatencyMs | *int | Response latency in milliseconds. |
IsRetry | bool | Whether this event is flagged as a retry. |
RetryReason | string | Why the retry occurred. |
RetryOf | *uuid.UUID | UUID of the original event this retries. |
OccurredAt | time.Time | UTC timestamp of the event. |
Details | map[string]interface{} | Arbitrary extra metadata. |
CostResult
type CostResult struct {
CostUSD decimal.Decimal
CostConfidence string
PricingSource string
PricingVersion string
}Result of a pricing.Engine.GetCost() call.
| Field | Description |
|---|---|
CostUSD | Calculated cost in USD. |
CostConfidence | "computed" or "unknown". |
PricingSource | "litellm", "custom", or "unknown". |
PricingVersion | Hash of the pricing data used. |
RateEntry
type RateEntry struct {
Service string
Per string
CostUSD decimal.Decimal
}A single rate entry in the RateRegistry.
TaskStatus
Type alias for core.TaskStatus. Constants re-exported at the dexcost package level:
| Constant | Value |
|---|---|
dexcost.StatusPending | "pending" |
dexcost.StatusRunning | "running" |
dexcost.StatusSuccess | "success" |
dexcost.StatusFailed | "failed" |
EventType
Type alias for core.EventType. Constants re-exported at the dexcost package level:
| Constant | Value |
|---|---|
dexcost.EventTypeLLMCall | "llm_call" |
dexcost.EventTypeExternalCost | "external_cost" |
dexcost.EventTypeComputeCost | "compute_cost" |
dexcost.EventTypeRetryMarker | "retry_marker" |
CostConfidence
Type alias for core.CostConfidence. Constants re-exported at the dexcost package level:
| Constant | Value |
|---|---|
dexcost.CostConfidenceExact | "exact" |
dexcost.CostConfidenceComputed | "computed" |
dexcost.CostConfidenceEstimated | "estimated" |
dexcost.CostConfidenceUnknown | "unknown" |
PricingSource
Type alias for core.PricingSource. Constants re-exported at the dexcost package level:
| Constant | Value |
|---|---|
dexcost.PricingSourceLiteLLM | "litellm" |
dexcost.PricingSourceProviderResponse | "provider_response" |
dexcost.PricingSourceManual | "manual" |
dexcost.PricingSourceCustom | "custom" |
dexcost.PricingSourceRateRegistry | "rate_registry" |
dexcost.PricingSourceUnknown | "unknown" |
DexcostContext
Type alias for core.ContextData. Holds attribution data stored in a context.Context by SetContext.
| Field | Type | Description |
|---|---|---|
CustomerID | string | Customer attribution. |
ProjectID | string | Project attribution. |
Agent | string | Agent name. |
Metadata | map[string]interface{} | Arbitrary key-value metadata. |
ErrInvalidAPIKey
var ErrInvalidAPIKey = errors.New("invalid API key format")Returned by ValidateAPIKey when the key does not start with dx_live_ or dx_test_. Also available as dexcost.InvalidAPIKeyError.
ALL_SUPPORTED_INSTRUMENTS
var ALL_SUPPORTED_INSTRUMENTS = []string{
"openai", "anthropic", "gemini", "bedrock", "cohere", "groq", "litellm", "langchain",
}The full list of providers and integrations the Go SDK can instrument.
Type aliases
The following type aliases re-export internal types at the top-level dexcost package for convenience:
| Alias | Underlying type |
|---|---|
dexcost.Task | core.Task |
dexcost.Event | core.Event |
dexcost.CostTracker | core.Tracker |
dexcost.PricingEngine | pricing.Engine |
dexcost.RateRegistry | pricing.RateRegistry |
dexcost.RateEntry | pricing.RateEntry |
dexcost.ServiceCatalog | pricing.ServiceCatalog |
dexcost.CostResult | pricing.CostResult |
dexcost.SyncWorker | transport.EventPusher |
dexcost.DexcostCallbackHandler | integrations.DexcostCallbackHandler |
dexcost.EventOption | core.EventOption |
dexcost.LLMCallOption | core.LLMCallOption |
dexcost.RetryOption | core.RetryOption |
Configuration
All Config fields, environment variables, development mode, attribution context helpers, and the dexcost CLI.
Overview
The Rust SDK brings Agent Unit Economics to async (Tokio) Rust applications by wrapping LLM clients or recording calls explicitly with full customer, project, and task attribution.