@patternzones/koine-sdk 2.0.4 → 2.1.0
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.
- package/README.md +21 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -76,6 +76,27 @@ Creates a client instance with the given configuration. The config is validated
|
|
|
76
76
|
| `KoineError` | Error class with typed `code` property |
|
|
77
77
|
| `KoineErrorCode` | Union type of all possible error codes |
|
|
78
78
|
|
|
79
|
+
## Error Handling & Retries
|
|
80
|
+
|
|
81
|
+
The SDK does not automatically retry failed requests. When the gateway returns `429 Too Many Requests` (concurrency limit exceeded), your application should implement retry logic:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
async function generateWithRetry(prompt: string, maxRetries = 3) {
|
|
85
|
+
for (let i = 0; i < maxRetries; i++) {
|
|
86
|
+
try {
|
|
87
|
+
return await koine.generateText({ prompt });
|
|
88
|
+
} catch (error) {
|
|
89
|
+
if (error instanceof KoineError && error.code === 'CONCURRENCY_LIMIT_ERROR') {
|
|
90
|
+
await new Promise(r => setTimeout(r, 1000 * (i + 1))); // Exponential backoff
|
|
91
|
+
continue;
|
|
92
|
+
}
|
|
93
|
+
throw error;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
throw new Error('Max retries exceeded');
|
|
97
|
+
}
|
|
98
|
+
```
|
|
99
|
+
|
|
79
100
|
## Documentation
|
|
80
101
|
|
|
81
102
|
See the [SDK Guide](https://github.com/pattern-zones-co/koine/blob/main/docs/sdk-guide.md) for:
|