Skip to main content

Official Python SDK for Trunkate AI

Project description

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.5.tar.gz (3.1 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.5-py3-none-any.whl (2.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: trunkate_ai-0.1.5.tar.gz
  • Upload date:
  • Size: 3.1 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.5.tar.gz
Algorithm Hash digest
SHA256 1d6b7d21725790a27d34888aba956d0f9f0446c20cd55ba66b870b20e81ce240
MD5 a4caf8f88048527ca8fed27ebffc4fc9
BLAKE2b-256 11a98babb7ee8769a34b36aa4cf971775e86f72453d79b2776d8e3d5c51be4d2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trunkate_ai-0.1.5-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.5-py3-none-any.whl
Algorithm Hash digest
SHA256 6c3da69a8ce35bbd418b0d3858f6d6b4c8789abb32e7bc210ed9d126d6c07531
MD5 25dccd6be8815f8246bfeb06001ac708
BLAKE2b-256 92acb2dbe5dba7f0bce07ebf8360f0e26dbbc8726099da6365072ba748551ff7

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