© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
Cloudflare DevelopersCD
Cloudflare Developers•3y ago•
2 replies
AngusMa

Workers AI Error

Sometimes the Workers AI will throw a SyntaxError, but it doesn’t always fail, It usually succeeds.
Code part about Workers AI:
const ai = new Ai(env.AI);
const output =  ai.run('@cf/meta/llama-2-7b-chat-int8', {
  prompt: args.prompt
}).then(function (result){
  return result;
}).then(async function (result){
  await fetch('https://discord.com/api/v10/webhooks/'+env.DISCORD_APPLICATION_ID+'/'+interaction.token+'/messages/@original',{
      method:'PATCH',
      headers:{'content-type': 'application/json;charset=UTF-8',},
      body:JSON.stringify({
          content: result.response,
      })
  })
})
const ai = new Ai(env.AI);
const output =  ai.run('@cf/meta/llama-2-7b-chat-int8', {
  prompt: args.prompt
}).then(function (result){
  return result;
}).then(async function (result){
  await fetch('https://discord.com/api/v10/webhooks/'+env.DISCORD_APPLICATION_ID+'/'+interaction.token+'/messages/@original',{
      method:'PATCH',
      headers:{'content-type': 'application/json;charset=UTF-8',},
      body:JSON.stringify({
          content: result.response,
      })
  })
})

The error (root directory path replaced with PROJECT_DIR):
✘ [ERROR] Uncaught (in promise) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON

      at async InferenceSession.run
  ({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6124:26)
      at async Ai.run
  ({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6192:30)


✘ [ERROR] Uncaught (async) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON
✘ [ERROR] Uncaught (in promise) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON

      at async InferenceSession.run
  ({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6124:26)
      at async Ai.run
  ({PROJECT_DIR}/.wrangler/tmp/dev-5g4ZDx/server.js:6192:30)


✘ [ERROR] Uncaught (async) SyntaxError: Unexpected token 'E', "ERROR 3026"... is not valid JSON
Cloudflare Developers banner
Cloudflare DevelopersJoin
Welcome to the official Cloudflare Developers server. Here you can ask for help and stay updated with the latest news
85,042Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

Workers AI Error 429 (3040)
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
11mo ago
Workers AI
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
4w ago
workers ai
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
3y ago
Workers AI: getting internal server error
Cloudflare DevelopersCDCloudflare Developers / workers-and-pages-help
2y ago