gpt4 book ai didi

python - Azure Bing 图像搜索客户端抛出找不到资源的错误

转载 作者:行者123 更新时间:2023-12-02 08:31:00 25 4
gpt4 key购买 nike

我正在尝试使用 bing 图像搜索 SDK,但本教程对我不起作用:

https://learn.microsoft.com/en-us/azure/cognitive-services/bing-image-search/quickstarts/client-libraries?pivots=programming-language-python

from azure.cognitiveservices.search.imagesearch import ImageSearchClient 
from msrest.authentication import CognitiveServicesCredentials

# This is my key generated by azure portal
subscription_key = "XXXXXXXXXXXXXXXXX"
# This is my endpoint generated by azure portal
subscription_endpoint = "https://vadmeggy-image-search.cognitiveservices.azure.com/bing/v7.0"
search_term = "bird"

client = ImageSearchClient(endpoint=subscription_endpoint, credentials=CognitiveServicesCredentials(subscription_key))
image_results = client.images.search(query=search_term)

异常(exception):

azure.cognitiveservices.search.imagesearch.models._models_py3.ErrorResponseException:操作返回无效的状态代码“找不到资源”

我错过了什么?我调用了 REST API,它与给定的订阅 key 配合得很好。如果 SDK 不起作用,我可以回退到 REST API,但也许有人可以帮助我。

最佳答案

Python实现自动添加Bing版本,需要使用

subscription_endpoint = "https://vadmeggy-image-search.cognitiveservices.azure.com"

一切都会好起来的。文档和实现似乎不同步。

关于python - Azure Bing 图像搜索客户端抛出找不到资源的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61035548/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com