DocDoeAI / scratch /test_gemini_credentials.py
asnannp's picture
Deploy backend cd4237ff: support routes + rate limit + exam_date nullable + upload 413 fix
7c6ffa6
Raw
History Blame Contribute Delete
736 Bytes
import os
from google import genai
def test_gemini():
api_key = os.environ.get("GEMINI_API_KEY", "")
print(f"GEMINI_API_KEY from env: '{api_key[:5]}...' (len={len(api_key)})")
try:
# Initialize client (it will look at GEMINI_API_KEY automatically)
client = genai.Client()
# Test basic embed content
response = client.models.embed_content(
model="text-embedding-004",
contents="Hello World"
)
print("Success! Generated embedding:")
print(f"Vector length: {len(response.embeddings[0].values)}")
except Exception as e:
print(f"Failed to generate embedding with default client: {e}")
if __name__ == "__main__":
test_gemini()