Skip to content

Commit a3ca993

Browse files
authored
docs: README.md
1 parent e0221f4 commit a3ca993

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# OpenAI API Usage
2+
<img width="282" alt="image" src="https://github.com/webcpu/OpenAIAPIUsage/assets/4646838/9d8ad726-95da-4714-bf85-abee5a51c772">
3+
4+
Welcome to OpenAI API Usage, a sleek and convenient macOS menu bar application designed to keep you informed about your API usage costs every minute. With this app, you no longer need to log into multiple dashboards or wait for billing statements to understand your API consumption. API Usage Tracker does the heavy lifting by displaying your current API usage amount in USD directly in your menu bar, ensuring you have immediate access to your spending without interrupting your workflow.
5+
6+
7+
# Steps
8+
1. Click "Get Bearer Token".
9+
- <img width="214" alt="image" src="https://github.com/webcpu/OpenAIAPIUsage/assets/4646838/b1bcfd01-1dbc-458b-839c-40149dbdd8d9">
10+
11+
2. Copy OpenAI Dashboard API Bearer Token in Safari
12+
<img width="1126" alt="screenshot-dashboard" src="https://github.com/webcpu/OpenAIAPIUsage/assets/4646838/05877530-ad21-49d2-a1a9-a722ba2ff1bd">
13+
3. Click "Paste Bearer Token".
14+
15+
- <img width="214" alt="image" src="https://github.com/webcpu/OpenAIAPIUsage/assets/4646838/6b9b68ca-d4e5-4539-88e5-9b0bb3bc2dd3">
16+
17+
18+
# Obtaining a OpenAI Dashboard API Bearer Token in Safari
19+
20+
## Prerequisites
21+
22+
- Safari browser installed on your Mac.
23+
- Log in to access https://platform.openai.com/usage
24+
25+
## Steps to Retrieve a Bearer Token
26+
27+
### 1. Open Developer Tools
28+
29+
To start, log in to access https://platform.openai.com/usage. Then, open Safari's Developer Tools. If the Developer menu is not already visible in Safari, enable it by following these steps:
30+
31+
- Go to Safari > Preferences > Advanced.
32+
- Check the box at the bottom that says "Show Develop menu in menu bar."
33+
34+
Now you can access the Developer Tools by:
35+
36+
- Clicking on the "Develop" menu in the menu bar and selecting "Show Web Inspector."
37+
- Using the keyboard shortcut `Option+Cmd+I`.
38+
39+
### 2. Access the Network Tab
40+
41+
Within the Web Inspector, click on the "Network" tab. This tab records all the network requests made by the browser. If the list is empty, refresh the page to start capturing the network activity while the Web Inspector is open.
42+
43+
### 3. Trigger a Network Request
44+
45+
Bearer tokens are usually included in specific requests, such as those made during login or when accessing secured content. Execute an action that would trigger such a request to ensure the bearer token is sent.
46+
47+
### 4. Identify the Request Containing the Bearer Token
48+
49+
Look through the network requests listed in the "Network" tab to find one that includes an Authorization header with a Bearer token. This is typically found in requests to API endpoints or other backend services.
50+
51+
You might find it helpful to use the filter functionality to narrow down the requests by typing keywords related to your application's API endpoints.
52+
53+
### 5. Extract the Bearer Token
54+
55+
After locating the request with the bearer token, click on it to open the request details. Navigate to the "Headers" section and look for the "Authorization" header under the "Request Headers" subsection.
56+
57+
The Bearer token usually follows the "Bearer" scheme in this header, formatted as follows:
58+
59+
60+
61+
```Authorization: Bearer sess-31uNn4ckFvo36Mg6CdSycFdeOm...```
62+
63+
64+
The string after "Bearer" is your token. You can select and copy this token for your use.
65+
66+
## Using the Bearer Token
67+
68+
With the bearer token copied, you can use it in authenticated requests to the server. When testing with API tools like Postman or crafting requests with cURL, include this token in the Authorization header, following the same format observed in the Web Inspector.
69+
70+
## Important Considerations
71+
72+
- **Security**: Treat bearer tokens as sensitive information, as they grant access to the application on behalf of the authenticated user. Never expose them in client-side code or share them unnecessarily.
73+
- **Expiration**: Bearer tokens often expire after a certain period. If your token becomes invalid, you'll need to repeat these steps to obtain a new one.
74+
- **Environment Variability**: The exact steps and the layout of the Web Inspector may vary slightly between different versions of Safari and depending on the specific web application you are working with.

0 commit comments

Comments
 (0)