# Perplexity LLM Responses Langsung

**API:** Data API

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

**Tags:** DataForSEO

Mengirim `user_prompt` ke model Perplexity dan mengembalikan balasannya secara sinkron. `model_name` harus berasal dari `get_dataforseo_ai_perplexity_llm_responses_models` - `sonar`, `sonar-pro`, dan `sonar-reasoning-pro`. `web_search_country_iso_code` membatasi cakupan pencarian, yang tidak ditawarkan tiga vendor lainnya. Mengembalikan `model_name`, `input_tokens`, `output_tokens`, `reasoning_tokens`, `web_search`, `money_spent`, `datetime`, `items`, dan `fan_out_queries`. Baca `money_spent` pada respons untuk melihat biaya sebenarnya dari sebuah prompt. Dibungkus dalam envelope DataForSEO: data di `tasks[0].result`, hasil di `tasks[0].status_code` - permintaan yang ditolak tetap mengembalikan HTTP 200.

### Referensi harga

- Pengukuran: biaya respons yang dilaporkan.
- Perkiraan permintaan referensi: USD 0,0163.
- Pengali pelanggan referensi: 1,0. Jangan menerapkannya lagi pada jumlah pelanggan yang telah diselesaikan.

Hanya metadata referensi, bukan penawaran akun, harga yang dijamin, atau batas pengeluaran. Kredit sumber daya bukanlah kredit Felo. Biaya akhir mengikuti catatan tagihan Felo.

## Related links

- [Harga](<https://docs.perplexity.ai/guides/pricing>)

## 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>prompt untuk model AI</em><br><strong>field wajib</strong><br>pertanyaan atau tugas yang ingin Anda kirim ke model AI;<br>Anda dapat menentukan <strong>hingga 500 karakter</strong> di field <code>user_prompt</code>"
          },
          "model_name": {
            "type": "string",
            "description": "<em>nama model AI</em><br><strong>field wajib</strong><br><code>model_name</code >terdiri dari nama model sebenarnya dan nama versi;<br>jika nama model dasar ditentukan, versi terbarunya akan ditetapkan secara default;<br>Anda dapat menerima daftar model LLM yang tersedia dengan membuat permintaan terpisah ke endpoint berikut: <code>https://api.dataforseo.com/v3/ai_optimization/perplexity/llm_responses/models</code>"
          },
          "max_output_tokens": {
            "type": [
              "integer",
              "null"
            ],
            "description": "<em>jumlah maksimum token dalam respons AI</em><br>field opsional<br>nilai minimum: <code>1</code><br>nilai maksimum: <code>4096</code>;<br>nilai default: <code>2048</code>;<br><strong>Catatan:</strong> jika model penalaran ditentukan dalam permintaan, jumlah token keluaran dapat melebihi batas <code>max_output_tokens</code> yang ditentukan"
          },
          "temperature": {
            "type": [
              "number",
              "null"
            ],
            "description": "<em>keacakan respons AI</em><br>field opsional<br>nilai yang lebih tinggi membuat keluaran lebih beragam <br>nilai yang lebih rendah membuat keluaran lebih terfokus<br>nilai minimum: <code>0</code><br>nilai maksimum: <code>1.9</code><br>nilai default: <code>0.77</code>"
          },
          "top_p": {
            "type": [
              "number",
              "null"
            ],
            "description": "<em>keragaman respons AI</em><br>field opsional <br>mengontrol keragaman respons dengan membatasi pemilihan token<br>nilai minimum: <code>0</code><br>nilai maksimum: <code>1</code> <br>nilai default: <code>0.9</code>"
          },
          "web_search_country_iso_code": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>kode negara untuk lokalisasi penelusuran web</em><br>field opsional<br>tentukan kode ISO negara untuk mendapatkan hasil penelusuran web yang terlokalisasi<br><strong>Catatan:</strong> hanya tersedia untuk model Perplexity Sonar<br>contoh: <code>US</code>"
          },
          "system_message": {
            "type": [
              "string",
              "null"
            ],
            "description": "<em>instruksi untuk perilaku AI</em><br>field opsional<br>menentukan peran, nada, atau perilaku spesifik AI <br>Anda dapat menentukan <strong>hingga 500 karakter</strong> di field <code>system_message</code>"
          },
          "message_chain": {
            "type": [
              "array",
              "null"
            ],
            "items": {
              "type": [
                "object",
                "null"
              ],
              "oneOf": [
                {
                  "type": "object",
                  "properties": {
                    "role": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "peran pengguna asal pesan"
                    },
                    "message": {
                      "type": [
                        "string",
                        "null"
                      ],
                      "description": "teks pesan"
                    }
                  }
                }
              ]
            },
            "description": "riwayat percakapan\nfield opsional\narray objek pesan yang mewakili giliran percakapan sebelumnya;\nsetiap objek harus berisi:\nstring role dengan peran user atau ai;\nstring message dengan konten pesan (maksimum 500 karakter);\nAnda dapat menentukan maksimum 10 objek pesan dalam array;\nCatatan: untuk model Perplexity, pesan harus bergantian secara ketat antara peran user dan AI (user → ai);\ncontoh:\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>pengenal tugas yang ditentukan pengguna</em><br>field opsional<br><em>batas karakter adalah 255</em><br>Anda dapat menggunakan parameter ini untuk mengidentifikasi tugas dan mencocokkannya dengan hasil<br>Anda akan menemukan nilai <code>tag</code> yang ditentukan di objek <code>data</code> pada respons"
          }
        },
        "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 — Operasi berhasil

