# 即時 Claude LLM 回應

**API:** Data API

**Endpoint:** `POST /v1/beta/dataforseo/ai_optimization/claude/llm_responses/live`

**Tags:** DataForSEO

將 `user_prompt` 傳送給 Claude 模型並同步傳回其回覆。`model_name` 必須來自 `get_dataforseo_ai_claude_llm_responses_models`——名稱形如 `claude-sonnet-5`，看似合理的猜測會遭拒。傳回 `model_name`、`input_tokens`、`output_tokens`、`reasoning_tokens`、`web_search`、`money_spent`、`datetime`、`items` 與 `fan_out_queries`。請讀取回應中的 `money_spent` 以了解提示實際花費。包裝在 DataForSEO 的信封中：資料位於 `tasks[0].result`，結果狀態位於 `tasks[0].status_code`——即使請求遭拒仍會傳回 HTTP 200。

### 定價參考

- 計量方式：依回報的回應成本計量。
- 參考請求預估：USD 0.0567。
- 參考客戶乘數：1.0。不得再次套用於已結算的客戶金額。

僅供參考的中繼資料，並非帳戶報價、保證價格或消費上限。資源額度並非 Felo 額度。最終費用依 Felo 計費記錄為準。

## Base URL

- `https://openapi.felo.ai`

## Authentication

- `FeloBearerAuth` (http bearer, bearer format Felo API Key)
- `FeloApiKey` (apiKey in header `X-API-Key`)

## Request body

Required: **no**

### application/json

Schema:

