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
Release history Release notifications | RSS feed
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.3.0.tar.gz
(6.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file trunkate_ai-0.3.0.tar.gz.
File metadata
- Download URL: trunkate_ai-0.3.0.tar.gz
- Upload date:
- Size: 6.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6e43eaf8286ceb40380473f4eb612d7587920bb0ed226edc19cdbe8fd03a7b58
|
|
| MD5 |
d67fb6c7642b5e4d9aeaf9ab828db086
|
|
| BLAKE2b-256 |
c3c64ef402d91f9651e05a06cc7b8c9d99b3536679591cf9d38037995f547324
|
File details
Details for the file trunkate_ai-0.3.0-py3-none-any.whl.
File metadata
- Download URL: trunkate_ai-0.3.0-py3-none-any.whl
- Upload date:
- Size: 4.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.20
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8c4fd8ea6f38943554e898e449e9ed8bb4679f988c72b72906164c4558da5815
|
|
| MD5 |
433db5845c9f68f5db9d817065912e85
|
|
| BLAKE2b-256 |
9a723d953a7d98ef3f1409b38854f52eabc5dbc35348ff896083ffeeff16288e
|