Headers:
- `X-Request-Id` (string) — Pengenal permintaan yang harus disertakan saat menghubungi dukungan Felo.

**application/json**

Schema: object | null

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

### 400 — Permintaan tidak dapat diproses. Periksa parameter permintaan.

### 401 — Kunci API Felo yang valid diperlukan.

### 402 — Permintaan tidak dapat dilanjutkan karena persyaratan penagihan belum terpenuhi.

### 403 — Akun tidak diizinkan melakukan operasi ini.

### 429 — Batas permintaan atau batas pengeluaran telah tercapai.

### 502 — Layanan tidak dapat menyelesaikan permintaan.

### 503 — API atau layanan penagihan untuk sementara tidak tersedia.

### 504 — Layanan kehabisan waktu saat memproses permintaan.

### default — Respons error; respons passthrough upstream dapat menggunakan format penyedia

**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>array tugas</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_AiOptimizationPerplexityLlmResponsesLiveResultInfo

`#/components/schemas/Response36Afe1097B20_AiOptimizationPerplexityLlmResponsesLiveResultInfo`

```json
{
  "type": "object",
  "properties": {
    "model_name": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>nama model AI yang digunakan</em>"
    },
    "input_tokens": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>jumlah token pada input</em><br>total token yang diproses"
    },
    "output_tokens": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>jumlah token pada output</em><br>total token yang dihasilkan dalam respons AI"
    },
    "reasoning_tokens": {
      "type": [
        "integer",
        "null"
      ]
    },
    "web_search": {
      "type": [
        "boolean",
        "null"
      ],
      "description": "<em>menunjukkan apakah penelusuran web digunakan</em><br><strong>Catatan:</strong> penelusuran web diaktifkan secara default pada model Perplexity Sonar"
    },
    "money_spent": {
      "type": [
        "number",
        "null"
      ],
      "description": "<em>biaya token AI, USD</em><br>harga yang dikenakan oleh penyedia model AI pihak ketiga sesuai Harga mereka"
    },
    "datetime": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>tanggal dan waktu saat hasil diterima</em><br>dalam format UTC: “yyyy-mm-dd hh-mm-ss +00:00”<br>misalnya:<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>array item respons</em><br>berisi data respons AI terstruktur"
    },
    "fan_out_queries": {
      "type": [
        "object",
        "null"
      ],
      "description": "<em>array kueri fan-out</em><br>berisi kueri penelusuran terkait yang diturunkan dari kueri utama untuk memberikan respons yang lebih menyeluruh"
    }
  }
}
```

### 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>array hasil</em>"
        }
      }
    }
  ]
}
```

### Response36Afe1097B20_AnnotationInfo

`#/components/schemas/Response36Afe1097B20_AnnotationInfo`

```json
{
  "type": "object",
  "properties": {
    "title": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>nama domain atau judul sumber yang dikutip</em>"
    },
    "url": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>URL pengalihan ke sumber yang dikutip</em><br>berisi pengalihan Vertex AI yang mengarah ke sumber asli"
    },
    "direct_url": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>URL langsung ke sumber yang dikutip</em><br>berisi URL sumber asli yang menjadi tujuan pengalihan Vertex AI di field `url`"
    },
    "start_index": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>awal pengindeksan anotasi</em>"
    },
    "end_index": {
      "type": [
        "integer",
        "null"
      ],
      "description": "<em>akhir pengindeksan anotasi</em>"
    },
    "text": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>teks bagian rantai penalaran</em><br>teks bagian rantai penalaran yang merangkum proses pemikiran model"
    }
  }
}
```

