このプロンプトを開発者Consoleにコピーして自分で試してみましょう!

Content
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)