-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheck_api_keys.py
More file actions
115 lines (99 loc) · 4.63 KB
/
Copy pathcheck_api_keys.py
File metadata and controls
115 lines (99 loc) · 4.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
import os
from openai import OpenAI
from dotenv import load_dotenv
import google.generativeai as genai
# Load environment variables from .env file
load_dotenv(override=True)
# ==============================================================================
# 1. GOOGLE GEMINI API TRACK
# ==============================================================================
# AVAILABLE FREE TIER MODELS IN 2026:
# - "gemini-3-flash" : Current default, optimized for speed & general use.
# - "gemini-3.1-flash-lite" : High-efficiency budget tier, lowest latency.
# ==============================================================================
def verify_gemini():
print("\n🟢 Testing Google Gemini API Key...")
api_key = os.getenv("GEMINI_API_KEY") or os.getenv("GOOGLE_API_KEY")
if not api_key:
print(" ❌ Skipped: No GEMINI_API_KEY or GOOGLE_API_KEY found in environment.")
return False
try:
genai.configure(api_key=api_key)
# Using the standard free tier baseline model
model = genai.GenerativeModel("gemini-3-flash")
response = model.generate_content("Respond with exactly the phrase: 'Gemini Key is Working!'")
print(f" ✅ SUCCESS! Response: {response.text.strip()}")
return True
except Exception as e:
print(f" ❌ FAILED: Authentication or quota issue.")
print(f" Details: {e}")
return False
# ==============================================================================
# 2. XAI GROK API TRACK
# ==============================================================================
# AVAILABLE MODELS IN 2026 (Note: xAI API is pay-as-you-go / token-metered):
# - "grok-4.1-fast" : Extremely cheap, high-throughput model (~$0.20 per 1M input tokens).
# - "grok-4.5" : Flagship high-reasoning model.
# ==============================================================================
def verify_grok():
print("\n🟢 Testing xAI Grok API Key...")
api_key = os.getenv("XAI_API_KEY")
if not api_key:
print(" ❌ Skipped: No XAI_API_KEY found in environment.")
return False
try:
# Grok uses the standard OpenAI-compatible SDK formatting
client = OpenAI(
api_key=api_key,
base_url="https://api.x.ai/v1"
)
completion = client.chat.completions.create(
model="grok-4.1-fast",
messages=[{"role": "user", "content": "Respond with exactly: 'Grok Key is Working!'"}]
)
print(f" ✅ SUCCESS! Response: {completion.choices[0].message.content.strip()}")
return True
except Exception as e:
print(f" ❌ FAILED: Check your credit balance or API Key string.")
print(f" Details: {e}")
return False
# ==============================================================================
# 3. OPENROUTER API TRACK
# ==============================================================================
# CORE 100% FREE LIVE POPULAR MODELS IN 2026 (Appended with :free):
# - "meta-llama/llama-3.3-70b-instruct:free" : Outstanding large chat & reasoning model.
# - "meta-llama/llama-3.2-3b-instruct:free" : Fast, short-context compact model.
# - "qwen/qwen3-coder:free" : Powerful code generation and structure exploration.
# - "nvidia/nemotron-3-ultra-550b-a55b:free" : Deep context handling up to 1M tokens.
# - "google/gemma-4-31b-it:free" : Mid-size instruction following.
# ==============================================================================
def verify_openrouter():
print("\n🟢 Testing OpenRouter API Key...")
api_key = os.getenv("OPENROUTER_API_KEY")
if not api_key:
print(" ❌ Skipped: No OPENROUTER_API_KEY found in environment.")
return False
try:
client = OpenAI(
base_url="https://openrouter.ai/api/v1",
api_key=api_key,
)
# Using standard free high-quality endpoint
completion = client.chat.completions.create(
model="meta-llama/llama-3.3-70b-instruct:free",
messages=[{"role": "user", "content": "Respond with exactly: 'OpenRouter Key is Working!'"}]
)
print(f" ✅ SUCCESS! Response: {completion.choices[0].message.content.strip()}")
return True
except Exception as e:
print(f" ❌ FAILED: Validation exception occurred.")
print(f" Details: {e}")
return False
if __name__ == "__main__":
print("=" * 60)
print("🔑 CLOUD ENDPOINT PROVIDER DISCOVERY STATUS")
print("=" * 60)
verify_gemini()
verify_grok()
verify_openrouter()
print("\n" + "=" * 60)