This started as a small test of a question that kept coming up: should one application use Sol, Terra, or Luna?
After sketching a few workflows, choosing one model for the whole application felt too crude. Classification and extraction have very different failure costs from debugging or final review. This repository keeps that decision in a short Python function so the rule can be inspected, tested, and changed without hiding it inside a prompt.
The goal is to send each task to the least expensive tier that reliably passes its acceptance check, while keeping an explicit escalation path for ambiguous or high-consequence work.
| Tier | Default role | Typical tasks |
|---|---|---|
| Luna | High-volume work with a clear acceptance test | Classification, extraction, normalization, formatting |
| Terra | Balanced production default | Drafting, planning, ordinary coding, bounded analysis |
| Sol | Escalation and final judgment | Ambiguous debugging, architecture decisions, final review |
The router uses task properties rather than prompt length. A long document can contain a simple extraction job, while a short debugging question can hide substantial uncertainty.
The routing logic has no third-party dependencies:
python router.py
python cost_calculator.py
python -m unittest discover -s tests -vBasic usage:
from router import TaskProfile, choose_model
task = TaskProfile(kind="classification")
model = choose_model(task)
print(model) # gpt-5.6-lunaEscalate work when ambiguity or consequence increases:
task = TaskProfile(
kind="debugging",
ambiguity="high",
consequence="medium",
)
print(choose_model(task)) # gpt-5.6-terracost_calculator.py keeps prices in configuration instead of burying them in application logic.
With the example prices dated August 28, 2026, a task using 8,000 input tokens and 1,500 output tokens costs approximately:
| Tier | Cost per task | Cost for 100,000 tasks |
|---|---|---|
| Sol | $0.0620 | $6,200 |
| Terra | $0.0340 | $3,400 |
| Luna | $0.0034 | $340 |
Pricing changes. Verify the current provider documentation before using these figures for budgeting.
The router itself does not depend on an API gateway. I used CometAPI for the integration example because switching models through one OpenAI-compatible client kept the surrounding code easier to inspect.
That convenience does not make model-specific evaluation optional. Sol, Terra, and Luna still need to be tested on representative tasks. The shared client simply keeps model selection, usage tracking, retries, and fallback behavior from being scattered across several integrations.
Install the OpenAI-compatible client and set a server-side key:
pip install openai
# PowerShell
$env:COMETAPI_API_KEY="your-key"
# macOS or Linux
export COMETAPI_API_KEY="your-key"Then run:
python example_cometapi.pyThe example keeps model identifiers configurable through environment variables because availability and naming can change:
GPT56_SOL_MODEL=gpt-5.6-sol
GPT56_TERRA_MODEL=gpt-5.6-terra
GPT56_LUNA_MODEL=gpt-5.6-lunaCheck the CometAPI documentation and current model catalog before sending production traffic.
Do not optimize for token price alone. Track:
- acceptance without editing;
- retry count;
- validation failures;
- latency;
- token usage;
- human review time.
The useful metric is:
cost per accepted task = total model cost / outputs that pass review
Start with 30 to 50 representative tasks per route. Assign each route to the least expensive tier that consistently clears the real quality bar.
router.py— explicit, testable routing policycost_calculator.py— configurable token-cost estimatesexample_cometapi.py— OpenAI-compatible CometAPI exampletests/test_router.py— routing-policy tests
This repository was prepared as part of CometAPI content work. The routing policy is intentionally provider-neutral, and the example pricing should be checked against current public documentation before use.
