将此提示复制到我们的开发者控制台中,亲自尝试!

内容
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)