Skip to content

Limit concurrent generations

Concurrent generation limits protect the organization from bursts of requests, such as an integration starting hundreds of tasks by mistake. They correspond to the concurrent generation settings in the dashboard:

  • inflightCountLimit limits the number of generations running at once.
  • inflightRubLimit limits their combined cost in rubles.
  • maxCostLimit sets the maximum cost of one generation in rubles. More expensive generations are rejected.

Once a limit is reached, new generations are blocked until enough in-flight tasks finish. The employee sees the rejection without the limit values. Organization, team, and employee limits all apply at the same time. The strictest limit wins.

Only keys whose creator is an owner or admin can change concurrent generation limits. A manager cannot change these limits for their own teams or team members. Each such item returns forbidden. An organization-level request from a manager returns HTTP 403. A personal account key or a key whose creator has the member role receives HTTP 403 for the entire request.

A key creator cannot change the limits on their own account or on an employee with a higher role. For example, an admin cannot change an owner’s limits.

POSThttps://gptunnel.ru/api/v1/access/setInflightLimits

Send 1 to 25 employee entries in items. If a login appears more than once, only its first entry is applied. An error for one employee does not stop the request from processing the others.

Request headers

ParameterTypeDescription
Authorization*stringAPI key

Request parameters

ParameterTypeDescription
items*object[]Array of 1–25 employees. Each item has this shape: { login, inflightCountLimit?, inflightRubLimit?, maxCostLimit? }
items[].login*stringEmployee login. Matching is case-insensitive.
items[].inflightCountLimitnumberMaximum number of concurrent generations. Use an integer from 0 to 1,000,000. Use 0 for no limit.
items[].inflightRubLimitnumberMaximum combined cost of running generations, in whole rubles (RUB). Use 0 for no limit.
items[].maxCostLimitnumberMaximum cost of a single generation, in whole rubles (RUB). Use 0 for no limit.

The response counts successful employee updates in updated and failures in failed. Each entry in failedLogins identifies the login and explains the error.

Error reasons

ParameterTypeDescription
not_foundstringNo employee in the organization has this login
forbiddenstringThe caller is a manager, the target is the key creator, or the employee has a higher role than the caller.
errorstringUnexpected error processing this employee. Retry the request.

Set GPTUNNEL_API_KEY and replace the placeholders with values for your organization.

import json
import os
from urllib.request import Request, urlopen
key = os.environ.get("GPTUNNEL_API_KEY")
if not key:
raise SystemExit("Set GPTUNNEL_API_KEY")
body = {
"items": [
{
"login": "ivanov@company.com",
"inflightCountLimit": 2,
"inflightRubLimit": 500,
"maxCostLimit": 150
},
{
"login": "petrov@company.com",
"maxCostLimit": 0
}
]
}
request = Request(
"https://gptunnel.ru/api/v1/access/setInflightLimits",
method="POST",
headers={
"Authorization": key,
"Content-Type": "application/json",
},
data=json.dumps(body).encode("utf-8"),
)
with urlopen(request, timeout=30) as response:
print(json.load(response))
{
"code": 0,
"updated": 1,
"failed": 1,
"failedLogins": [
{
"login": "petrov@company.com",
"reason": "not_found",
"message": "Employee not found in the organization."
}
]
}
POSThttps://gptunnel.ru/api/v1/access/setTeamInflightLimits

The limits apply to the entire team. Send up to 25 entries in items, each with { teamId, inflightCountLimit?, inflightRubLimit?, maxCostLimit? }. Get teamId from POST /api/v1/employees/getTeams. The response counts successes and failures in updated and failed. Each entry in failedTeams has a reason: not_found for a team outside the organization, forbidden for a manager’s key, or error.

import json
import os
from urllib.request import Request, urlopen
key = os.environ.get("GPTUNNEL_API_KEY")
if not key:
raise SystemExit("Set GPTUNNEL_API_KEY")
body = {
"items": [
{
"teamId": "664f0a1b2c3d4e5f60718293",
"inflightCountLimit": 3,
"inflightRubLimit": 1000
}
]
}
request = Request(
"https://gptunnel.ru/api/v1/access/setTeamInflightLimits",
method="POST",
headers={
"Authorization": key,
"Content-Type": "application/json",
},
data=json.dumps(body).encode("utf-8"),
)
with urlopen(request, timeout=30) as response:
print(json.load(response))
{
"code": 0,
"updated": 1,
"failed": 0,
"failedTeams": []
}
POSThttps://gptunnel.ru/api/v1/access/setOrgInflightLimits

Send a single object, { inflightCountLimit?, inflightRubLimit?, maxCostLimit? }, as the request body. A manager’s key receives HTTP 403.

import json
import os
from urllib.request import Request, urlopen
key = os.environ.get("GPTUNNEL_API_KEY")
if not key:
raise SystemExit("Set GPTUNNEL_API_KEY")
body = {
"maxCostLimit": 5000
}
request = Request(
"https://gptunnel.ru/api/v1/access/setOrgInflightLimits",
method="POST",
headers={
"Authorization": key,
"Content-Type": "application/json",
},
data=json.dumps(body).encode("utf-8"),
)
with urlopen(request, timeout=30) as response:
print(json.load(response))
{
"code": 0,
"updated": true
}

Read the current values in the inflight object returned by the access settings methods.