You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When processing the streaming response, you'll receive quota usage information in the final `done` event. Here's a JavaScript example of how to handle this:
// Schedule next request after quota reset if needed
166
+
if (remainingRequests ===0) {
167
+
setTimeout(() => {
168
+
// Safe to make next request
169
+
}, remainingTimeMs);
170
+
}
171
+
}
172
+
173
+
eventSource.close();
174
+
});
175
+
```
176
+
146
177
**Using MCP Server Backend Mode via API:**
147
178
148
179
You can override the agent's default backend mode by adding the `use_mcp` parameter:
@@ -182,7 +213,13 @@ event: execution
182
213
data: Your final answer from the agent.
183
214
184
215
event: done
185
-
data: {}
216
+
data: {
217
+
"maxRequests": 200,
218
+
"remainingRequests": 193,
219
+
"maxTokens": 200000,
220
+
"remainingTokens": 179910,
221
+
"remainingTimeMs": 903
222
+
}
186
223
```
187
224
188
225
**Possible Event Types:**
@@ -242,11 +279,30 @@ The final textual answer or a chunk of the answer from the agent for the user. F
242
279
<details>
243
280
<summary><b><code>done</code> (Click to expand)</b></summary>
244
281
245
-
Signals that the agent has finished processing and the response stream is complete.
282
+
Signals that the agent has finished processing and the response stream is complete. This event also includes quota usage information for managing your API limits.
246
283
247
-
```json
248
-
{}
284
+
```json showLineNumbers
285
+
{
286
+
"quotaUsage": {
287
+
"maxRequests": 200,
288
+
"remainingRequests": 193,
289
+
"maxTokens": 200000,
290
+
"remainingTokens": 179910,
291
+
"remainingTimeMs": 903
292
+
}
293
+
}
249
294
```
295
+
296
+
**Quota Usage Fields:**
297
+
-`maxRequests`: Maximum number of requests allowed in the current rolling window
298
+
-`remainingRequests`: Number of requests remaining in the current window
299
+
-`maxTokens`: Maximum number of tokens allowed in the current rolling window
300
+
-`remainingTokens`: Number of tokens remaining in the current window
301
+
-`remainingTimeMs`: Time in milliseconds until the rolling window resets
302
+
303
+
:::tip Managing quota usage
304
+
Use the quota information in the `done` event to implement client-side rate limiting and avoid hitting API limits. When `remainingRequests` or `remainingTokens` are low, consider adding delays between requests or queuing them for later execution.
305
+
:::
250
306
</details>
251
307
252
308
</TabItem>
@@ -344,6 +400,8 @@ Port applies limits to AI agent interactions to ensure fair usage across all cus
344
400
-**Query limit**: ~40 queries per hour.
345
401
-**Token usage limit**: 800,000 tokens per hour.
346
402
403
+
You can view your quota limits are available in the API response.
404
+
347
405
:::caution Usage limits
348
406
Usage limits may change without prior notice. Once a limit is reached, you will need to wait until it resets.
349
407
If you attempt to interact with an agent after reaching a limit, you will receive an error message indicating that the limit has been exceeded.
@@ -448,6 +506,17 @@ Ensure that:
448
506
The AI invocation entity contains the `feedback` property where you can mark is as `Negative` or `Positive`. We're working on adding a more convenient way to rate conversation from Slack and from the UI.
449
507
</details>
450
508
509
+
<details>
510
+
<summary><b>What are the usage limits and how can I know them? (Click to expand)</b></summary>
511
+
512
+
Port applies the following limits to AI agent interactions:
513
+
-**Query limit**: ~40 queries per hour
514
+
-**Token usage limit**: 800,000 tokens per hour
515
+
516
+
You can monitor your current usage in the final `done` event showing your remaining requests, tokens, and reset time.
517
+
518
+
</details>
519
+
451
520
<details>
452
521
<summary><b>How is my data with AI agents handled? (Click to expand)</b></summary>
0 commit comments