# Perplexity LLM レスポンス（ライブ）

**API:** Data API

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

**Tags:** DataForSEO

`user_prompt` を Perplexity モデルに送信し、その返信を同期的に返します。`model_name` は `get_dataforseo_ai_perplexity_llm_responses_models` から取得する必要があり、`sonar`、`sonar-pro`、`sonar-reasoning-pro` のいずれかです。`web_search_country_iso_code` で検索範囲を限定できますが、他の 3 社にはこの機能はありません。`model_name`、`input_tokens`、`output_tokens`、`reasoning_tokens`、`web_search`、`money_spent`、`datetime`、`items`、`fan_out_queries` を返します。1 回のプロンプトにかかった実際のコストは、レスポンスの `money_spent` で確認できます。DataForSEO のエンベロープに包まれます。データは `tasks[0].result`、結果は `tasks[0].status_code` に格納され、拒否されたリクエストでも HTTP 200 が返ります。

### 料金の参考情報

- 計測方法: 報告されたレスポンスコスト。
- 参考リクエスト見積もり: 0.0163 USD。
- 参照用の顧客乗数: 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>利用可能な LLM モデルのリストは、次のエンドポイントに個別にリクエストして取得できます：<code>https://api.dataforseo.com/v3/ai_optimization/perplexity/llm_responses/models</code>"
          },
          "max_output_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<em>AI レスポンスの最大トークン数</em><br>任意フィールド<br>最小値：<code>1</code><br>最大値：<code>4096</code>；<br>デフォルト値：<code>2048</code>；<br><strong>注意：</strong>リクエストで推論モデルを指定した場合、出力トークン数が指定した <code>max_output_tokens</code> の上限を超える可能性があります"
          },
          "temperature": {
            "type": [
              "number",
              "null"
            ],
            "description": "<em>AI レスポンスのランダム性</em><br>任意フィールド<br>値が高いほど出力が多様になります <br>値が低いほど出力が集中します<br>最小値：<code>0</code><br>最大値：<code>1.9</code><br>デフォルト値：<code>0.77</code>"
          },
          "top_p": {
            "type": [
              "number",
              "null"
            ],
            "description": "<em>AI レスポンスの多様性</em><br>任意フィールド <br>トークンの選択を制限してレスポンスの多様性を制御します<br>最小値: <code>0</code><br>最大値: <code>1</code> <br>デフォルト値: <code>0.9</code>"
          },
          "web_search_country_iso_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>ウェブ検索のローカライズ用の国コード</em><br>任意フィールド<br>ローカライズされたウェブ検索結果を取得するには、国の ISO コードを指定します<br><strong>注意：</strong>Perplexity Sonar モデルでのみ利用できます<br>例：<code>US</code>"
          },
          "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?\"}]"
          },
          "tag": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>ユーザー定義のタスク識別子</em><br>任意フィールド<br><em>文字数上限は 255 です</em><br>このパラメーターを使ってタスクを識別し、結果と照合できます<br>指定した <code>tag</code> の値は、レスポンスの <code>data</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,
            "temperature": 0.3,
            "top_p": 0.5,
            "web_search_country_iso_code": "FR",
            "model_name": "sonar",
            "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,
      "temperature": 0.3,
      "top_p": 0.5,
      "web_search_country_iso_code": "FR",
      "model_name": "sonar",
      "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_AiOptimizationPerplexityLlmResponsesLiveResponseInfo"
    }
  ]
}
```

### 400 — リクエストを処理できませんでした。リクエストパラメータを確認してください。

### 401 — 有効な Felo API キーが必要です。

### 402 — 請求要件が満たされていないため、リクエストを続行できません。

### 403 — このアカウントにはこの操作を行う権限がありません。

### 429 — リクエストまたは支出の上限に達しました。

### 502 — サービスがリクエストを完了できませんでした。

### 503 — API または請求サービスが一時的に利用できません。

### 504 — リクエストの処理中にサービスがタイムアウトしました。

### default — エラーレスポンス。上流のパススルーレスポンスはプロバイダーの形式を使用する場合があります

**application/json**

Schema:

```json
{}
```

## Schema definitions

### Response36Afe1097B20_AiOptimizationPerplexityLlmResponsesLiveResponseInfo

`#/components/schemas/Response36Afe1097B20_AiOptimizationPerplexityLlmResponsesLiveResponseInfo`

```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_AiOptimizationPerplexityLlmResponsesLiveTaskInfo"
              }
            ]
          },
          "description": "<em>タスクの配列</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_AiOptimizationPerplexityLlmResponsesLiveResultInfo

`#/components/schemas/Response36Afe1097B20_AiOptimizationPerplexityLlmResponsesLiveResultInfo`

