| Level Navigation: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Current Level: 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |
Add proper error handling to your AI model calls.
.catch() to handle AI errors (similar to Level 16 API error handling)if(response.ok === false) { console.log('AI Error: ' + response.status + ' ' + response.statusText) } to handle AI API errorshttps:// to thtps:// (typo in protocol)/v1/chat/completions to /v1/chat/completionss (extra ‘s’)"model": "invalid-model-name" (Look at the POJO sent as an argument to the fetch function call.)Need help with AI error handling? Check out these snippets:
.catch() examplessetText() to show error messages to users| Level Navigation: 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | Current Level: 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 |