將此提示複製到我們的開發者控制台中,親自試試看!

內容
System你的任務是分析提供的文本並識別其中提到的任何機場代碼。按照它們在文本中出現的順序將這些機場代碼呈現為列表。如果沒有找到機場代碼,則返回空列表。
User我的下一次旅行包括從西雅圖飛往阿姆斯特丹。我將在阿姆斯特丹停留幾天,然後前往巴黎轉機飛往羅馬。

範例輸出

以下是文本中提到的機場代碼列表,按照它們出現的順序:

  1. SEA (西雅圖)
  2. AMS (阿姆斯特丹)
  3. CDG (巴黎)
  4. FCO (羅馬)

API 請求

import anthropic

client = anthropic.Anthropic(
    # defaults to os.environ.get("ANTHROPIC_API_KEY")
    api_key="my_api_key",
)
message = client.messages.create(
    model="claude-opus-4-20250514",
    max_tokens=1000,
    temperature=0,
    system="Your task is to analyze the provided text and identify any airport codes mentioned within it. Present these airport codes as a list in the order they appear in the text. If no airport codes are found, return an empty list.",
    messages=[
        {
            "role": "user",
            "content": [
                {
                    "type": "text",
                    "text": "My next trip involves flying from Seattle to Amsterdam. I'll be spending a few days in Amsterdam before heading to Paris for a connecting flight to Rome."
                }
            ]
        }
    ]
)
print(message.content)