jqはJSONを整形するツールです。
#!/bin/bash
API_KEY="YOUR_API_KEY"
ENDPOINT="https://api.deepseek.com/v1/chat/completions"
echo "DeepSeek CLI (Ctrl+C to exit)"
while true; do
read -p "> " input
REQUEST_BODY='{
"model": "deepseek-chat",
"messages": [
{"role": "user", "content": "'"$input"'"}
]
}'
RESPONSE=$(curl -s -X POST "$ENDPOINT" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d "$REQUEST_BODY")
echo $RESPONSE | jq -r '.choices[0].message.content'
done
以上。