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

Uploaded Python 3

File details

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

File metadata

  • Download URL: trunkate_ai-0.1.8.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

Hashes for trunkate_ai-0.1.8.tar.gz
Algorithm Hash digest
SHA256 e2012d8fd1a5bd73b3e0d629d285a443f8f51cd45639b2549980d4504e151901
MD5 da4739349058f7c33f4b04bc98c135a5
BLAKE2b-256 a497339ff0636363c6c5d3cdfa983775343aa4ac6506bc7a5f6526cad6a12886

See more details on using hashes here.

File details

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

File metadata

  • Download URL: trunkate_ai-0.1.8-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.8-py3-none-any.whl
Algorithm Hash digest
SHA256 2f5edcd76a988cc793b4b4c43df0a7cfede55491943e6b249f1a750e26fdfa27
MD5 6c12bab77c0f3bb98fd076cc6296c417
BLAKE2b-256 a53d5f9c64c6958b18f3f322bfbc0050a5d0edf8ec9f1f00c38b29908363bc05

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