llm-errors 0.1.4 → 0.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (28) hide show
  1. package/CHANGELOG.md +24 -0
  2. package/README.md +14 -5
  3. package/dist/index.cjs +133 -31
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +8 -5
  6. package/dist/index.d.ts +8 -5
  7. package/dist/index.js +133 -31
  8. package/dist/index.js.map +1 -1
  9. package/fixtures/README.md +5 -2
  10. package/fixtures/cases/anthropic/rate-limit-credit-balance.json +17 -0
  11. package/fixtures/cases/anthropic/sdk-billing-error.json +14 -0
  12. package/fixtures/cases/gemini/plain-unavailable-body.json +9 -0
  13. package/fixtures/cases/gemini/rpc-quota-exhausted-billing.json +11 -0
  14. package/fixtures/cases/gemini/rpc-quota-exhausted-rate-bucket.json +11 -0
  15. package/fixtures/cases/generic/http-400-retry-after.json +15 -0
  16. package/fixtures/cases/generic/http-503-retry-after.json +15 -0
  17. package/fixtures/cases/openai/plain-rate-limit-body.json +10 -0
  18. package/fixtures/cases/openai/sdk-billing-hard-limit.json +12 -0
  19. package/fixtures/expected/anthropic/rate-limit-credit-balance.json +8 -0
  20. package/fixtures/expected/anthropic/sdk-billing-error.json +8 -0
  21. package/fixtures/expected/gemini/plain-unavailable-body.json +8 -0
  22. package/fixtures/expected/gemini/rpc-quota-exhausted-billing.json +8 -0
  23. package/fixtures/expected/gemini/rpc-quota-exhausted-rate-bucket.json +8 -0
  24. package/fixtures/expected/generic/http-400-retry-after.json +7 -0
  25. package/fixtures/expected/generic/http-503-retry-after.json +8 -0
  26. package/fixtures/expected/openai/plain-rate-limit-body.json +7 -0
  27. package/fixtures/expected/openai/sdk-billing-hard-limit.json +7 -0
  28. package/package.json +2 -2
@@ -0,0 +1,10 @@
1
+ {
2
+ "name": "OpenAI direct plain rate limit body",
3
+ "shape": "plain-provider-error-body",
4
+ "error": {
5
+ "message": "Rate limit reached for requests",
6
+ "type": "rate_limit_error",
7
+ "code": "rate_limit_exceeded",
8
+ "param": null
9
+ }
10
+ }
@@ -0,0 +1,12 @@
1
+ {
2
+ "name": "OpenAI SDK billing hard limit",
3
+ "shape": "openai-sdk-api-error",
4
+ "error": {
5
+ "error": {
6
+ "message": "Billing hard limit has been reached",
7
+ "type": "invalid_request_error",
8
+ "code": "billing_hard_limit_reached",
9
+ "param": null
10
+ }
11
+ }
12
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "provider": "anthropic",
3
+ "category": "insufficient_quota",
4
+ "message": "Your credit balance is too low.",
5
+ "status": 429,
6
+ "code": "rate_limit_error",
7
+ "retryable": false
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "provider": "anthropic",
3
+ "category": "insufficient_quota",
4
+ "message": "Your credit balance is too low.",
5
+ "status": 429,
6
+ "code": "billing_error",
7
+ "retryable": false
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "provider": "gemini",
3
+ "category": "overloaded",
4
+ "message": "The model is overloaded. Please try again later.",
5
+ "status": 503,
6
+ "code": "UNAVAILABLE",
7
+ "retryable": true
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "provider": "gemini",
3
+ "category": "insufficient_quota",
4
+ "message": "You exceeded your current quota, please check your plan and billing details.",
5
+ "status": 429,
6
+ "code": "RESOURCE_EXHAUSTED",
7
+ "retryable": false
8
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "provider": "gemini",
3
+ "category": "rate_limit",
4
+ "message": "Quota exceeded for requests per minute.",
5
+ "status": 429,
6
+ "code": "RESOURCE_EXHAUSTED",
7
+ "retryable": true
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "provider": "unknown",
3
+ "category": "invalid_request",
4
+ "message": "Bad request",
5
+ "status": 400,
6
+ "retryable": false
7
+ }
@@ -0,0 +1,8 @@
1
+ {
2
+ "provider": "unknown",
3
+ "category": "overloaded",
4
+ "message": "Service temporarily unavailable",
5
+ "status": 503,
6
+ "retryable": true,
7
+ "retryAfterMs": 6000
8
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "provider": "openai",
3
+ "category": "rate_limit",
4
+ "message": "Rate limit reached for requests",
5
+ "code": "rate_limit_exceeded",
6
+ "retryable": true
7
+ }
@@ -0,0 +1,7 @@
1
+ {
2
+ "provider": "openai",
3
+ "category": "insufficient_quota",
4
+ "message": "Billing hard limit has been reached",
5
+ "code": "billing_hard_limit_reached",
6
+ "retryable": false
7
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "llm-errors",
3
- "version": "0.1.4",
3
+ "version": "0.1.5",
4
4
  "description": "Normalize OpenAI, Anthropic and Gemini API errors into one shape: category, retryable flag and Retry-After delay. Zero dependencies.",
5
5
  "keywords": [
6
6
  "openai",
@@ -72,7 +72,7 @@
72
72
  "eslint": "^10.4.1",
73
73
  "prettier": "^3.4.2",
74
74
  "tsup": "^8.3.5",
75
- "typescript": "^5.7.2",
75
+ "typescript": "^6.0.3",
76
76
  "typescript-eslint": "^8.60.0",
77
77
  "vitest": "^4.1.8"
78
78
  }