Downsizing logodownsizing
Downsizing logodownsizing
Documentation

Complexity API

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


Overview

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

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

Three endpoint formats are supported so you can call the API using the same message shape your application already produces. Additional tiers and formats may be added in future.

Authentication

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

Authorization: Bearer dws_YOUR_API_KEY

You may also use X-Api-Key: dws_YOUR_API_KEY or the Anthropic SDK header x-api-key: dws_YOUR_API_KEY. Find your key in the Complexity API section of your dashboard.

Endpoints

All three endpoints accept up to 100 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/grade \
  -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/grade \
  -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/grade \
  -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/grade",
    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/grade",
    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 Complexity 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 Complexity API.