### Response36Afe1097B20_BaseAiOptimizationLlmResponseElementItem

`#/components/schemas/Response36Afe1097B20_BaseAiOptimizationLlmResponseElementItem`

```json
{
  "type": "object",
  "properties": {
    "type": {
      "type": [
        "string",
        "null"
      ],
      "description": "jenis elemen"
    }
  },
  "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": "versi API saat ini"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "kode status umum; Anda dapat menemukan daftar lengkap kode respons di sini"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "pesan informasi umum; Anda dapat menemukan daftar lengkap pesan informasi umum di sini"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "total waktu eksekusi, detik"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "total biaya tugas, USD",
      "format": "double"
    },
    "tasks_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "jumlah tugas dalam array tasks",
      "format": "int64"
    },
    "tasks_error": {
      "type": [
        "integer",
        "null"
      ],
      "description": "jumlah tugas dalam array tasks yang dikembalikan dengan error",
      "format": "int64"
    }
  }
}
```

### Response36Afe1097B20_BaseResponseTaskInfo

`#/components/schemas/Response36Afe1097B20_BaseResponseTaskInfo`

```json
{
  "properties": {
    "id": {
      "type": [
        "string",
        "null"
      ],
      "description": "pengenal tugas; pengenal tugas unik di sistem kami dalam format UUID"
    },
    "status_code": {
      "type": [
        "integer",
        "null"
      ],
      "description": "kode status tugas yang dihasilkan oleh DataForSEO; dapat berada dalam rentang berikut: 10000-60000; Anda dapat menemukan daftar lengkap kode respons di sini"
    },
    "status_message": {
      "type": [
        "string",
        "null"
      ],
      "description": "pesan informasi tugas; Anda dapat menemukan daftar lengkap pesan informasi umum di sini"
    },
    "time": {
      "type": [
        "string",
        "null"
      ],
      "description": "waktu eksekusi, detik"
    },
    "cost": {
      "type": [
        "number",
        "null"
      ],
      "description": "total biaya tugas, USD",
      "format": "double"
    },
    "result_count": {
      "type": [
        "integer",
        "null"
      ],
      "description": "jumlah elemen dalam array hasil",
      "format": "int64"
    },
    "path": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "string",
          "null"
        ]
      },
      "description": "Jalur URL"
    },
    "data": {
      "type": [
        "object",
        "null"
      ],
      "additionalProperties": {
        "type": [
          "object",
          "null"
        ]
      },
      "description": "berisi parameter yang sama dengan yang Anda tentukan dalam permintaan POST"
    }
  }
}
```

### Response36Afe1097B20_LlmMessageSectionInfo

`#/components/schemas/Response36Afe1097B20_LlmMessageSectionInfo`

```json
{
  "type": "object",
  "properties": {
    "type": {
      "type": [
        "string",
        "null"
      ],
      "description": "jenis elemen"
    },
    "text": {
      "type": [
        "string",
        "null"
      ],
      "description": "<em>teks bagian rantai penalaran</em><br>teks bagian rantai penalaran yang merangkum proses pemikiran model"
    },
    "annotations": {
      "type": [
        "array",
        "null"
      ],
      "items": {
        "type": [
          "object",
          "null"
        ],
        "oneOf": [
          {
            "$ref": "#/components/schemas/Response36Afe1097B20_AnnotationInfo"
          }
        ]
      },
      "description": "<em>array referensi yang digunakan untuk menghasilkan respons</em><br>sama dengan <code>null</code> jika parameter <code>web_search</code> tidak disetel ke <code>true</code><br><strong>Catatan:</strong> <code>annotations</code> dapat mengembalikan kosong meskipun <code>web_search</code> bernilai <code>true</code>, karena AI akan mencoba mengambil informasi web tetapi mungkin tidak menemukan hasil yang relevan"
    }
  }
}
```

### 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>bagian rantai penalaran</em><br>array objek yang berisi bagian rantai penalaran yang dihasilkan oleh LLM"
        }
      }
    }
  ]
}
```
