litellm/ptu.cast
2026-08-21 13:33:50 -07:00

51 lines
6.4 KiB
Text

{"version":3,"term":{"cols":80,"rows":24},"timestamp":1787344362,"command":"bash /private/tmp/claude-501/-Users-yucheng/667712b5-da77-4adc-8274-a98d7bf26f43/scratchpad/demo/demo.sh","env":{"SHELL":"/bin/zsh"}}
[0.024, "o", "\r\n\u001b[1;36m== litellm_internal_staging @ 6a75bbdddd -- PTU flat cost, config.yaml and DB ==\u001b[0m\r\n"]
[0.000, "o", "\u001b[0;33m$ git -C /Users/yucheng/litellm-wt/ptu-staging log --oneline -1 | cat\u001b[0m\r\n"]
[0.038, "o", "6a75bbdddd fix(mcp): deny the interactive dcr_bridge authorize for a user without server access (#37865)\r\n"]
[1.008, "o", "\r\n\u001b[1;36m== 1. THE GATE -- identical config.yaml, one PTU deployment with NO model_info.id ==\u001b[0m\r\n\u001b[0;33m$ curl -s http://127.0.0.1:4871/v2/model/info -H 'Authorization: Bearer sk-ptustg' | jq -r '.data[].model_name'\u001b[0m\r\n"]
[0.050, "o", "azure-ptu\r\nplain-sibling\r\n"]
[0.001, "o", " ^ flag OFF: the reservation loads, exactly as before\r\n"]
[1.008, "o", "\u001b[0;33m$ curl -s http://127.0.0.1:4872/v2/model/info -H 'Authorization: Bearer sk-ptustg' | jq -r '.data[].model_name'\u001b[0m\r\n"]
[0.022, "o", "plain-sibling\r\n"]
[0.001, "o", " ^ flag ON: it is refused and only the sibling remains\r\n"]
[1.007, "o", "\u001b[0;33m$ grep -o 'model_info.id is required.*already uses, [a-f0-9]\\{16\\}' /private/tmp/claude-501/-Users-yucheng/667712b5-da77-4adc-8274-a98d7bf26f43/scratchpad/demo/gate_on.log | head -1\u001b[0m\r\n"]
[0.011, "o", "model_info.id is required when PTU fields are set. Without one the deployment is identified by a hash of its litellm_params, so rotating a credential bills the reservation a second time under the new identity. Set it to the id this deployment already uses, 3c724828418a00f7\r\n"]
[0.000, "o", " ^ the refusal names the id the deployment already uses, so history carries forward\r\n"]
[1.007, "o", "\r\n\u001b[1;36m== 2. CONFIG PATH -- declared id, flag on (:4870) ==\u001b[0m\r\n"]
[0.000, "o", "\u001b[0;33m$ curl -s http://127.0.0.1:4870/v2/model/info -H 'Authorization: Bearer sk-ptustg' | jq -r '.data[] | \" \\(.model_name) id=\\(.model_info.id) input_cost=\\(.litellm_params.input_cost_per_token)\"'\u001b[0m\r\n"]
[0.035, "o", " azure-ptu id=azure-ptu-eastus input_cost=0.0\r\n plain-sibling id=68f281f8cbe15c32d2f532787eddeea9897aecf46e7a7a928f13d8bab8c2da93 input_cost=null\r\n"]
[0.000, "o", " ^ prepaid capacity, so per-token pricing is zeroed; the plain sibling is untouched\r\n"]
[1.009, "o", "\r\n\u001b[1;36m== 3. DB PATH -- the id rule does not reach it (a stored row already has a stable key) ==\u001b[0m\r\n"]
[0.000, "o", "\u001b[0;33m$ curl -s -X POST http://127.0.0.1:4870/model/new -H 'Authorization: Bearer sk-ptustg' -H 'Content-Type: application/json' -d '{\"model_name\":\"db-ptu\",\"litellm_params\":{\"model\":\"gemini/gemini-2.5-flash\",\"api_key\":\"x\"},\"model_info\":{\"team_id\":\"ptu-demo-team\",\"ptu_count\":5,\"cost_per_ptu_per_hour\":2.0,\"ptu_effective_from\":\"2026-08-18T00:00:00Z\"}}' -o /tmp/dbnew.json -w ' HTTP %{http_code}\\n'\u001b[0m\r\n"]
[0.092, "o", " HTTP 200\r\n"]
[0.001, "o", "\u001b[0;33m$ jq -r '\" created with id=\\(.model_info.id)\"' /tmp/dbnew.json\u001b[0m\r\n"]
[0.006, "o", " created with id=5e5c9613-2738-4eed-afbf-bef85b17c353\r\n"]
[0.000, "o", " ^ no model_info.id was sent and it was accepted: the DB mints a stable uuid\r\n"]
[1.008, "o", "\r\n\u001b[1;36m== 4. A REAL request through the config reservation (real Gemini, real money) ==\u001b[0m\r\n"]
[0.000, "o", "\u001b[0;33m$ docker exec ptustg-pg psql -U postgres -d ptustg -c 'DELETE FROM \"LiteLLM_SpendLogs\";' > /dev/null && echo ' spend log cleared'\u001b[0m\r\n"]
[0.110, "o", " spend log cleared\r\n"]
[0.027, "o", "\u001b[0;33m$ curl -s -X POST http://127.0.0.1:4870/v1/chat/completions -H 'Authorization: Bearer sk-eZQnBqeivgsnOSq1XiQsUQ' -H 'Content-Type: application/json' -d '{\"model\":\"azure-ptu\",\"messages\":[{\"role\":\"user\",\"content\":\"Reply with exactly: proof\"}],\"max_tokens\":200}' | jq -r '\" reply=\\(.choices[0].message.content) tokens=\\(.usage.prompt_tokens)/\\(.usage.completion_tokens)\"'\u001b[0m\r\n"]
[0.625, "o", " reply=proof tokens=6/25\r\n"]
[7.008, "o", "\u001b[0;33m$ docker exec ptustg-pg psql -U postgres -d ptustg -c 'SELECT model, spend, prompt_tokens, completion_tokens FROM \"LiteLLM_SpendLogs\";'\u001b[0m\r\n"]
[0.056, "o", " model | spend | prompt_tokens | completion_tokens \r\n-------------------------+-------+---------------+-------------------\r\n gemini/gemini-2.5-flash | 0 | 6 | 25\r\n(1 row)\r\n\r\n"]
[0.002, "o", " ^ real tokens, zero per-token spend: the reservation already paid for them\r\n"]
[1.006, "o", "\r\n"]
[0.000, "o", "\u001b[1;36m== 5. IDENTITY (#37794) -- rotate the credential, the bill must not move ==\u001b[0m\r\n"]
[0.000, "o", "\u001b[0;33m$ /Users/yucheng/litellm/.venv/bin/python /private/tmp/claude-501/-Users-yucheng/667712b5-da77-4adc-8274-a98d7bf26f43/scratchpad/demo/rec_identity.py 2>/dev/null\u001b[0m\r\n"]
[3.923, "o", "query-engine ac9d7041ed77bcc8a8dbd2ab6616b39013829574"]
[0.000, "o", "\r\n"]
[0.161, "o", " before rotation: 3 days, $720, identities=['ptu-east']\r\n"]
[0.009, "o", " after rotation: 3 days, $720, identities=['ptu-east']\r\n duplicate ids rejected, numeric ids normalised, org fan-out allowed:\r\n"]
[0.000, "o", " same id twice -> REFUSED model_info.id 'dup' is declared on more than one deploymen\r\n"]
[0.000, "o", " numeric dupes -> REFUSED model_info.id '123' is declared on more than one deploymen\r\n"]
[0.001, "o", " org fan-out -> loaded ['orgid', 'orgid']\r\n"]
[2.322, "o", "\r\n\u001b[1;36m== 6. PRUNE (#37793) -- only charges the run can reassess are retracted ==\u001b[0m\r\n"]
[0.000, "o", "\u001b[0;33m$ /Users/yucheng/litellm/.venv/bin/python /private/tmp/claude-501/-Users-yucheng/667712b5-da77-4adc-8274-a98d7bf26f43/scratchpad/demo/rec_prune.py 2>/dev/null\u001b[0m\r\n"]
[3.486, "o", "query-engine ac9d7041ed77bcc8a8dbd2ab6616b39013829574"]
[0.000, "o", "\r\n"]
[0.152, "o", " retired deployment, absent from every source -> kept ['dep-live', 'dep-retired']\r\n"]
[0.006, "o", " scanned deployment, PTU config removed -> pruned []\r\n"]
[0.005, "o", " nothing scanned at all, issues no deletes -> kept ['dep-orphan']\r\n"]
[0.130, "o", " the catch-up pass never prunes -> kept ['dep-live', 'dep-orphan']\r\n"]
[2.324, "o", "\r\n\u001b[1;36m== all green ==\u001b[0m\r\n"]
[0.001, "x", "0"]