gpt4 book ai didi

javascript - Azure 翻译 API - 限制客户端请求

转载 作者:行者123 更新时间:2023-12-03 03:47:31 27 4
gpt4 key购买 nike

我正在尝试限制客户端可以向使用 Azure Translation API 的翻译服务发出的请求数量。

以下来自 Microsoft 的链接描述了如何限制请求,但不清楚应在请求中的何处添加此限制信息。我假设请求 header ?

https://learn.microsoft.com/en-us/azure/api-management/api-management-sample-flexible-throttling

这是 curl 。请注意末尾的速率限制 header 。这是这样做的方法吗?

// Pass secret key and region using headers to a custom endpoint
curl -X POST " my-ch-n.cognitiveservices.azure.com/translator/text/v3.0/translate?to=fr" \
-H "Ocp-Apim-Subscription-Key: xxx" \
-H "Ocp-Apim-Subscription-Region: switzerlandnorth" \
-H "Content-Type: application/json" \
-H "rate-limit-by-key: calls=10 renewal-period=60 counter-key=1.1.1.1" \
-d "[{'Text':'Hello'}]" -v

最佳答案

您共享的链接来自 API Management,这是 Azure 上提供的托管 API 网关。这个想法是生成“产品”并让您的用户订阅它们。这样,您将能够跟踪请求并使用速率限制策略(您共享的链接)执行限制。

如果需要,请观看此简短视频,展示此功能的使用情况:

https://www.youtube.com/watch?v=dbF7uVkGOw0

关于javascript - Azure 翻译 API - 限制客户端请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/68568694/

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