thisFasih commited on
Commit
780b466
·
verified ·
1 Parent(s): d2ec9da

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +138 -126
README.md CHANGED
@@ -1,126 +1,138 @@
1
- # API Key Validator for OpenAI & Gemini
2
-
3
- A lightweight Gradio web app that lets you quickly validate API keys for both OpenAI and Google Gemini (Generative Language API) and view the list of available models for each provider.
4
-
5
- ## Features
6
- - Validate OpenAI API key (calls `GET /v1/models`).
7
- - Validate Gemini API key (calls `GET /v1beta/models`).
8
- - Secure password-style input fields (keys never echoed in plain text).
9
- - Immediate feedback: success, failure, and raw error payload when invalid.
10
- - Displays available model IDs / names returned by each provider.
11
- - Zero persistence: keys are not stored, logged, or transmitted elsewhere.
12
-
13
- ## Tech Stack
14
- - **Python** (>=3.9 recommended)
15
- - **Gradio** for the UI
16
- - **Requests** for outbound HTTPS calls
17
-
18
- ## Getting Started
19
- ### 1. Clone / Download
20
- ```bash
21
- git clone <your-repo-url>
22
- cd api-key-tester-app
23
- ```
24
- (Replace folder name if different.)
25
-
26
- ### 2. Create Virtual Environment (Optional but Recommended)
27
- ```bash
28
- python -m venv .venv
29
- # Windows
30
- .venv\Scripts\activate
31
- # macOS / Linux
32
- source .venv/bin/activate
33
- ```
34
-
35
- ### 3. Install Dependencies
36
- ```bash
37
- pip install -r requirements.txt
38
- ```
39
-
40
- ### 4. Run the App
41
- ```bash
42
- python app.py
43
- ```
44
- Gradio will print a local URL (e.g., `http://127.0.0.1:7860`) and, if enabled, a public share URL.
45
-
46
- ## Usage
47
- 1. Enter your OpenAI API key (format typically starts with `sk-...`).
48
- 2. Enter your Gemini API key (Google AI Studio issued key).
49
- 3. Click **"Test Keys"**.
50
- 4. View validation results and model lists.
51
-
52
- If a key is invalid, the raw response body (error JSON / message) is shown in the results panel for troubleshooting.
53
-
54
- ## Security & Privacy
55
- - Inputs use `type="password"` in Gradio (no on-screen echo).
56
- - Keys are only transmitted directly to official provider endpoints.
57
- - No server-side storage, caching, or logging of keys.
58
- - Avoid sharing screenshots that contain sensitive error payloads.
59
-
60
- ## Environment Variables (Optional Enhancement)
61
- Currently keys are entered manually. You could extend the app to pre-fill from environment variables (example shown for convenience):
62
- Add to your shell:
63
- ```bash
64
- # Windows PowerShell
65
- $Env:OPENAI_API_KEY="sk-your-key"
66
- $Env:GEMINI_API_KEY="your-gemini-key"
67
- ```
68
-
69
- ## Error Handling
70
- - Network errors captured and surfaced as exception strings.
71
- - Non-200 status codes display provider error payload (`resp.text`).
72
- - Rate limits or expired keys will return provider-specific error JSON.
73
-
74
- ## Roadmap / Ideas
75
- - Add support for additional providers (Anthropic, Mistral, etc.).
76
- - Show quota usage (if endpoint available).
77
- - Dark mode toggle.
78
- - Simple caching of last successful model list.
79
- - Downloadable validation report.
80
-
81
- ## Testing
82
- There are no automated tests yet. Suggested next steps:
83
- - Unit test helper functions `test_openai_key` and `test_gemini_key` using mocked `requests.get`.
84
- - Add a smoke test ensuring the Gradio interface launches without exceptions.
85
-
86
- ## Contributing
87
- 1. Fork the repository.
88
- 2. Create a feature branch: `git checkout -b feature/<name>`.
89
- 3. Commit changes: `git commit -m "Add <feature>"`.
90
- 4. Push: `git push origin feature/<name>`.
91
- 5. Open a Pull Request.
92
-
93
- Please keep changes minimal and focused. For significant UI or provider additions, open an issue first to discuss.
94
-
95
- ## Configuration Notes
96
- | Provider | Endpoint Used | Purpose |
97
- |----------|---------------|---------|
98
- | OpenAI | `GET https://api.openai.com/v1/models` | Validates key + lists models |
99
- | Gemini | `GET https://generativelanguage.googleapis.com/v1beta/models?key=...` | Validates key + lists models |
100
-
101
- ## Limitations
102
- - Does not test key against every possible endpoint.
103
- - Model lists may differ if access is restricted or in preview.
104
- - No persistent audit trail by design.
105
-
106
- ## License
107
- Specify a license (e.g., MIT, Apache-2.0). If none provided, all rights reserved by default.
108
-
109
- ## Disclaimer
110
- This tool is for quick manual validation. Always follow provider security best practices and rotate credentials regularly.
111
-
112
- ## FAQ
113
- **Q: Are my keys stored anywhere?**
114
- A: No. They exist only in session memory for the duration of the Streamlit interaction.
115
-
116
- **Q: Why is my valid key showing limited models?**
117
- A: Some models require special access or are in restricted beta.
118
-
119
- **Q: Can I deploy this?**
120
- A: Yes—e.g., Streamlit Community Cloud can run Gradio apps too. Select your GitHub repo, branch `master`, and main file path `app.py`. Leave the App URL blank or choose a simple subdomain. Alternatively, deploy on Spaces (Hugging Face) or Render.
121
-
122
- **Q: How can I add another provider?**
123
- A: Create a new helper similar to `test_openai_key`, call its endpoint, parse model list, and extend the UI block.
124
-
125
- ---
126
- Feel free to customize sections like License or add CI badges once the project is in a public repo.
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # API Key Validator for OpenAI & Gemini
2
+
3
+ # API Key Validator for OpenAI & Gemini
4
+ ---
5
+ title: API Key Validator
6
+ emoji: 🔑
7
+ colorFrom: blue
8
+ colorTo: green
9
+ sdk: gradio
10
+ sdk_version: "4.31.0"
11
+ app_file: app.py
12
+ pinned: false
13
+ ---
14
+
15
+ A lightweight Gradio web app that lets you quickly validate API keys for both OpenAI and Google Gemini (Generative Language API) and view the list of available models for each provider.
16
+
17
+ ## Features
18
+ - Validate OpenAI API key (calls `GET /v1/models`).
19
+ - Validate Gemini API key (calls `GET /v1beta/models`).
20
+ - Secure password-style input fields (keys never echoed in plain text).
21
+ - Immediate feedback: success, failure, and raw error payload when invalid.
22
+ - Displays available model IDs / names returned by each provider.
23
+ - Zero persistence: keys are not stored, logged, or transmitted elsewhere.
24
+
25
+ ## Tech Stack
26
+ - **Python** (>=3.9 recommended)
27
+ - **Gradio** for the UI
28
+ - **Requests** for outbound HTTPS calls
29
+
30
+ ## Getting Started
31
+ ### 1. Clone / Download
32
+ ```bash
33
+ git clone <your-repo-url>
34
+ cd api-key-tester-app
35
+ ```
36
+ (Replace folder name if different.)
37
+
38
+ ### 2. Create Virtual Environment (Optional but Recommended)
39
+ ```bash
40
+ python -m venv .venv
41
+ # Windows
42
+ .venv\Scripts\activate
43
+ # macOS / Linux
44
+ source .venv/bin/activate
45
+ ```
46
+
47
+ ### 3. Install Dependencies
48
+ ```bash
49
+ pip install -r requirements.txt
50
+ ```
51
+
52
+ ### 4. Run the App
53
+ ```bash
54
+ python app.py
55
+ ```
56
+ Gradio will print a local URL (e.g., `http://127.0.0.1:7860`) and, if enabled, a public share URL.
57
+
58
+ ## Usage
59
+ 1. Enter your OpenAI API key (format typically starts with `sk-...`).
60
+ 2. Enter your Gemini API key (Google AI Studio issued key).
61
+ 3. Click **"Test Keys"**.
62
+ 4. View validation results and model lists.
63
+
64
+ If a key is invalid, the raw response body (error JSON / message) is shown in the results panel for troubleshooting.
65
+
66
+ ## Security & Privacy
67
+ - Inputs use `type="password"` in Gradio (no on-screen echo).
68
+ - Keys are only transmitted directly to official provider endpoints.
69
+ - No server-side storage, caching, or logging of keys.
70
+ - Avoid sharing screenshots that contain sensitive error payloads.
71
+
72
+ ## Environment Variables (Optional Enhancement)
73
+ Currently keys are entered manually. You could extend the app to pre-fill from environment variables (example shown for convenience):
74
+ Add to your shell:
75
+ ```bash
76
+ # Windows PowerShell
77
+ $Env:OPENAI_API_KEY="sk-your-key"
78
+ $Env:GEMINI_API_KEY="your-gemini-key"
79
+ ```
80
+
81
+ ## Error Handling
82
+ - Network errors captured and surfaced as exception strings.
83
+ - Non-200 status codes display provider error payload (`resp.text`).
84
+ - Rate limits or expired keys will return provider-specific error JSON.
85
+
86
+ ## Roadmap / Ideas
87
+ - Add support for additional providers (Anthropic, Mistral, etc.).
88
+ - Show quota usage (if endpoint available).
89
+ - Dark mode toggle.
90
+ - Simple caching of last successful model list.
91
+ - Downloadable validation report.
92
+
93
+ ## Testing
94
+ There are no automated tests yet. Suggested next steps:
95
+ - Unit test helper functions `test_openai_key` and `test_gemini_key` using mocked `requests.get`.
96
+ - Add a smoke test ensuring the Gradio interface launches without exceptions.
97
+
98
+ ## Contributing
99
+ 1. Fork the repository.
100
+ 2. Create a feature branch: `git checkout -b feature/<name>`.
101
+ 3. Commit changes: `git commit -m "Add <feature>"`.
102
+ 4. Push: `git push origin feature/<name>`.
103
+ 5. Open a Pull Request.
104
+
105
+ Please keep changes minimal and focused. For significant UI or provider additions, open an issue first to discuss.
106
+
107
+ ## Configuration Notes
108
+ | Provider | Endpoint Used | Purpose |
109
+ |----------|---------------|---------|
110
+ | OpenAI | `GET https://api.openai.com/v1/models` | Validates key + lists models |
111
+ | Gemini | `GET https://generativelanguage.googleapis.com/v1beta/models?key=...` | Validates key + lists models |
112
+
113
+ ## Limitations
114
+ - Does not test key against every possible endpoint.
115
+ - Model lists may differ if access is restricted or in preview.
116
+ - No persistent audit trail by design.
117
+
118
+ ## License
119
+ Specify a license (e.g., MIT, Apache-2.0). If none provided, all rights reserved by default.
120
+
121
+ ## Disclaimer
122
+ This tool is for quick manual validation. Always follow provider security best practices and rotate credentials regularly.
123
+
124
+ ## FAQ
125
+ **Q: Are my keys stored anywhere?**
126
+ A: No. They exist only in session memory for the duration of the Streamlit interaction.
127
+
128
+ **Q: Why is my valid key showing limited models?**
129
+ A: Some models require special access or are in restricted beta.
130
+
131
+ **Q: Can I deploy this?**
132
+ A: Yes—e.g., Streamlit Community Cloud can run Gradio apps too. Select your GitHub repo, branch `master`, and main file path `app.py`. Leave the App URL blank or choose a simple subdomain. Alternatively, deploy on Spaces (Hugging Face) or Render.
133
+
134
+ **Q: How can I add another provider?**
135
+ A: Create a new helper similar to `test_openai_key`, call its endpoint, parse model list, and extend the UI block.
136
+
137
+ ---
138
+ Feel free to customize sections like License or add CI badges once the project is in a public repo.