-
Notifications
You must be signed in to change notification settings - Fork 25
Expand file tree
/
Copy pathmain.py
More file actions
25 lines (21 loc) · 738 Bytes
/
main.py
File metadata and controls
25 lines (21 loc) · 738 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
from openai import OpenAI
# Point the client to the local cgpu serve instance
# The API key is required by the SDK but ignored by the server
client = OpenAI(
base_url="http://localhost:8080/v1",
api_key="unused"
)
try:
print("Sending request to cgpu serve...")
response = client.responses.create(
model="gemini-2.0-flash",
instructions="You are a coding assistant that talks like a pirate.",
input="How do I check if a Python object is an instance of a class?",
)
print("\nResponse received:")
print("-" * 20)
print(response.output_text)
print("-" * 20)
except Exception as e:
print(f"\nError: {e}")
print("\nMake sure 'cgpu serve' is running in another terminal.")