gpt4 book ai didi

python-3.x - 适用于 Python 的必应图像搜索 SDK : Getting 'Permission Denied'

转载 作者:行者123 更新时间:2023-12-03 00:05:43 25 4
gpt4 key购买 nike

我正在尝试使用示例程序 provided by Microsoft here测试与其在 Azure 上的认知服务产品相关的 Bing 图像搜索服务。我逐个字符地输入代码(当然,使用我自己的 API key ),当我执行程序时,我收到以下错误消息:

Traceback (most recent call last):
File "x.py", line 9, in <module>
image_results = client.images.search(query=search_term)
File "/home/rsbrownjr/anaconda3/envs/ibing/lib/python3.6/site-packages/azure/cognitiveservices/search/imagesearch/operations/images_operations.py", line 485, in search
raise models.ErrorResponseException(self._deserialize, response)
azure.cognitiveservices.search.imagesearch.models.error_response_py3.ErrorResponseException: Operation returned an invalid status code 'PermissionDenied'

我毫无疑问地知道我已将正确的 API key 放入程序中。我的定价等级为 S0 即用即付,但我也没有任何其他选择。这必须有一个简单的解决方案。

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

subscription_key = "MY API KEY HERE"
search_term = "canadian rockies"

client = ImageSearchAPI(CognitiveServicesCredentials(subscription_key))

image_results = client.images.search(query=search_term)

if image_results.value:
first_image_result = image_results.value[0]
print("Total number of images returned: {}".format(len(image_results.value)))
print("First image thumbnail url: {}".format(
first_image_result.thumbnail_url))
print("First image content url: {}".format(first_image_result.content_url))
else:
print("No image results returned!")

最佳答案

我刚刚测试了代码,代码没问题。因此您必须提供错误的 API key 。

enter image description here

这是我的测试 key 52c32221ceaa4f388b26a2b85fb79bff。这是 7 天免费试用 key 。我明白了here .

enter image description here

关于python-3.x - 适用于 Python 的必应图像搜索 SDK : Getting 'Permission Denied' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57421770/

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