Skip to Content

Go SDK

The official Trunkate AI Go SDK provides idiomatic struct bindings and is designed to slide perfectly into highly-concurrent backend pipelines.

Installation

go get trunkate.ai/go

Usage (Universal Budget)

The Budget field is Universal. It accepts both absolute token counts (int) and proactive percentage buffers (string).

package main import ( "fmt" "trunkate.ai/go" ) func main() { client, _ := trunkate_ai.NewClient("tk_live_...") // OPTION A: Fixed Token Budget (Integer) resp, _ := client.Optimize(&trunkate_ai.Request{ Text: "...", Budget: 500, }) // OPTION B: Proactive Percentage Buffer (String) resp2, _ := client.Optimize(&trunkate_ai.Request{ Text: "...", Budget: "20%", }) fmt.Printf("Optimized: %s", resp.Text) }

Parameter Reference

ParameterTypeRequiredDescription
TextstringYesThe natural language prompt to optimize.
TaskstringNoOptional guidance for preservation ranking.
Budgetint|stringNoAbsolute tokens (e.g. 500) or percentage (e.g. "20%").
ModelstringNoTarget LLM (default: gpt-4o).
Last updated on