```json
{
  "type": "array",
  "items": {
    "type": [
      "object",
      "null"
    ],
    "oneOf": [
      {
        "type": "object",
        "properties": {
          "user_prompt": {
            "type": "string",
            "description": "<em>AI 模型的提示詞</em><br><strong>必填欄位</strong><br>要傳送給 AI 模型的問題或任務；<br>在 <code>user_prompt</code> 欄位中最多可指定 <strong>500 個字元</strong>"
          },
          "model_name": {
            "type": "string",
            "description": "<em>AI 模型名稱</em><br><strong>必填欄位</strong><br><code>model_name</code > 由實際模型名稱和版本名稱組成；<br>如果只指定基礎模型名稱，將預設設定其最新版本；<br>例如，指定 <code>claude-opus-4-0</code> 時，會自動將 <code>claude-opus-4-20250514</code> 設為 <code>model_name</code>；<br>可個別向 <code>https://api.dataforseo.com/v3/ai_optimization/claude/llm_responses/models</code> 發出請求，取得可用的 LLM 模型清單"
          },
          "max_output_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<em>AI 回應中的最大 token 數</em><br>選填欄位<br>最小值：<code>1</code>；<br>最大值：<code>4096</code>；<br>預設值：<code>2048</code>；<br><strong>注意：</strong>如果 <code>web_search</code> 設為 <code>true</code>，或請求中指定的是推論模型，輸出 token 數可能超過指定的 <code>max_output_tokens</code> 上限<br><strong>注意 2：</strong>如果 <code>use_reasoning</code> 設為 <code>true</code>，<code>max_output_tokens</code> 的最小值為 <code>1025</code>"
          },
          "temperature": {
            "type": [
              "number",
              "null"
            ],
            "description": "<em>AI 回應的隨機性</em><br>選填欄位<br>值越高，輸出越多元；<br>值越低，輸出越集中；<br>最小值：<code>0</code><br>最大值：<code>1</code><br>預設值：<code>0.7</code><p><strong>注意：</strong>同一請求中 <code>temperature</code> 不能與 <code>top_p</code> 同時使用"
          },
          "top_p": {
            "type": [
              "number",
              "null"
            ],
            "description": "<em>AI 回應的多樣性</em><br>選填欄位 <br>透過限制 token 選擇來控制回應的多樣性；<br>最小值：<code>0</code><br>最大值：<code>1</code> <br>預設值：<code>null</code><p><strong>注意：</strong>同一請求中 <code>top_p</code> 不能與 <code>temperature</code> 同時使用"
          },
          "web_search": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "<em>啟用網路搜尋以取得目前資訊</em><br>選填欄位<br>啟用後，AI 模型可以存取並引用目前的網路資訊；<br><strong>注意：</strong>支援 <code>web_search</code> 的模型清單請參閱 <a href=\"https://docs.dataforseo.com/v3/ai_optimization/claude/llm_responses/models/\">Models 端點</a>； <br>預設值：<code>false</code>；<br>此參數的費用可在 <a title=\"Anthropic API Pricing\" href=\"https://docs.anthropic.com/en/docs/about-claude/pricing\" target=\"_blank\" rel=\"noopener noreferrer\">定價頁</a>計算"
          },
          "force_web_search": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "<em>強制 AI 代理程式使用網路搜尋</em><br>選填欄位<br>要啟用此參數，還必須啟用 <code>web_search</code>；<br>啟用後，AI 模型會被強制存取並引用目前的網路資訊；<br>預設值：<code>false</code>；<br><strong>注意：</strong>即使參數設為 <code>true</code>，也無法保證回應中會引用網路來源"
          },
          "web_search_country_iso_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>用於網路搜尋的地點的 ISO 國家代碼</em><br>選填欄位<br>可能的值：<code>'AR','AT','AU','BE','BR','CA','CH','CL','CN','DE','DK','ES','FI','FR','GB','HK','ID','IN','IT','JP','KR','MX','MY','NL','NO','NZ','PH','PL','PT','RU','SA','SE','TR','TW','US','ZA'</code>"
          },
          "web_search_city": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>用於網路搜尋的地點的城市名稱</em><br>選填欄位<br>"
          },
          "system_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>AI 行為指令</em><br>選填欄位<br>定義 AI 的角色、語氣或特定行為；<br>在 <code>system_message</code> 欄位中最多可指定 <strong>500 個字元</strong>"
          },
          "message_chain": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": [
                "object",
                "null"
              ],
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "訊息來源使用者的角色"
                    },
                    "message": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "訊息文字"
                    }
                  }
                }
              ]
            },
            "description": "對話歷史\n選填欄位\n代表先前對話輪次的訊息物件陣列；\n每個物件必須包含：\nrole 字串，值為 user 或 ai 角色；\nmessage 字串，包含訊息內容（最多 500 個字元）；\n陣列中最多可指定 10 個訊息物件；\n注意：對於 Perplexity 模型，訊息必須嚴格在 user 與 AI 角色之間交替（user → ai）；\n範例：\n\"message_chain\": [{\"role\":\"user\",\"message\":\"Hello, what’s up?\"},{\"role\":\"ai\",\"message\":\"Hello! I’m doing well, thank you. How can I assist you today?\"}]"
          },
          "use_reasoning": {
            "type": [
              "boolean",
              "null"
            ],
            "description": "<em>為 AI 模型啟用推論</em><br>選填欄位<br>啟用後，模型會在產生回應前進行推論<br>支援 <code>reasoning</code> 的模型清單請參閱 <a href=\"https://docs.dataforseo.com/v3/ai_optimization/claude/llm_responses/models/\" target=\"_blank\">Models 端點</a><br>預設值：<code>false</code><br><strong>注意：</strong>如果設為 <code>true</code>，<code>max_output_tokens</code> 的最小值為 <code>1025</code><br><strong>注意 2：</strong>如果設為 <code>true</code>，<code>force_web_search</code> 必須設為 <code>false</code><br><strong>注意 3：</strong>如果設為 <code>true</code>，則不能使用 <code>temperature</code> 與 <code>top_p</code>"
          },
          "tag": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>使用者自訂任務識別碼</em><br>選填欄位<br><em>字元數上限為 255</em><br>可使用此參數識別任務，並將其與結果對應<br>可在回應的 <code>data</code> 物件中找到指定的 <code>tag</code> 值"
          }
        },
        "example": [
          {
            "system_message": "communicate as if we are in a business meeting",
            "message_chain": [
              {
                "role": "user",
                "message": "Hello, what’s up?"
              },
              {
                "role": "ai",
                "message": "Hello! I’m doing well, thank you. How can I assist you today? Are there any specific topics or projects you’d like to discuss in our meeting?"
              }
            ],
            "max_output_tokens": 200,
            "model_name": "claude-opus-4-0",
            "temperature": 0.3,
            "web_search": true,
            "web_search_country_iso_code": "FR",
            "user_prompt": "provide information on how relevant the amusement park business is in France now"
          }
        ]
      }
    ]
  },
  "example": [
    {
      "system_message": "communicate as if we are in a business meeting",
      "message_chain": [
        {
          "role": "user",
          "message": "Hello, what’s up?"
        },
        {
          "role": "ai",
          "message": "Hello! I’m doing well, thank you. How can I assist you today? Are there any specific topics or projects you’d like to discuss in our meeting?"
        }
      ],
      "max_output_tokens": 200,
      "model_name": "claude-opus-4-0",
      "temperature": 0.3,
      "web_search": true,
      "web_search_country_iso_code": "FR",
      "user_prompt": "provide information on how relevant the amusement park business is in France now"
    }
  ]
}
```

## Responses

### 200 — 操作成功

Headers:
- `X-Request-Id` (string) — 聯絡 Felo 支援時需提供的請求識別碼。

**application/json**

Schema: object | null

```json
{
  "type": [
    "object",
    "null"
  ],
  "oneOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_AiOptimizationClaudeLlmResponsesLiveResponseInfo"
    }
  ]
}
```

### 400 — 無法處理該要求。請檢查請求參數。

### 401 — 需要有效的 Felo API 金鑰。

### 402 — 由於未符合計費要求，要求無法繼續。

### 403 — 該帳戶無權執行此操作。

### 429 — 已達到要求或支出上限。

### 502 — 服務無法完成該要求。

### 503 — API 或計費服務暫時無法使用。

### 504 — 服務在處理要求時逾時。

### default — 錯誤回應；上游透傳回應可能採用供應商格式

**application/json**

Schema:

```json
{}
```

## Schema definitions

