> ## Documentation Index
> Fetch the complete documentation index at: https://aisa.one/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# 实时 Perplexity LLM 响应

> Live Perplexity LLM Responses 端点允许您根据输入参数，从指定的 Perplexity AI 模型检索结构化响应。



## OpenAPI

````yaml openapi/zh/dataforseo.json POST /dataforseo/ai_optimization/perplexity/llm_responses/live
openapi: 3.0.3
info:
  title: DataForSEO API
  version: 1.0.0
  description: 通过 AIsa 统一网关提供的 DataForSEO API 端点。
servers:
  - url: https://api.aisa.one/apis/v1
security:
  - BearerAuth: []
paths:
  /dataforseo/ai_optimization/perplexity/llm_responses/live:
    post:
      summary: 实时 Perplexity LLM 响应
      description: Live Perplexity LLM Responses 端点允许您根据输入参数，从指定的 Perplexity AI 模型检索结构化响应。
      operationId: post_dataforseo_ai_optimization_perplexity_llm_responses_live
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              properties:
                user_prompt:
                  type: string
                  description: >-
                    AI 模型的提示词，必填字段；您希望发送给 AI 模型的问题或任务；可在 user_prompt 字段中指定最多 500
                    个字符
                model_name:
                  type: string
                  description: >-
                    AI 模型名称，必填字段 model_name
                    由实际模型名称和版本名称组成；如果指定基础模型名称，默认使用其最新版本；你可以通过向以下端点单独发送请求来获取可用
                    LLM
                    模型列表：https://api.dataforseo.com/v3/ai_optimization/perplexity/llm_responses/models
                max_output_tokens:
                  type: integer
                  description: >-
                    AI
                    响应中的最大词元数；可选字段；最小值：1；最大值：4096；默认值：2048；注意：如果请求中指定了推理模型，输出词元数可能会超过指定的
                    max_output_tokens 限制
                temperature:
                  type: number
                  description: AI 响应的随机性，可选字段。值越高，输出越多样；值越低，输出越聚焦。最小值：0；最大值：1.9；默认值：0.77
                top_p:
                  type: number
                  description: AI 响应的多样性；可选字段，通过限制词元选择来控制响应的多样性；最小值：0；最大值：1；默认值：0.9。
                web_search_country_iso_code:
                  type: string
                  description: >-
                    用于网页搜索本地化的国家/地区代码。可选字段；指定国家/地区的 ISO 代码，以获取本地化的网页搜索结果。注意：仅适用于
                    Perplexity Sonar 模型。示例：US
                system_message:
                  type: string
                  description: >-
                    AI 行为指令，可选字段，用于定义 AI 的角色、语气或特定行为；可在 system_message 字段中指定最多
                    500 个字符
                message_chain:
                  type: array
                  items:
                    type: string
                  description: >-
                    对话历史 可选字段 表示先前对话轮次的消息对象数组；每个对象必须包含：role 字符串，角色为 user 或
                    ai；message 字符串，包含消息内容（最多 500 个字符）；数组中最多可以指定 10 个消息对象；注意：对于
                    Perplexity 模型，消息必须严格在 user 和 AI 角色之间交替（user →
                    ai）；示例："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
                  description: >-
                    用户定义的任务标识符。可选字段。字符数限制为 255。您可以使用此参数标识任务并将其与结果匹配；您将在响应的 data
                    对象中找到指定的 tag 值
              required:
                - user_prompt
                - model_name
      responses:
        '200':
          description: 成功响应
          content:
            application/json:
              schema:
                type: object
                properties:
                  version:
                    type: string
                    description: API 的当前版本
                  status_code:
                    type: integer
                    description: 通用状态码；您可以在此处查看完整的响应码列表。注意：我们强烈建议设计必要的系统来处理相关异常或错误情况
                  status_message:
                    type: string
                    description: 常规信息消息；可在此处查看常规信息消息的完整列表
                  time:
                    type: string
                    description: 执行时间（秒）
                  cost:
                    type: number
                    description: 任务总成本（美元）
                  tasks_count:
                    type: integer
                    description: tasks 数组中的任务数量
                  tasks_error:
                    type: integer
                    description: 返回错误的 tasks 数组中的任务数量
                  tasks:
                    type: array
                    items:
                      type: string
                    description: 任务数组
                  tasks.id:
                    type: string
                    description: 任务标识符，系统中采用 UUID 格式的唯一任务标识符
                  tasks.status_code:
                    type: integer
                    description: DataForSEO 生成的任务状态码；范围为：10000-60000；完整响应代码列表可在此处查看
                  tasks.status_message:
                    type: string
                    description: 任务的信息性消息，你可以在此处查看通用信息性消息的完整列表
                  tasks.time:
                    type: string
                    description: 执行时间（秒）
                  tasks.cost:
                    type: number
                    description: 任务成本（美元），包括基础任务价格与 money_spent 值之和
                  tasks.result_count:
                    type: integer
                    description: 结果数组中的元素数量
                  tasks.path:
                    type: array
                    items:
                      type: string
                    description: URL 路径
                  tasks.data:
                    type: object
                    description: 包含您在 POST 请求中指定的相同参数
                  tasks.result:
                    type: array
                    items:
                      type: string
                    description: 结果数组
                  tasks.result.model_name:
                    type: string
                    description: 所用 AI 模型的名称
                  tasks.result.input_tokens:
                    type: integer
                    description: 输入中的词元数量，即已处理的词元总数
                  tasks.result.output_tokens:
                    type: integer
                    description: 输出中的词元数量，即 AI 响应生成的词元总数
                  tasks.result.web_search:
                    type: boolean
                    description: 表示是否使用了网页搜索。注意：Perplexity Sonar 模型默认启用网页搜索
                  tasks.result.money_spent:
                    type: number
                    description: AI 词元成本（美元），即第三方 AI 模型提供商根据其定价收取的费用
                  tasks.result.datetime:
                    type: string
                    description: >-
                      以 UTC 格式接收结果的日期和时间：“yyyy-mm-dd hh-mm-ss
                      +00:00”，示例：2019-11-15 12:57:46 +00:00
                  tasks.result.items:
                    type: array
                    items:
                      type: string
                    description: 响应条目数组，包含结构化 AI 响应数据
                  tasks.result.items.type:
                    type: string
                    description: 元素类型 = 'message'
                  tasks.result.items.sections:
                    type: array
                    items:
                      type: string
                    description: 内容分区数组，包含 AI 响应的不同部分
                  tasks.result.items.sections.type:
                    type: string
                    description: 元素类型='text'
                  tasks.result.items.sections.text:
                    type: string
                    description: AI 生成的文本内容
                  tasks.result.items.sections.annotations:
                    type: array
                    items:
                      type: string
                    description: >-
                      用于生成响应的引用数组；如果 web_search 参数未设置为 true，则为 null。注意：即使
                      web_search 为 true，annotations 也可能返回空值，因为 AI 会尝试检索 Web
                      信息，但可能找不到相关结果。
                  tasks.result.items.sections.annotations.title:
                    type: string
                    description: 引用来源的域名或标题
                  tasks.result.items.sections.annotations.url:
                    type: string
                    description: 引用来源的 URL
                  tasks.result.fan_out_queries:
                    type: array
                    items:
                      type: string
                    description: 扩展查询数组，包含从主查询派生的相关搜索查询，以提供更全面的响应
        '400':
          description: 错误请求
        '401':
          description: 未授权
        '429':
          description: 超出速率限制
        '500':
          description: 内部服务器错误
components:
  securitySchemes:
    BearerAuth:
      type: http
      scheme: bearer

````