-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexamples.sh
More file actions
executable file
·72 lines (62 loc) · 1.58 KB
/
examples.sh
File metadata and controls
executable file
·72 lines (62 loc) · 1.58 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
#!/bin/bash
# Example cURL commands for testing the API
BASE_URL="http://localhost:3000"
API_KEY="${API_KEY:-}"
# Set auth header if API_KEY is provided
if [ -n "$API_KEY" ]; then
AUTH_HEADER="-H 'Authorization: Bearer $API_KEY'"
else
AUTH_HEADER=""
fi
echo "Testing OpenAI-compatible API"
echo "=============================="
echo ""
# Health check
echo "1. Health Check"
echo " GET /health"
curl -s "$BASE_URL/health" | jq .
echo ""
# List models
echo "2. List Models"
echo " GET /v1/models"
curl -s $AUTH_HEADER "$BASE_URL/v1/models" | jq '.data[].id'
echo ""
# Chat completion
echo "3. Chat Completion"
echo " POST /v1/chat/completions"
curl -s $AUTH_HEADER \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Say hello!"}],
"max_tokens": 20
}' \
"$BASE_URL/v1/chat/completions" | jq '.choices[0].message.content'
echo ""
# Streaming chat completion
echo "4. Streaming Chat Completion"
echo " POST /v1/chat/completions (stream=true)"
curl -s $AUTH_HEADER \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [{"role": "user", "content": "Count from 1 to 3"}],
"stream": true,
"max_tokens": 30
}' \
"$BASE_URL/v1/chat/completions"
echo ""
echo ""
# Legacy completion
echo "5. Legacy Completion"
echo " POST /v1/completions"
curl -s $AUTH_HEADER \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"prompt": "The capital of France is",
"max_tokens": 10
}' \
"$BASE_URL/v1/completions" | jq '.choices[0].text'
echo ""
echo "Tests complete!"