Credit Groups
- openwebui_token_tracking.credit_groups.create_credit_group(credit_group_name, credit_allowance, description, database_url=None)[source]
Creates a credit group in the database.
- Parameters:
credit_group_name (str) – Name of the credit group to be created.
credit_allowance (int) – Maximum credit allowance granted to members of this group.
description (str) – Description e of the credit group to be created.
database_url (str, optional) – URL of the database. If None, uses env variable
DATABASE_URL
- Raises:
KeyError – Raised if a credit group of this name already exists.
- openwebui_token_tracking.credit_groups.get_credit_group(credit_group_name, database_url=None)[source]
Retrieves a credit group from the database by its name and returns it as a dictionary.
- Parameters:
- Returns:
Dictionary containing the credit group properties (id, name, max_credit, description)
- Return type:
- Raises:
KeyError – Raised if the credit group of that name could not be found
- openwebui_token_tracking.credit_groups.list_credit_groups(database_url=None)[source]
Lists all credit groups in the database in a readable format.
- openwebui_token_tracking.credit_groups.update_credit_group(credit_group_name, new_credit_allowance=None, new_description=None, new_name=None, database_url=None)[source]
Updates an existing credit group in the database.
- Parameters:
credit_group_name (str) – Name of the credit group to update
new_credit_allowance (int, optional) – New maximum credit allowance for the group
new_description (str, optional) – New description for the group
new_name (str, optional) – New name for the group
database_url (str, optional) – URL of the database. If None, uses env variable
DATABASE_URL
- Raises:
KeyError – Raised if the credit group of that name could not be found
ValueError – Raised if no updates are specified
- openwebui_token_tracking.credit_groups.upsert_credit_group(credit_group_name, credit_allowance, description, database_url=None)[source]
Creates a new credit group or updates an existing one if it already exists.
- Parameters:
- Returns:
True if a new group was created, False if an existing group was updated
- Return type:
- openwebui_token_tracking.credit_groups.delete_credit_group(credit_group_name, database_url=None, force=False)[source]
Deletes a credit group from the database.
- Parameters:
- Raises:
KeyError – Raised if the credit group of that name could not be found
ValueError – Raised if the group has users and force=False
- openwebui_token_tracking.credit_groups.add_user(user_id, credit_group_name, database_url=None)[source]
Add the specified user to the credit group
- openwebui_token_tracking.credit_groups.remove_user(user_id, credit_group_name, database_url=None)[source]
Removes a user from the specified credit group.
- Parameters:
- Raises:
KeyError – Raised if the credit group of that name could not be found
ValueError – Raised if the user is not in the specified credit group
- openwebui_token_tracking.credit_groups.list_users(credit_group_name, database_url=None)[source]
Lists all users in a specific credit group.
- Parameters:
- Returns:
List of dictionaries containing user information
- Return type:
- Raises:
KeyError – Raised if the credit group of that name could not be found