Downsizing logodownsizing
Documentation

Routing API

Score task routing without forwarding the request to an LLM — useful for pre-routing, analytics, or building custom model-selection logic.


Overview

The Routing API determines the minimum model tier required to guarantee quality while optimizing costs.

  • small — simple request, lightweight model
  • medium — moderate routing, mid-tier model
  • large — complex request, flagship model
  • largest — highest routing, most powerful model

Three endpoint formats are supported so you can call the API using the same message shape your application already produces.

Authentication

The Routing API uses the same Downsizing access key as all other endpoints. Pass it in the Authorization header:

Authorization: Bearer dws_YOUR_API_KEY

Find your key in the Routing API section of your dashboard.

Endpoints

All three endpoints accept up to 1 000 000 tokens of conversation history and return the same JSON response.

Anthropic format

Pass a messages array in Anthropic /v1/messages format (string or block-array content):

bash
curl -X POST \
  https://api.downsizing.dev/YOUR_INFERENCE_ID/anthropic/v1/routing \
  -H "Authorization: Bearer dws_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "user", "content": "Refactor this Python class to use dataclasses." }
    ]
  }'

OpenAI Chat Completions format

Pass a messages array in OpenAI Chat Completions format:

bash
curl -X POST \
  https://api.downsizing.dev/YOUR_INFERENCE_ID/openai/v1/chat/routing \
  -H "Authorization: Bearer dws_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "messages": [
      { "role": "user", "content": "Refactor this Python class to use dataclasses." }
    ]
  }'

OpenAI Responses API format

Pass an input array in OpenAI Responses API format:

bash
curl -X POST \
  https://api.downsizing.dev/YOUR_INFERENCE_ID/openai/v1/responses/routing \
  -H "Authorization: Bearer dws_YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "input": [
      { "type": "message", "role": "user", "content": "Refactor this Python class to use dataclasses." }
    ]
  }'

Response

All three endpoints return the same JSON object:

json
{
  "tier": "medium"
}
  • tier — one of "small", "medium", "large", or "largest"

If the scoring model is temporarily unavailable, the API falls back to a neutral score (tier: "medium") so your application never fails solely due to scorer unavailability.

SDK examples

Anthropic SDK

python
import anthropic

client = anthropic.Anthropic(
    api_key="dws_YOUR_API_KEY",
    base_url="https://api.downsizing.dev/YOUR_INFERENCE_ID/anthropic",
)

response = client._client.post(
    "/v1/routing",
    headers={"x-api-key": "dws_YOUR_API_KEY"},
    json={"messages": [{"role": "user", "content": "Write a Redis-backed job queue in Go."}]},
)
response.raise_for_status()
print(response.json()["tier"])  # "large"

OpenAI SDK

python
import openai

client = openai.OpenAI(
    api_key="dws_YOUR_API_KEY",
    base_url="https://api.downsizing.dev/YOUR_INFERENCE_ID/openai/v1",
)

response = client._client.post(
    "/chat/routing",
    headers={"Authorization": "Bearer dws_YOUR_API_KEY"},
    json={"messages": [{"role": "user", "content": "Write a Redis-backed job queue in Go."}]},
)
response.raise_for_status()
print(response.json()["tier"])  # "large"

Pricing

The Routing API is billed at $0.05 per request, charged against your pay-per-use balance. Request counts and charges are visible in the billing section of your dashboard under Routing API.


Spot an error or something not working? Tell us on Discord or email docs@downsizing.dev.