Skip to content

Commit 4c9b755

Browse files
Add additional token calculation information to the Limit Azure OpenAI API token usage API Management policy
How does the new APIM policy “Limit Azure OpenAI API token usage” `estimate-prompt-tokens` feature work? How does it estimate the tokens? Only of the prompt or also of the response? What changes, when I activate/deactivate it? The documentation was way too minimal on this. This change adds some additional information about the impact of setting `estimate-prompt-tokens` to false. This is important, because it might cause the probably unexpected behavior of sending requests to the LLM backend, which should have been filtered out by the policy. Please check for correctness by the Product Team.
1 parent 3637397 commit 4c9b755

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

articles/api-management/azure-openai-token-limit-policy.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ For more information, see [Azure OpenAI Service models](../ai-services/openai/co
5454
| -------------- | ----------------------------------------------------------------------------------------------------- | -------- | ------- |
5555
| counter-key | The key to use for the token limit policy. For each key value, a single counter is used for all scopes at which the policy is configured. Policy expressions are allowed.| Yes | N/A |
5656
| tokens-per-minute | The maximum number of tokens consumed by prompt and completion per minute. | Yes | N/A |
57-
| estimate-prompt-tokens | Boolean value that determines whether to estimate the number of tokens required for a prompt: <br> - `true`: estimate the number of tokens based on prompt schema in API; may reduce performance. <br> - `false`: don't estimate prompt tokens. | Yes | N/A |
57+
| estimate-prompt-tokens | Boolean value that determines whether to estimate the number of tokens required for a prompt: <br> - `true`: estimate the number of tokens based on prompt schema in API; may reduce performance. <br> - `false`: don't estimate prompt tokens. <br><br> _When setting this to `false`, the remaing tokens per `counter-key` will be calculated using the actual token-usage from the response of the model. This could result in prompts being sent to the model, that exceed the token limit. In such case, this will be detected in the response result in all succeeding requests being blocked by the policy, until the token limit frees up again._ | Yes | N/A |
5858
| retry-after-header-name | The name of a custom response header whose value is the recommended retry interval in seconds after the specified `tokens-per-minute` is exceeded. Policy expressions aren't allowed. | No | `Retry-After` |
5959
| retry-after-variable-name | The name of a variable that stores the recommended retry interval in seconds after the specified `tokens-per-minute` is exceeded. Policy expressions aren't allowed. | No | N/A |
6060
| remaining-tokens-header-name | The name of a response header whose value after each policy execution is the number of remaining tokens allowed for the time interval. Policy expressions aren't allowed.| No | N/A |

0 commit comments

Comments
 (0)