-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_llm.py
More file actions
35 lines (27 loc) · 921 Bytes
/
test_llm.py
File metadata and controls
35 lines (27 loc) · 921 Bytes
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
import os
from openai import OpenAI
# User provided key
API_KEY = "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"
BASE_URL = "https://openrouter.ai/api/v1"
print(f"Testing Connectivity to {BASE_URL}...")
try:
client = OpenAI(
base_url=BASE_URL,
api_key=API_KEY,
default_headers={
"HTTP-Referer": "http://localhost:5173",
"X-Title": "MultiModalDocIntel"
}
)
print("Sending request to google/gemini-2.0-flash-exp:free ...")
response = client.chat.completions.create(
model="google/gemini-2.0-flash-lite-preview-02-05:free",
messages=[
{"role": "user", "content": "Say hello!"}
],
)
print("\nSUCCESS!")
print("Response:", response.choices[0].message.content)
except Exception as e:
print("\nFAILURE!")
print("Error:", e)