Translate example running out of time

I’m using the simple template for the translation genai sample (code below), and I keep getting request timeouts. I’m on the free tier w/ a ten second limit, but shouldn’t it be enough time to process?

Here’s the code, but like I said, it’s right from the sample.

import { Ai } from '@cloudflare/ai';

export default {
	async fetch(request, env) {
		const ai = new Ai(env.AI);
		const inputs = {
			text: 'Tell me a joke about Cloudflare',
			source_lang: 'en',
			target_lang: 'fr'
		const response = await'@cf/meta/m2m100-1.2b', inputs);

		return Response.json({ inputs, response });


The Workers free tier only offers 10ms of CPU, which is likely the limit you’re hitting.

You’ll definitely want to upgrade to a paid plan with more CPU ms available for this kind of use-case.

1 Like

Ok. I had done another test previously with one of the other models and it returned really quickly. Is this one that much slower? (And if you don’t have the limit and could give it a quick try, I’d love to hear how long it takes for you. :slight_smile:

Randomly, today requests are responding in less than two seconds or so. :slight_smile:

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.