mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-26 11:14:04 +00:00
dev - token_counter endpoint
This commit is contained in:
parent
4d97ca4500
commit
e50284bc72
1 changed files with 23 additions and 0 deletions
|
@ -4765,6 +4765,29 @@ async def moderations(
|
|||
)
|
||||
|
||||
|
||||
@router.post(
|
||||
"/dev/token_counter ",
|
||||
tags=["LLM Utils"],
|
||||
dependencies=[Depends(user_api_key_auth)],
|
||||
responses={
|
||||
200: {
|
||||
"cost": {
|
||||
"description": "The calculated cost",
|
||||
"example": 0.0,
|
||||
"type": "float",
|
||||
}
|
||||
}
|
||||
},
|
||||
)
|
||||
async def token_counter(request: Request):
|
||||
""" """
|
||||
from litellm import token_counter
|
||||
|
||||
data = await request.json()
|
||||
total_tokens = token_counter(**data)
|
||||
return {"total_tokens": total_tokens}
|
||||
|
||||
|
||||
#### KEY MANAGEMENT ####
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue