Brave Images
2026-03-30
新闻来源:网淘吧
围观:6
电脑广告
手机广告
Brave 图片搜索
通过 Brave Search API 搜索图片。
使用方法
curl -s "https://api.search.brave.com/res/v1/images/search?q=QUERY&count=COUNT" \
-H "X-Subscription-Token: $BRAVE_API_KEY"
参数
| 参数 | 必需 | 描述 |
|---|---|---|
q | 是 | 搜索查询(URL编码) |
count | 否 | 结果数量(1-100,默认值 20) |
country | 否 | 用于区域偏好的两位字母代码(US, DE, IL) |
search_lang | 否 | 语言代码(en, de, he) |
safesearch | 否 | 关闭、中等、严格(默认值:中等) |
响应解析
每个结果中的关键字段:

results[].title—— 图片标题results[].properties.url—— 完整图片URLresults[].thumbnail.src—— 缩略图URLresults[].source—— 来源网站results[].properties.width/height—— 尺寸
示例
搜索以色列的“日落海滩”图片:
curl -s "https://api.search.brave.com/res/v1/images/search?q=sunset%20beach&count=5&country=IL" \
-H "X-Subscription-Token: $BRAVE_API_KEY"
然后从JSON响应中提取:
- 缩略图:
.results[0].thumbnail.src - 完整图片:
.results[0].properties.url
结果交付
当呈现图片搜索结果时:
- 直接向用户发送图片(不要仅列出URL)
- 使用
results[].properties.url获取完整图片,或使用results[].thumbnail.src用于缩略图 - 将图像标题作为图注包含
- 如果存在比显示的更多的结果,告知用户(例如,"找到20张图片,显示3张——需要更多吗?")
示例流程:
User: "find me pictures of sunsets"
→ Search with count=10
→ Send 3-5 images with captions
→ "Found 10 sunset images, showing 5. Want to see more?"
注意事项
- 对查询字符串进行URL编码(空格转换为
%20) - 来自环境变量的API密钥:
$BRAVE_API_KEY - 遵守订阅层级的速率限制
文章底部电脑广告
手机广告位-内容正文底部
上一篇:Antigravity Balance
下一篇:Gitea


微信扫一扫,打赏作者吧~