- Add mask_api_key() and is_masked_or_placeholder() to llm_provider service - Return masked keys in all provider CRUD endpoints - Reject masked/placeholder keys in fetch_models and test_provider_config - Show masked key with Change button in ProviderConfig.svelte edit form - Exclude masked keys from fetch-models, test, and submit payloads on frontend - Update semantics-core skill with clarified complexity tier rules - Switch agent modes from subagent to all
649 lines
20 KiB
JSON
649 lines
20 KiB
JSON
{
|
|
"/spend/calculate": {
|
|
"post": {
|
|
"tags": [
|
|
"Budget & Spend Tracking"
|
|
],
|
|
"summary": "Calculate Spend",
|
|
"description": "Accepts all the params of completion_cost.\n\nCalculate spend **before** making call:\n\nNote: If you see a spend of $0.0 you need to set custom_pricing for your model: https://docs.litellm.ai/docs/proxy/custom_pricing\n\n```\ncurl --location 'http://localhost:4000/spend/calculate'\n--header 'Authorization: Bearer sk-1234'\n--header 'Content-Type: application/json'\n--data '{\n \"model\": \"anthropic.claude-v2\",\n \"messages\": [{\"role\": \"user\", \"content\": \"Hey, how'''s it going?\"}]\n}'\n```\n\nCalculate spend **after** making call:\n\n```\ncurl --location 'http://localhost:4000/spend/calculate'\n--header 'Authorization: Bearer sk-1234'\n--header 'Content-Type: application/json'\n--data '{\n \"completion_response\": {\n \"id\": \"chatcmpl-123\",\n \"object\": \"chat.completion\",\n \"created\": 1677652288,\n \"model\": \"gpt-3.5-turbo-0125\",\n \"system_fingerprint\": \"fp_44709d6fcb\",\n \"choices\": [{\n \"index\": 0,\n \"message\": {\n \"role\": \"assistant\",\n \"content\": \"Hello there, how may I assist you today?\"\n },\n \"logprobs\": null,\n \"finish_reason\": \"stop\"\n }]\n \"usage\": {\n \"prompt_tokens\": 9,\n \"completion_tokens\": 12,\n \"total_tokens\": 21\n }\n }\n}'\n```",
|
|
"operationId": "calculate_spend_spend_calculate_post",
|
|
"requestBody": {
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/SpendCalculateRequest"
|
|
}
|
|
}
|
|
},
|
|
"required": true
|
|
},
|
|
"responses": {
|
|
"200": {
|
|
"description": "The calculated cost",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"properties": {
|
|
"cost": {
|
|
"type": "number",
|
|
"description": "The calculated cost",
|
|
"example": 0.0
|
|
}
|
|
},
|
|
"type": "object"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"security": [
|
|
{
|
|
"APIKeyHeader": []
|
|
}
|
|
]
|
|
}
|
|
},
|
|
"/spend/logs": {
|
|
"get": {
|
|
"tags": [
|
|
"Budget & Spend Tracking"
|
|
],
|
|
"summary": "View Spend Logs",
|
|
"description": "[DEPRECATED] This endpoint is not paginated and can cause performance issues.\nPlease use `/spend/logs/v2` instead for paginated access to spend logs.\n\nView all spend logs, if request_id is provided, only logs for that request_id will be returned\n\nWhen start_date and end_date are provided:\n- summarize=true (default): Returns aggregated spend data grouped by date (maintains backward compatibility)\n- summarize=false: Returns filtered individual log entries within the date range\n\nExample Request for all logs\n```\ncurl -X GET \"http://0.0.0.0:8000/spend/logs\" -H \"Authorization: Bearer sk-1234\"\n```\n\nExample Request for specific request_id\n```\ncurl -X GET \"http://0.0.0.0:8000/spend/logs?request_id=chatcmpl-6dcb2540-d3d7-4e49-bb27-291f863f112e\" -H \"Authorization: Bearer sk-1234\"\n```\n\nExample Request for specific api_key\n```\ncurl -X GET \"http://0.0.0.0:8000/spend/logs?api_key=sk-test-example-key-123\" -H \"Authorization: Bearer sk-1234\"\n```\n\nExample Request for specific user_id\n```\ncurl -X GET \"http://0.0.0.0:8000/spend/logs?user_id=ishaan@berri.ai\" -H \"Authorization: Bearer sk-1234\"\n```\n\nExample Request for date range with individual logs (unsummarized)\n```\ncurl -X GET \"http://0.0.0.0:8000/spend/logs?start_date=2024-01-01&end_date=2024-01-02&summarize=false\" -H \"Authorization: Bearer sk-1234\"\n```",
|
|
"operationId": "view_spend_logs_spend_logs_get",
|
|
"security": [
|
|
{
|
|
"APIKeyHeader": []
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"name": "api_key",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Get spend logs based on api key",
|
|
"title": "Api Key"
|
|
},
|
|
"description": "Get spend logs based on api key"
|
|
},
|
|
{
|
|
"name": "user_id",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Get spend logs based on user_id",
|
|
"title": "User Id"
|
|
},
|
|
"description": "Get spend logs based on user_id"
|
|
},
|
|
{
|
|
"name": "request_id",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "request_id to get spend logs for specific request_id. If none passed then pass spend logs for all requests",
|
|
"title": "Request Id"
|
|
},
|
|
"description": "request_id to get spend logs for specific request_id. If none passed then pass spend logs for all requests"
|
|
},
|
|
{
|
|
"name": "start_date",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Time from which to start viewing key spend",
|
|
"title": "Start Date"
|
|
},
|
|
"description": "Time from which to start viewing key spend"
|
|
},
|
|
{
|
|
"name": "end_date",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Time till which to view key spend",
|
|
"title": "End Date"
|
|
},
|
|
"description": "Time till which to view key spend"
|
|
},
|
|
{
|
|
"name": "summarize",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"type": "boolean",
|
|
"description": "When start_date and end_date are provided, summarize=true returns aggregated data by date (legacy behavior), summarize=false returns filtered individual logs",
|
|
"default": true,
|
|
"title": "Summarize"
|
|
},
|
|
"description": "When start_date and end_date are provided, summarize=true returns aggregated data by date (legacy behavior), summarize=false returns filtered individual logs"
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successful Response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/LiteLLM_SpendLogs"
|
|
},
|
|
"title": "Response 200 View Spend Logs Spend Logs Get"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/spend/logs/v2": {
|
|
"get": {
|
|
"tags": [
|
|
"Budget & Spend Tracking"
|
|
],
|
|
"summary": "Ui View Spend Logs",
|
|
"description": "View spend logs with pagination support.\nAvailable at both `/spend/logs/v2` (public API) and `/spend/logs/ui` (internal UI).\n\nReturns paginated response with data, total, page, page_size, and total_pages.\n\nExample:\n```\ncurl -X GET \"http://0.0.0.0:8000/spend/logs/v2?start_date=2025-11-25%2000:00:00&end_date=2025-11-26%2023:59:59&page=1&page_size=50\" -H \"Authorization: Bearer sk-1234\"\n```",
|
|
"operationId": "ui_view_spend_logs_spend_logs_v2_get",
|
|
"security": [
|
|
{
|
|
"APIKeyHeader": []
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"name": "api_key",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Get spend logs based on api key",
|
|
"title": "Api Key"
|
|
},
|
|
"description": "Get spend logs based on api key"
|
|
},
|
|
{
|
|
"name": "user_id",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Get spend logs based on user_id",
|
|
"title": "User Id"
|
|
},
|
|
"description": "Get spend logs based on user_id"
|
|
},
|
|
{
|
|
"name": "request_id",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "request_id to get spend logs for specific request_id",
|
|
"title": "Request Id"
|
|
},
|
|
"description": "request_id to get spend logs for specific request_id"
|
|
},
|
|
{
|
|
"name": "team_id",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter spend logs by team_id",
|
|
"title": "Team Id"
|
|
},
|
|
"description": "Filter spend logs by team_id"
|
|
},
|
|
{
|
|
"name": "min_spend",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "number"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter logs with spend greater than or equal to this value",
|
|
"title": "Min Spend"
|
|
},
|
|
"description": "Filter logs with spend greater than or equal to this value"
|
|
},
|
|
{
|
|
"name": "max_spend",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "number"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter logs with spend less than or equal to this value",
|
|
"title": "Max Spend"
|
|
},
|
|
"description": "Filter logs with spend less than or equal to this value"
|
|
},
|
|
{
|
|
"name": "start_date",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Time from which to start viewing key spend",
|
|
"title": "Start Date"
|
|
},
|
|
"description": "Time from which to start viewing key spend"
|
|
},
|
|
{
|
|
"name": "end_date",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Time till which to view key spend",
|
|
"title": "End Date"
|
|
},
|
|
"description": "Time till which to view key spend"
|
|
},
|
|
{
|
|
"name": "page",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"type": "integer",
|
|
"minimum": 1,
|
|
"description": "Page number for pagination",
|
|
"default": 1,
|
|
"title": "Page"
|
|
},
|
|
"description": "Page number for pagination"
|
|
},
|
|
{
|
|
"name": "page_size",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"type": "integer",
|
|
"maximum": 100,
|
|
"minimum": 1,
|
|
"description": "Number of items per page",
|
|
"default": 50,
|
|
"title": "Page Size"
|
|
},
|
|
"description": "Number of items per page"
|
|
},
|
|
{
|
|
"name": "status_filter",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter logs by status (e.g., success, failure)",
|
|
"title": "Status Filter"
|
|
},
|
|
"description": "Filter logs by status (e.g., success, failure)"
|
|
},
|
|
{
|
|
"name": "model",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter logs by model",
|
|
"title": "Model"
|
|
},
|
|
"description": "Filter logs by model"
|
|
},
|
|
{
|
|
"name": "model_id",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter logs by model ID (litellm model deployment id)",
|
|
"title": "Model Id"
|
|
},
|
|
"description": "Filter logs by model ID (litellm model deployment id)"
|
|
},
|
|
{
|
|
"name": "key_alias",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter logs by key alias",
|
|
"title": "Key Alias"
|
|
},
|
|
"description": "Filter logs by key alias"
|
|
},
|
|
{
|
|
"name": "end_user",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter logs by end user",
|
|
"title": "End User"
|
|
},
|
|
"description": "Filter logs by end user"
|
|
},
|
|
{
|
|
"name": "error_code",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter logs by error code (e.g., '404', '500')",
|
|
"title": "Error Code"
|
|
},
|
|
"description": "Filter logs by error code (e.g., '404', '500')"
|
|
},
|
|
{
|
|
"name": "error_message",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Filter logs by error message (partial string match)",
|
|
"title": "Error Message"
|
|
},
|
|
"description": "Filter logs by error message (partial string match)"
|
|
},
|
|
{
|
|
"name": "sort_by",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"type": "string",
|
|
"description": "Sort logs by field: spend, total_tokens, startTime, or endTime",
|
|
"default": "startTime",
|
|
"title": "Sort By"
|
|
},
|
|
"description": "Sort logs by field: spend, total_tokens, startTime, or endTime"
|
|
},
|
|
{
|
|
"name": "sort_order",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Sort order: asc or desc",
|
|
"default": "desc",
|
|
"title": "Sort Order"
|
|
},
|
|
"description": "Sort order: asc or desc"
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successful Response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "object",
|
|
"additionalProperties": true,
|
|
"title": "Response 200 Ui View Spend Logs Spend Logs V2 Get"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"/spend/tags": {
|
|
"get": {
|
|
"tags": [
|
|
"Budget & Spend Tracking"
|
|
],
|
|
"summary": "View Spend Tags",
|
|
"description": "LiteLLM Enterprise - View Spend Per Request Tag\n\nExample Request:\n```\ncurl -X GET \"http://0.0.0.0:8000/spend/tags\" -H \"Authorization: Bearer sk-1234\"\n```\n\nSpend with Start Date and End Date\n```\ncurl -X GET \"http://0.0.0.0:8000/spend/tags?start_date=2022-01-01&end_date=2022-02-01\" -H \"Authorization: Bearer sk-1234\"\n```",
|
|
"operationId": "view_spend_tags_spend_tags_get",
|
|
"security": [
|
|
{
|
|
"APIKeyHeader": []
|
|
}
|
|
],
|
|
"parameters": [
|
|
{
|
|
"name": "start_date",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Time from which to start viewing key spend",
|
|
"title": "Start Date"
|
|
},
|
|
"description": "Time from which to start viewing key spend"
|
|
},
|
|
{
|
|
"name": "end_date",
|
|
"in": "query",
|
|
"required": false,
|
|
"schema": {
|
|
"anyOf": [
|
|
{
|
|
"type": "string"
|
|
},
|
|
{
|
|
"type": "null"
|
|
}
|
|
],
|
|
"description": "Time till which to view key spend",
|
|
"title": "End Date"
|
|
},
|
|
"description": "Time till which to view key spend"
|
|
}
|
|
],
|
|
"responses": {
|
|
"200": {
|
|
"description": "Successful Response",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"type": "array",
|
|
"items": {
|
|
"$ref": "#/components/schemas/LiteLLM_SpendLogs"
|
|
},
|
|
"title": "Response 200 View Spend Tags Spend Tags Get"
|
|
}
|
|
}
|
|
}
|
|
},
|
|
"422": {
|
|
"description": "Validation Error",
|
|
"content": {
|
|
"application/json": {
|
|
"schema": {
|
|
"$ref": "#/components/schemas/HTTPValidationError"
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |