Skip to main content

Syncing Models to GitHub model_context_window

Sync model pricing data from GitHub's model_prices_and_context_window.json file outside of the LiteLLM UI.

📹 Video Tutorial: Watch how to sync models via the Admin UI

Quick Start​

Manual sync:

curl -X POST "https://your-proxy-url/reload/model_cost_map" \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json"

Automatic sync every 6 hours:

curl -X POST "https://your-proxy-url/schedule/model_cost_map_reload?hours=6" \
-H "Authorization: Bearer YOUR_ADMIN_TOKEN" \
-H "Content-Type: application/json"

API Endpoints​

EndpointMethodDescription
/reload/model_cost_mapPOSTManual sync
/schedule/model_cost_map_reload?hours={hours}POSTSchedule periodic sync
/schedule/model_cost_map_reloadDELETECancel scheduled sync
/schedule/model_cost_map_reload/statusGETCheck sync status

Authentication: Requires admin role or master key

Python Example​

import requests

def sync_models(proxy_url, admin_token):
response = requests.post(
f"{proxy_url}/reload/model_cost_map",
headers={"Authorization": f"Bearer {admin_token}"}
)
return response.json()

# Usage
result = sync_models("https://your-proxy-url", "your-admin-token")
print(result['message'])

Configuration​

Custom model cost map URL:

export LITELLM_MODEL_COST_MAP_URL="https://raw.githubusercontent.com/BerriAI/litellm/main/model_prices_and_context_window.json"

Use local model cost map:

export LITELLM_LOCAL_MODEL_COST_MAP=True