All work →
costQL

Priced Before It Runs

GraphQL lets every caller ask a different question, which means every query has a different cost — and operators only learn that cost after the server has already paid it. costQL calibrates a live GraphQL API into a pricing pack: one small JSON file that quotes any query, instantly and fully offline, in Python or JavaScript. Live on PyPI and npm, validated against three unrelated APIs. Free and open source.

Visit WebsiteTry the PlaygroundRead the ArticlePyPInpmStar on GitHub
costQL banner — price GraphQL queries before they run
Challenge01

Pricing a Query Nobody Has Seen Yet

GraphQL's flexibility is exactly what makes it hard to bill. A REST endpoint does one thing at one cost; a GraphQL endpoint answers whatever shape of question the caller composes, and two queries that look similar can differ in cost by orders of magnitude. Flat per-request pricing overcharges the small queries and undercharges the expensive ones, while static complexity scoring assigns points to fields nobody ever measured.

Machine-driven traffic raises the stakes. When the caller is an agent composing queries on its own, there is no human in the loop to notice a bad number — a wrong price becomes a live billing problem the moment it ships. And metering after execution doesn't solve it: by the time the meter reads, the server has already done the work.

What was missing was a way to quote any query in advance — accurately, offline, and with honest uncertainty when the tool isn't sure.

Solution02

Calibrate Once, Quote Anywhere

costQL turns a live endpoint into a pricing oracle in three steps. A short adapter file (about 90 lines) tells it where the API lives and gives it real IDs to query with. Then `costql build` sends calibration queries at the API, times the answers, and learns per-resolver cost curves from measured behavior rather than assigned scores. Everything it learns is saved as one JSON file: the pricing pack.

The pack is the product. Load it in Python or JavaScript and price queries right where your code runs — zero network calls, no server, and both languages returning the exact same answer. Every quote is expressed in work-time: how much real work a query causes on the server. Each quote carries two numbers — a typical price for what the query usually costs, and a safe max sized so that billing on it never undercharges — plus a confidence rating that flags low-confidence quotes instead of failing silently.

Because APIs differ in what they can report, costQL meets each one at its own fidelity. Tier 1 puts a single stopwatch on the whole query from outside, with no server changes. Tier 2 reads per-resolver timings so parallel work stops hiding inside one clock. Tier 3 also counts batched and reused reads once instead of once per row. No tier is better than another — the right one is a fact about the API. Fields that call paid outside services, like an LLM or a licensed data feed, are named in the quote so the application can put its own price on them rather than letting costQL guess.

Contribution03

Designing What the Tool Refuses to Claim

I designed and shipped the system end to end: the calibration-over-scoring approach, the pricing pack as a single portable artifact, the three-tier fidelity model, the adapter interface, and the cross-language contract that Python and JavaScript must quote identically. The ML and numerical implementation was AI-assisted; the work I claim is the design and systems judgment — deciding what had to be measured instead of guessed, what the defaults had to protect, and what the tool must refuse to claim when it isn't sure.

The honesty defaults were the hardest design decisions. Billing on the safe max by default means the tool never quietly undercharges. Surfacing confidence means a shaky quote arrives flagged rather than dressed up as certainty. Naming external calls instead of pricing them means costQL doesn't invent numbers for services it can't see. I also built the proof surface: a browser playground with three real demo APIs calibrated into live packs, priced offline as you type, with no signup — plus the documentation and finished adapter examples that take a new user from endpoint to quote in about a minute.

Impact04

Live, Offline, and Hard to Break

costQL is live: `pip install costql` and `npm install costql` both work today, with CI running across Python 3.10 through 3.13 and the two runtimes held to identical answers. The approach was validated by calibrating three unrelated APIs — different domains, different schemas, different work profiles — into packs that price real queries in the browser at costql.com.

The result is infrastructure for a problem that is arriving fast: as agent-driven traffic grows, API operators need prices that exist before execution and hold up with no human watching. A pricing pack is small enough to ship inside an application, honest enough to bill on, and self-contained enough to need zero servers. It is the working proof of the bar the rest of my work is built to — measurable, honest, hard to break.

Building for Callers Who Can't Be Fooled
01

Measure, don't score

Static complexity points are guesses wearing uniforms. Calibrating against the live API grounds every price in observed behavior.

02

Never undercharge by default

The safe max exists so the default action is the honest one. Optimistic numbers are available, but they're information, not the bill.

03

Uncertainty is output

When confidence is low the quote says so. A flagged doubt is useful; a silent wrong answer running offline is a time bomb.

04

Meet the API where it is

The tier model makes fidelity a fact about the API rather than a sales ladder — every API gets the most truthful price it can support.

05

Claim the judgment, credit the tools

The implementation was AI-assisted and the copy says so. What can't be delegated is deciding what to measure, what to default, and what to refuse.

Explore More Projects
OneSource Web3 API Productization
OneSource Web3 API Productization

Productizing {Blockchain Data}

Pivoting to a service-first approach, this project focused on creating scalable APIs providing blockchain data, aligning with market demands and future growth.

The On-Chain Brokerage System
Hero for the On-Chain Brokerage System

The Innovation of Brokering On-Chain

A new approach to NFT brokerage built from the ground up for transparency and fun.