English
中文
English

Get started with Claude

中文

開始使用 Claude

English

Make your first API call to Claude and build a simple web search assistant.

中文

進行你的第一個 Claude API 呼叫,並建構一個簡單的網頁搜尋助手。

English

Prerequisites

中文

先決條件

English
  • An Anthropic Console account
  • An API key
中文
  • 一個 Anthropic Console 帳戶
  • 一個 API 金鑰
English

Call the API

中文

呼叫 API

English

Step 1: Set your API key

中文

步驟 1:設定你的 API 金鑰

English

Get your API key at the Claude Console and set it as an environment variable:

中文

在 Claude Console 取得你的 API 金鑰,並將其設定為環境變數:

bash
export ANTHROPIC_API_KEY='your-api-key-here'
English

Step 2: Make your first API call

中文

步驟 2:進行你的第一個 API 呼叫

English

Run this command to create a simple web search assistant:

中文

執行以下指令來建立一個簡單的網頁搜尋助手:

bash
curl https://api.anthropic.com/v1/messages \
  -H "Content-Type: application/json" \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -d '{
    "model": "claude-sonnet-4-5",
    "max_tokens": 1000,
    "messages": [
      {
        "role": "user",
        "content": "What should I search for to find the latest developments in renewable energy?"
      }
    ]
  }'
English

Example output:

中文

範例輸出:

json
{
  "id": "msg_01HCDu5LRGeP2o7s2xGmxyx8",
  "type": "message",
  "role": "assistant",
  "content": [
    {
      "type": "text",
      "text": "Here are some effective search strategies..."
    }
  ],
  "model": "claude-sonnet-4-5",
  "stop_reason": "end_turn",
  "usage": {
    "input_tokens": 21,
    "output_tokens": 305
  }
}
English

Next steps

中文

下一步

English

Now that you have made your first Claude API request, it's time to explore what else is possible:

中文

既然你已經完成了第一個 Claude API 請求,現在是時候探索其他可能性了: