設定 Harness
Chat API
接入帶有查詢分析、網頁資源和引用的 AI 對話搜尋。
POST
/v2/chat認證
Bearer API key
Content type
application/json
限流說明
Per API key and per user windows. Read X-RateLimit headers.
Chat API 可將 AI-powered conversational search 接入你的應用。傳送自然語言 query,即可獲得基於實時 web search results 生成的智慧回答。
Overview
Chat API 會執行以下流程:
- 分析並最佳化 query
- 搜尋相關 web information
- 排序並過濾 search results
- 基於 sources 生成完整 AI answer
- 返回 answer 和 source citations
認證
Authorization: Bearer YOUR_API_KEY詳見 認證指南。
Endpoint
POST https://openapi.felo.ai/v2/chat請求
| 引數 | 型別 | 必填 | 說明 | Constraints |
|---|---|---|---|---|
query | string | 是 | 使用者問題或搜尋 query | 1-2000 characters |
回應
{
"status": "ok",
"message": null,
"data": {
"answer": "...",
"query_analysis": { "queries": ["..."] },
"resources": [{ "link": "https://example.com", "title": "Source", "snippet": "..." }]
}
}回應欄位
| 欄位 | 型別 | 說明 |
|---|---|---|
status | string | "ok" 或 "error" |
data.answer | string | AI-generated answer |
data.query_analysis.queries | string[] | 從使用者輸入生成的最佳化 search queries |
data.resources | array | 用於生成回答的 web sources |
錯誤碼
| Code | HTTP Status | 說明 | Solution |
|---|---|---|---|
INVALID_API_KEY | 401 | API Key 無效或已撤銷 | 檢查 key 是否正確且 active |
MISSING_AUTHORIZATION | 401 | 缺少 Authorization header | 加入 Authorization header |
MISSING_PARAMETER | 400 | 缺少必填引數 | 確保 body 中包含 query |
QUERY_TOO_LONG | 400 | Query 超過最大長度 | 縮短到 2000 characters 以內 |
RATE_LIMITED | 429 | 請求過多 | 降低請求頻率或聯絡 support |
Example
curl -X POST https://openapi.felo.ai/v2/chat -H "Authorization: Bearer YOUR_API_KEY" -H "Content-Type: application/json" -d '{"query":"What are the benefits of renewable energy?"}'