Curtly
Core Engine Architecture

Dual-stage AI token optimization engine

Simultaneously compress input context payloads and eliminate expensive output generation multipliers with zero codebase modifications.

Combined Net Savings
Up to 65%

Blends 50-68% input context reduction with 30-50% output generation brevity.

Proxy Latency
< 15ms

Ultra-fast in-memory streaming gateway executing at the edge.

Integration Effort
60 Seconds

Drop-in baseURL configuration with zero prompt refactoring required.

The production engineering challenge

Modern AI applications suffer from asymmetric billing: input tokens carry massive context payload bloat from RAG docs and system instructions, while output tokens cost 300% to 500% more per million. Optimizing only input or only output leaves over half of potential savings on the table.

Technical architecture & mechanics

1

Stage 1: In-memory input context compression

Analyzes prompt AST and natural language payloads to eliminate token-heavy sub-words, repetitive delimiters, and conversational fluff while preserving code blocks bit-for-bit.

2

Stage 2: Output efficiency governor

Dynamically injects behavioral brevity directives into API calls that direct the target model to omit polite conversational preamble, repetitive confirmations, and markdown fluff.

3

End-to-end transparent reverse proxy

Operates as a high-speed gateway requiring only a single baseURL change in your OpenAI, Anthropic, or Vercel AI SDK client configurations.

Standard OpenAI SDK Drop-in

import OpenAI from 'openai'; // Point standard OpenAI SDK to Curtly dual-stage proxy const client = new OpenAI({ apiKey: process.env.OPENAI_API_KEY, baseURL: 'https://proxy.curtly.dev/v1', defaultHeaders: { 'x-curtly-key': process.env.CURTLY_API_KEY, 'x-curtly-efficiency': 'balanced', // lite | balanced | ultra }, }); const response = await client.chat.completions.create({ model: 'gpt-6-astra', messages: [{ role: 'user', content: 'Analyze this customer dataset...' }], });

Architecture comparison

Evaluation metricCurtly.dev gatewayTraditional / naive approach
Input Context CompressionAutomated 50-68% reduction with AST Safe Vault lockManual prompt shortening or static truncation
Output Token GovernanceAutomated 30-50% output reduction eliminating 5x multipliersNone (full price paid on verbose output generation)
Syntax Preservation100% bit-for-bit guarantee on code and JSONHigh risk of JSON corruption and lost code delimiters
Integration Overhead1-line baseURL swap in standard SDKsComplex custom middleware and prompt rewrites

Frequently asked questions

Basic prompt compression only reduces the input prompt before sending it to the model. Dual-stage optimization combines deterministic input compression with active output efficiency injection, targeting the disproportionately expensive 3x to 5x output token rates.

Ready to optimize your AI infrastructure?

Start optimizing in 60 seconds with a 1-line baseURL change. Free tier available with zero credit card required.