4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

ClaudeAPI Key取得手順

4
Posted at

概要

こちらはAnthoropic社が提供するClaudeモデルのAPI Keyを取得する手順を記載したものです。是非、参考にしていただければ嬉しいです。

手順

Build on the Claude Developer Platform にアクセスする。

Start Buildingを押す。
スクリーンショット 2025-11-22 15.43.49.png

サインインする。
スクリーンショット 2025-11-22 15.44.55.png

Get API Keyを押す。
スクリーンショット 2025-11-22 15.46.41.png

クレジットカードの登録とかして、購入のフローが完了し、再度Get API Keyを押すとAPIキーが表示されます。一度しか表示されないので要注意を!!

実際に発行されたAPI Keyが使用できるかをチェックしてみようと思います。私はM1macbookを使用しているのでターミナルで確認します。

curl https://api.anthropic.com/v1/messages \
    --header "x-api-key: $ANTHROPIC_API_KEY" \
    --header "anthropic-version: 2023-06-01" \
    --header "anthropic-beta: web-fetch-2025-09-10" \
    --header "content-type: application/json" \
    --data '{
        "model": "claude-sonnet-4-5",
        "max_tokens": 1024,
        "messages": [
            {
                "role": "user",
                "content": "こんにちは"
            }
        ],
        "tools": [{
            "type": "web_fetch_20250910",
            "name": "web_fetch",
            "max_uses": 5
        }]
    }'

そうすると・・・無事返信が来ました。

{
  "model": "claude-sonnet-4-5-20250929",
  "id": "msg_**********************",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "こんにちは!お元気ですか?何かお手伝いできることはありますか?"
    }
  ],
  "stop_reason": "end_turn",
  "stop_sequence": null,
  "usage": {
    "input_tokens": 1033,
    "cache_creation_input_tokens": 0,
    "cache_read_input_tokens": 0,
    "cache_creation": {
      "ephemeral_5m_input_tokens": 0,
      "ephemeral_1h_input_tokens": 0
    },
    "output_tokens": 30,
    "service_tier": "standard"
  }
}

最後に

エンジニアが一番大変なのはコードを書くことではなくて、こういう環境構築やらAPI Keyの取得だったりする

4
3
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
4
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?