🐋

CursorでDeepSeek V3と連携して費用を節約する

2025/01/07に公開
1

DeepSeekが提供しているコーディング向けのモデルDeepSeek-coder
とてもパフォーマンスに優れています。Cursorのエディタに登録して費用を抑えつつ
コーディングを効率良く行いましょう。

https://github.com/deepseek-ai/DeepSeek-Coder

DeepSeek Coder B33ではPythonスコアが56.1となっています。

DeepSeek Coder

Supported Programming Languages

['ada', 'agda', 'alloy', 'antlr', 'applescript', 'assembly', 'augeas', 'awk', 'batchfile', 'bluespec', 'c', 'c-sharp', 'clojure', 'cmake', 'coffeescript', 'common-lisp', 'cpp', 'css', 'cuda', 'dart', 'dockerfile', 'elixir', 'elm', 'emacs-lisp', 'erlang', 'f-sharp', 'fortran', 'glsl', 'go', 'groovy', 'haskell', 'html', 'idris', 'isabelle', 'java', 'java-server-pages', 'javascript', 'json', 'julia', 'jupyter-notebook', 'kotlin', 'lean', 'literate-agda', 'literate-coffeescript', 'literate-haskell', 'lua', 'makefile', 'maple', 'markdown', 'mathematica', 'matlab', 'ocaml', 'pascal', 'perl', 'php', 'powershell', 'prolog', 'protocol-buffer', 'python', 'r', 'racket', 'restructuredtext', 'rmarkdown', 'ruby', 'rust', 'sas', 'scala', 'scheme', 'shell', 'smalltalk', 'solidity', 'sparql', 'sql', 'stan', 'standard-ml', 'stata', 'systemverilog', 'tcl', 'tcsh', 'tex', 'thrift', 'typescript', 'verilog', 'vhdl', 'visual-basic', 'xslt', 'yacc', 'yaml', 'zig']

料金

deepseek-coderの料金が書いていなかったため、deepseek-chatの記載します。

MODEL(1) CONTEXT LENGTH MAX OUTPUT TOKENS(2) INPUT PRICE (CACHE HIT)(3) INPUT PRICE (CACHE MISS) OUTPUT PRICE
deepseek-chat 64K 8K $0.07/ 1M tokens(4)
$0.014 / 1M tokens
$0.27/ 1M tokens(4)
$0.14 / 1M tokens
$1.10/ 1M tokens(4)
$0.28/1M tokens
deepseek-reasoner 64K 32K 8K $0.14 $0.55

(1) The deepseek-chat model has been upgraded to DeepSeek-V3. deepseek-reasoner points to the new model DeepSeek-R1.
(2) CoT (Chain of Thought) is the reasoning content deepseek-reasoner gives before output the final answer. For details, please refer to Reasoning Model。
(3) If max_tokens is not specified, the default maximum output length is 4K. Please adjust max_tokens to support longer outputs.
(4) Please check DeepSeek Context Caching for the details of Context Caching.
(5) The form shows the the original price and the discounted price. From now until 2025-02-08 16:00 (UTC), all users can enjoy the discounted prices of DeepSeek API. After that, it will recover to full price. DeepSeek-R1 is not included in the discount.
(6) The output token count of deepseek-reasoner includes all tokens from CoT and the final answer, and they are priced equally.

ちなみに、input 1073トークン、output 678トークンの消費で
$0.0003でした。

※(4)2025-02-08 16:00 (UTC)まではAPI利用で割引価格を適用

※2025-01-20にDeepSeek-R1がリリースされました。

APIキーの発行

https://platform.deepseek.com/api_keys

上記URLにアクセスし、ログイン後APIキーを発行します。

トークン購入

利用前にトークンを購入する必要があります。

https://platform.deepseek.com/top_up

利用する分だけ事前に購入できるので良いですね。

Cursorにモデルを登録する

https://www.cursor.com/

Cursorを起動し、設定を開きます。

File->Preference->Cursor Settings->Models

+ Add modelをクリックし、

deepseek-chat
deepseek-coder

を追加します。

deepseek-reasonerはCursorのようなコードエディタでは利用できません。

{"error":{"message":"deepseek-reasoner does not support successive user or assistant messages (messages[1] and messages[2] in your input). You should interleave the user/assistant messages in the message sequence.","type":"invalid_request_error","param":null,"code":"invalid_request_error"}}

OpenAI API Keyをオーバーライドして利用します。

Override OpenAI Base URL

https://api.deepseek.com/v1

Saveをクリックします。

Deepseekで発行したAPI Keyを入力し、Verifyで動作確認をします。

エラーが出ずに登録されればOKです。

https://api-docs.deepseek.com/quick_start/error_codes

402エラーは残高不足です。

400エラーはモデルが存在していません。

その他エラーが出る場合は、モデルの追加画面で、deepsheek以外のチェックを外してみてください。(主にOpenAIのモデルgpt系)


利用

CursorのChatが表示されていない場合は

View->Appearance->Secondary Side Barにチェックを入れましょう

Cursorの右側に、Chatが表示されるので、deepseek-coderを選択し、質問をします。

簡単なプロンプト

しっかりと日本語で解説をしながら実装例を書いてくれました。

OpenAI の Gpt-4oの約1/10で同等のパフォーマンスと謳っているため
かなりいいモデルではないでしょうか。

標準入力トークン:

DeepSeek-v3: $0.27/1M tokens
GPT-4o: $2.50/1M tokens(約9.3倍)

キャッシュされた入力トークン:

DeepSeek-v3: $0.07/1M tokens
GPT-4o: $1.25/1M tokens(約17.9倍)

出力トークン:

DeepSeek-v3: $1.10/1M tokens
GPT-4o: $10.00/1M tokens(約9.1倍)

https://openai.com/ja-JP/api/pricing/
https://api-docs.deepseek.com/quick_start/pricing

https://x.com/teortaxesTex/status/1872253671989551473

GPT-4oやClaude Sonnet 3.5 を超えていると言われていますが
驚くべきは事前学習のコストのやすさ。
2048台のGPUと約2ヶ月間でモデルの学習が完了しています。
560万ドルという費用がAPIの利用料のやすさの理由でしょう。

DeepSeek-R1

https://api-docs.deepseek.com/news/news250120

gpt-o1のように思考フェーズを表示してくれるR1が追加されました。
公式では、o1を超えるパフォーマンスを謳っています。
中国はAI分野で急成長をしていますが、今後のリリースされるモデルは要ウォッチですね。



※deepseek-reasonerはCursorのようなコードエディタでは利用できません。

Discussion

くろぼしくろぼし

Deepseek-R1などがCursorに利用できないのかなと、ネットに彷徨っていたら、ドンピシャのこの記事に出会いました。ありがとうございます。大変参考になります。