-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.sh
More file actions
89 lines (79 loc) · 3.13 KB
/
Copy pathexample.sh
File metadata and controls
89 lines (79 loc) · 3.13 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/bin/bash
# NovaPAI cURL Examples
# Docs: https://novapai.ai
API_KEY="your-api-key"
BASE_URL="https://api.novapai.ai/router/v1"
# ── Basic Chat ──────────────────────────────────────────────
echo "=== Basic Chat ==="
curl -s "$BASE_URL/chat/completions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
]
}' | python3 -c "import sys,json; print(json.load(sys.stdin)['choices'][0]['message']['content'])"
# ── Streaming ───────────────────────────────────────────────
echo "=== Streaming ==="
curl -s "$BASE_URL/chat/completions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"messages": [{"role": "user", "content": "Tell me a joke"}],
"stream": true
}'
# ── Function Calling ────────────────────────────────────────
echo ""
echo "=== Function Calling ==="
curl -s "$BASE_URL/chat/completions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{"role": "user", "content": "What'\''s the weather in Tokyo?"}
],
"tools": [{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name"}
},
"required": ["city"]
}
}
}]
}' | python3 -c "
import sys,json
msg = json.load(sys.stdin)['choices'][0]['message']
tc = msg['tool_calls'][0]
print(f\"Function: {tc['function']['name']}\")
print(f\"Args: {tc['function']['arguments']}\")
"
# ── JSON Mode (Structured Output) ───────────────────────────
echo ""
echo "=== JSON Mode ==="
curl -s "$BASE_URL/chat/completions" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "deepseek-v4-pro",
"messages": [
{"role": "system", "content": "Extract company info as JSON."},
{"role": "user", "content": "Apple Inc. is based in Cupertino, founded in 1976."}
],
"response_format": {"type": "json_object"}
}' | python3 -c "import sys,json; print(json.dumps(json.loads(json.load(sys.stdin)['choices'][0]['message']['content']), indent=2))"
# ── List Models ─────────────────────────────────────────────
echo ""
echo "=== Available Models ==="
curl -s "$BASE_URL/models" \
-H "Authorization: Bearer $API_KEY" \
| python3 -c "import sys,json; [print(m['id']) for m in json.load(sys.stdin)['data']]"