```json
{
  "type": "object",
  "properties": {
    "model_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>使用された AI モデルの名前</em>"
    },
    "input_tokens": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>入力内のトークン数</em><br>処理されたトークンの合計数"
    },
    "output_tokens": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>出力内のトークン数</em><br>AI レスポンスで生成されたトークンの合計数"
    },
    "reasoning_tokens": {
      "type": [
        "integer",
        "null"
      ]
    },
    "web_search": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "<em>ウェブ検索が使用されたかどうかを示します</em><br><strong>注意:</strong> Perplexity Sonar モデルでは、ウェブ検索が既定で有効になっています"
    },
    "money_spent": {
      "type": [
        "number",
        "null"
      ],
      "description": "<em>AI トークンのコスト（米ドル）</em><br>サードパーティの AI モデルプロバイダーが<a href=\"https://docs.perplexity.ai/guides/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_MessageAiOptimizationLlmResponseElementItem"
          }
        ]
      },
      "description": "<em>レスポンスアイテムの配列</em><br>構造化された AI レスポンスデータを含みます"
    },
    "fan_out_queries": {
      "type": [
        "object",
        "null"
      ],
      "description": "<em>ファンアウトクエリの配列</em><br>より包括的な回答を提供するために、メインクエリから導出された関連検索クエリを含みます"
    }
  }
}
```

### Response36Afe1097B20_AiOptimizationPerplexityLlmResponsesLiveTaskInfo

`#/components/schemas/Response36Afe1097B20_AiOptimizationPerplexityLlmResponsesLiveTaskInfo`

```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_AiOptimizationPerplexityLlmResponsesLiveResultInfo"
              }
            ]
          },
          "description": "<em>結果の配列</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_AnnotationInfo

`#/components/schemas/Response36Afe1097B20_AnnotationInfo`

```json
{
  "type": "object",
  "properties": {
    "title": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>引用元のドメイン名またはタイトル</em>"
    },
    "url": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>引用元へのリダイレクト URL</em><br>元のソースに導く Vertex AI リダイレクトを含みます"
    },
    "direct_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>引用元への直接 URL</em><br>`url` フィールドの Vertex AI リダイレクトが指す元のソース URL を含みます"
    },
    "start_index": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>アノテーションインデックスの開始位置</em>"
    },
    "end_index": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>アノテーションインデックスの終了位置</em>"
    },
    "text": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>推論チェーンのセクションのテキスト</em><br>モデルの思考プロセスを要約した推論チェーンのセクションのテキスト"
    }
  }
}
```

### 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": "タスクの総コスト（USD）",
      "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": "タスクのステータスコード\nDataForSEO によって生成され、次の範囲の値になります: 10000-60000\nレスポンスコードの完全な一覧はこちらです"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "タスクの情報メッセージ\n一般的な情報メッセージの完全な一覧はこちらです"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "実行時間（秒）"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "タスクの総コスト（USD）",
      "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 リクエストで指定したものと同じパラメーターを含みます"
    }
  }
}
```

### Response36Afe1097B20_LlmMessageSectionInfo

`#/components/schemas/Response36Afe1097B20_LlmMessageSectionInfo`

```json
{
  "type": "object",
  "properties": {
    "type": {
      "type": [
        "string",
        "null"
      ],
      "description": "要素の種類"
    },
    "text": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>推論チェーンのセクションのテキスト</em><br>モデルの思考プロセスを要約した推論チェーンのセクションのテキスト"
    },
    "annotations": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "object",
          "null"
        ],
        "oneOf": [
          {
            "$ref": "#/components/schemas/Response36Afe1097B20_AnnotationInfo"
          }
        ]
      },
      "description": "<em>レスポンスの生成に使用された参照の配列</em><br><code>web_search</code> パラメーターが <code>true</code> に設定されていない場合は <code>null</code> になります<br><strong>注意：</strong><code>web_search</code> が <code>true</code> であっても、AI がウェブ情報の取得を試みても関連する結果が見つからない場合があるため、<code>annotations</code> は空で返されることがあります"
    }
  }
}
```

### Response36Afe1097B20_MessageAiOptimizationLlmResponseElementItem

`#/components/schemas/Response36Afe1097B20_MessageAiOptimizationLlmResponseElementItem`

```json
{
  "type": "object",
  "allOf": [
    {
      "$ref": "#/components/schemas/Response36Afe1097B20_BaseAiOptimizationLlmResponseElementItem"
    },
    {
      "type": "object",
      "properties": {
        "sections": {
          "type": [
            "array",
            "null"
          ],
          "items": {
            "type": [
              "object",
              "null"
            ],
            "oneOf": [
              {
                "$ref": "#/components/schemas/Response36Afe1097B20_LlmMessageSectionInfo"
              }
            ]
          },
          "description": "<em>推論チェーンのセクション</em><br>LLM が生成した推論チェーンのセクションを含むオブジェクトの配列"
        }
      }
    }
  ]
}
```
