diff --git a/cookbook/Proxy_Batch_Users.ipynb b/cookbook/Proxy_Batch_Users.ipynb index 4e3c7ce92..70521f5ab 100644 --- a/cookbook/Proxy_Batch_Users.ipynb +++ b/cookbook/Proxy_Batch_Users.ipynb @@ -1,30 +1,21 @@ { - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "provenance": [] - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, "cells": [ { "cell_type": "markdown", - "source": [ - "# Environment Setup" - ], "metadata": { "id": "680oRk1af-xJ" - } + }, + "source": [ + "# Environment Setup" + ] }, { "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "X7TgJFn8f88p" + }, + "outputs": [], "source": [ "import csv\n", "from typing import Optional\n", @@ -33,15 +24,15 @@ "\n", "proxy_base_url = \"http://0.0.0.0:4000\" # 👈 SET TO PROXY URL\n", "master_key = \"sk-1234\" # 👈 SET TO PROXY MASTER KEY" - ], - "metadata": { - "id": "X7TgJFn8f88p" - }, - "execution_count": null, - "outputs": [] + ] }, { "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "rauw8EOhgBz5" + }, + "outputs": [], "source": [ "## GLOBAL HTTP CLIENT ## - faster http calls\n", "class HTTPHandler:\n", @@ -78,27 +69,27 @@ " return response\n", " except Exception as e:\n", " raise e\n" - ], - "metadata": { - "id": "rauw8EOhgBz5" - }, - "execution_count": null, - "outputs": [] + ] }, { "cell_type": "markdown", + "metadata": { + "id": "7LXN8zaLgOie" + }, "source": [ "# Import Sheet\n", "\n", "\n", "Format: | ID | Name | Max Budget |" - ], - "metadata": { - "id": "7LXN8zaLgOie" - } + ] }, { "cell_type": "code", + "execution_count": null, + "metadata": { + "id": "oiED0usegPGf" + }, + "outputs": [], "source": [ "async def import_sheet():\n", " tasks = []\n", @@ -126,24 +117,19 @@ " await http_client.close()\n", "\n", "asyncio.run(import_sheet())" - ], - "metadata": { - "id": "oiED0usegPGf" - }, - "execution_count": null, - "outputs": [] + ] }, { "cell_type": "markdown", + "metadata": { + "id": "E7M0Li_UgJeZ" + }, "source": [ "# Create Users + Keys\n", "\n", "- Creates a user\n", "- Creates a key with max budget" - ], - "metadata": { - "id": "E7M0Li_UgJeZ" - } + ] }, { "cell_type": "code", @@ -168,7 +154,7 @@ " data=json.dumps({\n", " \"user_id\": user_id,\n", " \"key_alias\": f\"{user_id}-key\",\n", - " \"max_budget\": max_budget\n", + " \"max_budget\": max_budget # 👈 KEY CHANGE: SETS MAX BUDGET PER KEY\n", " })\n", " )\n", " print(f\"response: {response.text}\")\n", @@ -191,7 +177,8 @@ " data=json.dumps({\n", " \"user_id\": user_id,\n", " \"user_alias\": user_name,\n", - " \"auto_create_key\": False\n", + " \"auto_create_key\": False,\n", + " # \"max_budget\": max_budget # 👈 [OPTIONAL] Sets max budget per user (if you want to set a max budget across keys)\n", " })\n", " )\n", "\n", @@ -199,5 +186,19 @@ " return await create_key_with_alias(client=client, user_id=user_id, max_budget=max_budget)\n" ] } - ] -} \ No newline at end of file + ], + "metadata": { + "colab": { + "provenance": [] + }, + "kernelspec": { + "display_name": "Python 3", + "name": "python3" + }, + "language_info": { + "name": "python" + } + }, + "nbformat": 4, + "nbformat_minor": 0 +}