Skip to main content

mellontoken

Client for the mellontoken gateway.

import mellontoken

answer = await mellontoken.ask("Summarise this tender in one line.")
parsed = await mellontoken.ask(document_text, schema=DocExtraction)
full   = await mellontoken.ask_full(document_text, schema=DocExtraction)
full.cost_usd     # "0.00059550"
full.model        # the model that actually served it

Letting the gateway pick the model

answer = await mellontoken.ask(prompt, model="auto")
answer = await mellontoken.ask(prompt, model="auto", tier="high")   # bound the spend

full = await mellontoken.ask_full(prompt, model="auto")
full.route.model_slug    # what it picked
full.route.task          # the grid row it read
full.route.explanation   # why, in a paragraph you can argue with

One command. model="auto" makes the gateway classify the prompt on three axes (task, effort, capability), read the resulting grid cell, and serve the answer from whatever that cell names — and ask_full reports the decision on Answer.route, so routing is legible after the fact without a second call to ask about it.

Those three classifier calls are billed, per call. They cost roughly $0.005 against a completion's dollars and land on the ledger as kind=classifier rows, so the spend is visible rather than hidden. A service sending the same shape of prompt a thousand times should read full.route.model_slug once and then name that slug: the decision is a property of the workload, not of each call.

tier= bounds what the router may spend and outranks the effort classifier, because a tier is a statement about your budget rather than a property of the text. Set it per call, or once via MELLONTOKEN_TIER. It is only read on the auto path — with a named model it is logged as ignored rather than silently dropped.

A router that resolves nothing is not an error. route.model_slug is None when the capability gate rejected every candidate in the cell; ask logs the explanation and falls back to MELLONTOKEN_MODEL, which is what the gateway's own advice is — keep your own model. The one case that raises is MELLONTOKEN_MODEL=auto as well, where there is no own model to keep.

Configuration

From the environment:

variable default
MELLONTOKEN_BASE_URL http://localhost:8000/api/v1
MELLONTOKEN_API_KEY — required
MELLONTOKEN_MODEL gemini-3.7-flash (or auto)
MELLONTOKEN_TIER — (the effort classifier judges it)
MELLONTOKEN_MAX_TOKENS 32000
MELLONTOKEN_TIMEOUT 600

or in code:

mellontoken.configure(base_url="http://gateway:8000/api/v1", api_key=key, model="gpt-5.6-luna")

From inside a container the host's gateway is host.docker.internal, not localhost.

What ask does that a bare HTTP call does not

  • Sends the schema twice, as response_format and as prompt text. The request field is only honoured where the provider can enforce it; Gemini accepts a schema it will then ignore, and the field names in the prompt are what stop it inventing col_idx for col.
  • Reads JSON out of a fenced reply, and wraps a bare list under the schema's single array field when that is unambiguous.
  • Retries the shape, not the wire. A 401/402/403/404 is final — a key, a budget, a permission, a missing model — and raises immediately. A reply that did not parse is retried three times.
  • Logs the cost of every call, which is the reason to route through the gateway at all: mellon.cost_usd is the only per-call price any provider path reports.
  • Resolves model="auto" before sending anything. auto is a request for a decision, not a catalogue slug, and the completion endpoint would 404 it. Resolved once per ask, outside the retry loop: a reply that did not parse is a reason to ask the same model again, not to pay three classifiers for the same decision again.

Install

Built from this directory, which lives in the gateway's own repo so the client and the endpoint version together:

uv build            # -> dist/mellontoken-0.1.0-py3-none-any.whl

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mellontoken-0.1.0.tar.gz (10.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mellontoken-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file mellontoken-0.1.0.tar.gz.

File metadata

  • Download URL: mellontoken-0.1.0.tar.gz
  • Upload date:
  • Size: 10.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mellontoken-0.1.0.tar.gz
Algorithm Hash digest
SHA256 60957c81ed15e48ff9b891ac31ca42aa4d2f480da68199fed0324324227ff377
MD5 069e48a8ade4060c03ad79a53557f615
BLAKE2b-256 09cb64d43c472080e1077cb5239e371945038f4d0e181f468f9586836a76ff98

See more details on using hashes here.

File details

Details for the file mellontoken-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: mellontoken-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.12.5 {"installer":{"name":"uv","version":"0.12.5","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for mellontoken-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 85ced2a3b911079c4a13096fc0ec4ed5317c73647b044be322bfb83ea94b8c7a
MD5 e2d8c9941fa8b4f561063cafb4c65ba3
BLAKE2b-256 d925f0da58c6ee2f08c740ad51e942365f1b09e4ac7aaba25b14be938843d13b

See more details on using hashes here.

Release history Release notifications | RSS feed

0.2.0

2 files

This release

0.1.0 This release

2 files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page