### Response36Afe1097B20_AiOptimizationClaudeLlmResponsesLiveResponseInfo

`#/components/schemas/Response36Afe1097B20_AiOptimizationClaudeLlmResponsesLiveResponseInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseInfo"
    },
    {
      "type": "object",
      "properties": {
        "tasks": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "oneOf": [
              {
                "$ref": "#/components/schemas/Response36Afe1097B20_AiOptimizationClaudeLlmResponsesLiveTaskInfo"
              }
            ]
          },
          "description": "<em>任務陣列</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_AiOptimizationClaudeLlmResponsesLiveResultInfo

`#/components/schemas/Response36Afe1097B20_AiOptimizationClaudeLlmResponsesLiveResultInfo`

```json
{
  "type": "object",
  "properties": {
    "model_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>所用 AI 模型的名稱</em>"
    },
    "input_tokens": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>輸入中的 token 數</em><br>處理的 token 總數"
    },
    "output_tokens": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>輸出中的 token 數</em><br>AI 回應中產生的 token 總數"
    },
    "reasoning_tokens": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>推理 token 數</em><br>用於產生推理內容的 token 總數"
    },
    "web_search": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "<em>表示是否使用了網路搜尋</em>"
    },
    "money_spent": {
      "type": [
        "number",
        "null"
      ],
      "description": "<em>AI token 成本（美元）</em><br>第三方 AI 模型供應商依其<a href=\"https://docs.anthropic.com/en/docs/about-claude/pricing\" target=\"_blank\">定價</a>收取的費用"
    },
    "datetime": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>收到結果的日期與時間</em><br>採用 UTC 格式：“yyyy-mm-dd hh-mm-ss +00:00”<br>範例：<br><code class=\"long-string\">2019-11-15 12:57:46 +00:00</code>"
    },
    "items": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "object",
          "null"
        ],
        "oneOf": [
          {
            "$ref": "#/components/schemas/Response36Afe1097B20_BaseAiOptimizationLlmResponseElementItem"
          }
        ]
      },
      "description": "<em>回應項目陣列</em><br>包含結構化的 AI 回應資料"
    },
    "fan_out_queries": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "string",
          "null"
        ]
      },
      "description": "<em>扇出查詢陣列</em><br>包含從主查詢衍生的相關搜尋查詢，以提供更全面的回答"
    }
  }
}
```

### Response36Afe1097B20_AiOptimizationClaudeLlmResponsesLiveTaskInfo

`#/components/schemas/Response36Afe1097B20_AiOptimizationClaudeLlmResponsesLiveTaskInfo`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo"
    },
    {
      "type": "object",
      "properties": {
        "result": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "oneOf": [
              {
                "$ref": "#/components/schemas/Response36Afe1097B20_AiOptimizationClaudeLlmResponsesLiveResultInfo"
              }
            ]
          },
          "description": "<em>結果陣列</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_BaseAiOptimizationLlmResponseElementItem

`#/components/schemas/Response36Afe1097B20_BaseAiOptimizationLlmResponseElementItem`

```json
{
  "type": "object",
  "properties": {
    "type": {
      "type": [
        "string",
        "null"
      ],
      "description": "元素類型"
    }
  },
  "additionalProperties": false,
  "discriminator": {
    "propertyName": "type",
    "mapping": {
      "reasoning": "#/components/schemas/Response36Afe1097B20_ReasoningAiOptimizationLlmResponseElementItem",
      "message": "#/components/schemas/Response36Afe1097B20_MessageAiOptimizationLlmResponseElementItem"
    }
  }
}
```

### Response36Afe1097B20_BaseResponseInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseInfo`

```json
{
  "properties": {
    "version": {
      "type": [
        "string",
        "null"
      ],
      "description": "API 的目前版本"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "一般狀態碼\n完整回應碼清單請見此處"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "一般資訊訊息\n完整的一般資訊訊息清單請見此處"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "總執行時間，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任務總費用，美元",
      "format": "double"
    },
    "tasks_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 陣列中的任務數",
      "format": "int64"
    },
    "tasks_error": {
      "type": [
        "integer",
        "null"
      ],
      "description": "tasks 陣列中傳回錯誤的任務數",
      "format": "int64"
    }
  }
}
```

### Response36Afe1097B20_BaseResponseTaskInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo`

```json
{
  "properties": {
    "id": {
      "type": [
        "string",
        "null"
      ],
      "description": "任務識別碼\n我們系統中 UUID 格式的唯一任務識別碼"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "任務的狀態碼\n由 DataForSEO 產生，範圍如下：10000-60000\n完整回應碼清單請見此處"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "任務的資訊訊息\n完整的一般資訊訊息清單請見此處"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "執行時間，秒"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "任務總費用，美元",
      "format": "double"
    },
    "result_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "result 陣列中的元素數",
      "format": "int64"
    },
    "path": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "string",
          "null"
        ]
      },
      "description": "URL 路徑"
    },
    "data": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": [
          "object",
          "null"
        ]
      },
      "description": "包含你在 POST 請求中指定的相同參數"
    }
  }
}
```
