-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathchat.py
More file actions
24 lines (20 loc) · 718 Bytes
/
Copy pathchat.py
File metadata and controls
24 lines (20 loc) · 718 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
"""Chat completion via NovAI (OpenAI-compatible, drop-in).
pip install openai
export NOVAI_API_KEY=sk-...
python chat.py
"""
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["NOVAI_API_KEY"],
base_url="https://aiapi-pro.com/v1",
)
resp = client.chat.completions.create(
model="deepseek-v4-pro",
messages=[{"role": "user", "content": "Explain mixture-of-experts models in one paragraph."}],
)
print(resp.choices[0].message.content)
# Streaming variant:
# for chunk in client.chat.completions.create(model="deepseek-v4-pro",
# messages=[{"role": "user", "content": "hi"}], stream=True):
# print(chunk.choices[0].delta.content or "", end="", flush=True)