Developer API
Ошибки и биллинг
Большинство long-running jobs сразу возвращают queued ids. Billing и budget responses включают credit fields, чтобы client мог показать понятное решение пользователю.
#HTTP-ошибки
Клиенты должны ветвиться по status code и error code, а затем показывать пользователю billing или retry решение.
401Bearer token отсутствует, истек или невалиден.
402Недостаточно credits, budget exceeded или требуется premium approval.
403API key валиден, но у него нет scope, нужного для endpoint.
404Generation, repurpose task, user или account не найден.
409Device code уже использован или request конфликтует с текущим state.
429API key или organization превысили текущий request limit.
502Gateway не смог достучаться до upstream provider или прочитать его response.
503Нет доступного provider route или upstream provider вернул ошибку.
500Queue, database, provider или internal processing failure.
#Форматы error response
Большинство endpoints возвращают structured error body с code и message. AI Gateway chat routes возвращают OpenAI-compatible error.type, error.code и error.message. Часть legacy media handlers всё ещё возвращает string error body.
{
"error": {
"code": "insufficient_credits",
"message": "Insufficient credits"
}
}
{
"error": {
"type": "provider_unavailable",
"code": "provider_unavailable",
"message": "No configured provider route completed the request"
}
}