docs(ai): document onPayload callback

This commit is contained in:
Mario Zechner 2026-01-19 00:12:43 +01:00
parent ea02243a18
commit 023f6e2fa4

View file

@ -598,6 +598,20 @@ context.messages.push({ role: 'user', content: 'Please continue' });
const continuation = await complete(model, context);
```
### Debugging Provider Payloads
Use the `onPayload` callback to inspect the request payload sent to the provider. This is useful for debugging request formatting issues or provider validation errors.
```typescript
const response = await complete(model, context, {
onPayload: (payload) => {
console.log('Provider payload:', JSON.stringify(payload, null, 2));
}
});
```
The callback is supported by `stream`, `complete`, `streamSimple`, and `completeSimple`.
## APIs, Models, and Providers
The library implements 4 API interfaces, each with its own streaming function and options: