-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.py
More file actions
29 lines (24 loc) · 782 Bytes
/
Copy pathchat.py
File metadata and controls
29 lines (24 loc) · 782 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
"""Chat completion against cloudgpu.app with the official OpenAI SDK.
pip install -r requirements.txt
export CLOUDGPU_API_KEY=sk-...
python chat.py "Explain KV cache in two sentences"
"""
import os
import sys
from openai import OpenAI
client = OpenAI(
base_url="https://cloudgpu.app/v1",
api_key=os.environ["CLOUDGPU_API_KEY"],
)
prompt = sys.argv[1] if len(sys.argv) > 1 else "Say hello in one sentence."
# Model IDs and live prices: https://cloudgpu.app/api
stream = client.chat.completions.create(
model="deepseek-v4-flash",
messages=[{"role": "user", "content": prompt}],
stream=True,
)
for chunk in stream:
delta = chunk.choices[0].delta.content if chunk.choices else None
if delta:
print(delta, end="", flush=True)
print()