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.1.7.tar.gz
(3.3 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.1.7.tar.gz.
File metadata
- Download URL: trunkate_ai-0.1.7.tar.gz
- Upload date:
- Size: 3.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.19
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c5399a2906f8a011d5b480cc502a44dd3b5fda8f435096b95e8e90e1dfb1a00f
|
|
| MD5 |
13c6719ebc10a111a0705bc5a79e1c11
|
|
| BLAKE2b-256 |
2a80b10625983e6b5cfac8c1e31feffc6ef2511501458dd8a183a5a7df00f67e
|
File details
Details for the file trunkate_ai-0.1.7-py3-none-any.whl.
File metadata
- Download URL: trunkate_ai-0.1.7-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1e35c32a407dfe61d1d1d96035094c189218b70f17a40ba3e6a6795351575854
|
|
| MD5 |
f5077f5794e85e5a9b0abf79d0e5dab8
|
|
| BLAKE2b-256 |
7bbbf265bd3ee74659c8907b53e9a55112fc2bb14a622eaeefbc224d2928d4c9
|