Skip to main content

Official Python SDK for Trunkate AI

Project description

Trunkate AI Python SDK

The official Trunkate AI Python SDK provides synchronous bindings for Python 3.9+. It utilizes httpx internally for lightning-fast networking.

Installation

pip install trunkate-ai

Setup & Configuration

The SDK automatically reads the TRUNKATE_API_KEY from your environment.

import os
from trunkate_ai import Trunkate

# Initializes using os.environ.get("TRUNKATE_API_KEY")
client = Trunkate()

# Alternatively, pass it explicitly:
# client = Trunkate(api_key="tk_live_...")

Usage

# 1. Define your long prompt
prompt = "Your very long context..."

# 2. Optimize the prompt for a specific task
optimized = client.optimize(
    text=prompt,
    task="Summarize this document",
    budget=500,
    model="gpt-4o"
)

print(f"Reduced token count by {optimized.stats.reduction_percent}%")

Parameters

Parameter Type Required Description
text str Yes The raw, unoptimized prompt.
task str No Instructions on what the LLM should do with the prompt.
budget int No Target maximum token count (default: varies by model).
model str No The target LLM (default: gpt-4o).

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

trunkate_ai-0.1.6.tar.gz (3.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

trunkate_ai-0.1.6-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

Details for the file trunkate_ai-0.1.6.tar.gz.

File metadata

  • Download URL: trunkate_ai-0.1.6.tar.gz
  • Upload date:
  • Size: 3.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for trunkate_ai-0.1.6.tar.gz
Algorithm Hash digest
SHA256 9ce5903d6a5fe4ec426f15463b8400310fb27857446d6964446628c1ee60b1f7
MD5 e08478c953102eb2db2c6f1d25f1bbcf
BLAKE2b-256 794a29eefe8e878f252cbbdcb5a05bcce45708234bf2c13cf77dfc9909227f96

See more details on using hashes here.

File details

Details for the file trunkate_ai-0.1.6-py3-none-any.whl.

File metadata

  • Download URL: trunkate_ai-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 2.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.19

File hashes

Hashes for trunkate_ai-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 3e9308f7ffb3e33d94ee36a2d7619535ef2718b42e83e274cc4ab7646601c7cc
MD5 f20251b1ab29df8552bec29f27162013
BLAKE2b-256 516664f25443bc7a51851ccad2f7f7852b0cf328e99b4168de651785f1363f8c

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page