0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

deepseekをコマンドラインで使う方法

Posted at

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

以上。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?