---
description: Run machine learning models, powered by serverless GPUs, on Cloudflare's global network.
title: Cloudflare Workers AI
image: https://developers.cloudflare.com/workers-ai/og.png?v=28f3ca6015fd2e9e
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Cloudflare Workers AI

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Run machine learning models, powered by serverless GPUs, on Cloudflare's global network.

Available on Free and Paid plans

Workers AI allows you to run AI models in a serverless way, without having to worry about scaling, maintaining, or paying for unused infrastructure. You can invoke models running on GPUs on Cloudflare's network from your own code — from [Workers](https://developers.cloudflare.com/workers/), [Pages](https://developers.cloudflare.com/pages/), or anywhere via [the Cloudflare API](https://developers.cloudflare.com/api/resources/ai/methods/run/).

Workers AI gives you access to:

- **50+ [open-source models](https://developers.cloudflare.com/workers-ai/models/)**, available as a part of our model catalog
- Serverless, **pay-for-what-you-use** [pricing model](https://developers.cloudflare.com/workers-ai/platform/pricing/)
- All as part of a **fully-featured developer platform**, including [AI Gateway](https://developers.cloudflare.com/ai-gateway/), [Vectorize](https://developers.cloudflare.com/vectorize/), [Workers](https://developers.cloudflare.com/workers/) and more...

[Get started](https://developers.cloudflare.com/workers-ai/get-started) [Watch a Workers AI demo](https://youtu.be/cK_leoJsBWY?si=4u6BIy_uBOZf9Ve8)

Custom requirements

If you have custom requirements like private custom models or higher limits, complete the [Custom Requirements Form ↗︎](https://forms.gle/axnnpGDb6xrmR31T6). Cloudflare will contact you with next steps.

Workers AI is now Generally Available

To report bugs or give feedback, go to the [#workers-ai Discord channel ↗︎](https://discord.cloudflare.com). If you are having issues with Wrangler, report issues in the [Wrangler GitHub repository ↗︎](https://github.com/cloudflare/workers-sdk/issues/new/choose).

---

## Features

[Models](https://developers.cloudflare.com/workers-ai/models/)

Workers AI comes with a curated set of popular open-source models that enable you to do tasks such as image classification, text generation, object detection and more.

Browse models

---

## Related products

[AI Gateway](https://developers.cloudflare.com/ai-gateway/)

Observe and control your AI applications with caching, rate limiting, request retries, model fallback, and more.

[Vectorize](https://developers.cloudflare.com/vectorize/)

Build full-stack AI applications with Vectorize, Cloudflare’s vector database. Adding Vectorize enables you to perform tasks such as semantic search, recommendations, anomaly detection or can be used to provide context and memory to an LLM.

[Workers](https://developers.cloudflare.com/workers/)

Build serverless applications and deploy instantly across the globe for exceptional performance, reliability, and scale.

[Pages](https://developers.cloudflare.com/pages/)

Create full-stack applications that are instantly deployed to the Cloudflare global network.

[R2](https://developers.cloudflare.com/r2/)

Store large amounts of unstructured data without the costly egress bandwidth fees associated with typical cloud storage services.

[D1](https://developers.cloudflare.com/d1/)

Create new serverless SQL databases to query from your Workers and Pages projects.

[Durable Objects](https://developers.cloudflare.com/durable-objects/)

A globally distributed coordination API with strongly consistent storage.

[KV](https://developers.cloudflare.com/kv/)

Create a global, low-latency, key-value data storage.

---

## More resources

### [Get started](https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/)

Build and deploy your first Workers AI application.

### [Plans](https://developers.cloudflare.com/workers-ai/platform/pricing/)

Learn about Free and Paid plans.

### [Limits](https://developers.cloudflare.com/workers-ai/platform/limits/)

Learn about Workers AI limits.

### [Use cases](https://developers.cloudflare.com/use-cases/ai/)

Learn how you can build and deploy ambitious AI applications to Cloudflare's global network.

### [Storage options](https://developers.cloudflare.com/workers/platform/storage-options/)

Learn which storage option is best for your project.

### [Developer Discord](https://discord.cloudflare.com)

Connect with the Workers community on Discord to ask questions, share what you are building, and discuss the platform with other developers.

### [@CloudflareDev](https://x.com/cloudflaredev)

Follow @CloudflareDev on Twitter to learn about product announcements, and what is new in Cloudflare Workers.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/#page","headline":"Cloudflare Workers AI","description":"Run machine learning models, powered by serverless GPUs, on Cloudflare's global network.","url":"https://developers.cloudflare.com/workers-ai/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/og.png?v=28f3ca6015fd2e9e","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: Set up your first Workers AI project using the dashboard, CLI, or REST API.
title: Getting started
image: https://developers.cloudflare.com/workers-ai/get-started/og.png?v=7e846a5a03484ca2
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Getting started

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/get-started/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

There are several options to build your Workers AI projects on Cloudflare. To get started, choose your preferred method:

- [Workers Bindings](https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/)
- [REST API](https://developers.cloudflare.com/workers-ai/get-started/rest-api/)
- [Dashboard](https://developers.cloudflare.com/workers-ai/get-started/dashboard/)

Note

These examples are geared towards creating new Workers AI projects. For help adding Workers AI to an existing Worker, refer to [Workers Bindings](https://developers.cloudflare.com/workers-ai/configuration/bindings/).

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/get-started/#page","headline":"Getting started","description":"Set up your first Workers AI project using the dashboard, CLI, or REST API.","url":"https://developers.cloudflare.com/workers-ai/get-started/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/get-started/og.png?v=7e846a5a03484ca2","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Create and deploy a Workers AI application using the Cloudflare dashboard.
title: Dashboard
image: https://developers.cloudflare.com/workers-ai/get-started/dashboard/og.png?v=eaaf4cda315f2202
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Dashboard

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/get-started/dashboard/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Follow this guide to create a Workers AI application using the Cloudflare dashboard.

## Prerequisites

Sign up for a [Cloudflare account ↗︎](https://dash.cloudflare.com/sign-up/workers-and-pages) if you have not already.

## Setup

To create a Workers AI application:

1. In the Cloudflare dashboard, go to the **Workers & Pages** page. [Go to **Workers & Pages** ↗](https://dash.cloudflare.com/?to=/:account/workers-and-pages)
2. Select **Create application**.
3. Under **Select a template**, select **LLM Chat App**.
4. Select **Deploy**.
5. Name your Worker, then select **Create and deploy**.
6. Preview your Worker at its provided [`workers.dev`](https://developers.cloudflare.com/workers/configuration/routing/workers-dev/) subdomain.

## Development

### Dashboard

Editing in the dashboard is helpful for simpler use cases.

Once you have created your Worker script, you can edit and deploy your Worker using the Cloudflare dashboard:

1. In the Cloudflare dashboard, go to the **Workers & Pages** page. [Go to **Workers & Pages** ↗](https://dash.cloudflare.com/?to=/:account/workers-and-pages)
2. Select your application.
3. Select **Edit Code**.

![Edit code directly within the Cloudflare dashboard](https://developers.cloudflare.com/cdn-cgi/image/onerror=redirect,width=566,height=386,format=webp/_astro/workers-edit-code.CKxxvQSe.png)

### Wrangler CLI

To develop more advanced applications or [implement tests](https://developers.cloudflare.com/workers/testing/), start working in the Wrangler CLI.

1. Install [`npm` ↗︎](https://docs.npmjs.com/getting-started).
2. Install [`Node.js` ↗︎](https://nodejs.org/en/).

Node.js version manager

Use [Vite+ (`vp env`) ↗︎](https://viteplus.dev/guide/env) to install and manage Node.js versions.

For supported Node.js versions, refer to the [Wrangler system requirements](https://developers.cloudflare.com/workers/wrangler/install-and-update/#install-wrangler).

3. Run the following command, replacing the value of `[<DIRECTORY>]` which the location you want to put your Worker Script.

npmyarnpnpm

```
npm create cloudflare@latest -- [<DIRECTORY>] --type=pre-existing
```

```
yarn create cloudflare [<DIRECTORY>] --type=pre-existing
```

```
pnpm create cloudflare@latest [<DIRECTORY>] --type=pre-existing
```

After you run this command - and work through the prompts - your local changes will not automatically sync with dashboard. So, once you download your script, continue using the CLI.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/get-started/dashboard/#page","headline":"Dashboard","description":"Create and deploy a Workers AI application using the Cloudflare dashboard.","url":"https://developers.cloudflare.com/workers-ai/get-started/dashboard/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/get-started/dashboard/og.png?v=eaaf4cda315f2202","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Use the Cloudflare Workers AI REST API to deploy a large language model (LLM).
title: REST API
image: https://developers.cloudflare.com/workers-ai/get-started/rest-api/og.png?v=5b1fb19ca805e26f
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# REST API

Last updated Sep 15, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/get-started/rest-api/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

This guide will instruct you through setting up and deploying your first Workers AI project. You will use the Workers AI REST API to experiment with a large language model (LLM).

## Prerequisites

Sign up for a [Cloudflare account ↗︎](https://dash.cloudflare.com/sign-up/workers-and-pages) if you have not already.

## 1. Get API token and Account ID

You need your API token and Account ID to use the REST API.

To get these values:

1. In the Cloudflare dashboard, go to the **Workers AI** page. [Go to **Workers AI** ↗](https://dash.cloudflare.com/?to=/:account/ai/workers-ai)
2. Select **Use REST API**.
3. Get your API token:
   1. Select **Create a Workers AI API Token**.
   2. Review the prefilled information.
   3. Select **Create API Token**.
   4. Select **Copy API Token**.
   5. Save that value for future use. This token will be visible [on your profile](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/).
4. For **Get Account ID**, copy the value for **Account ID**. Save that value for future use.

Note

If you choose to [create an API token](https://developers.cloudflare.com/fundamentals/api/get-started/create-token/) instead of using the template, that token will need permissions for both `Workers AI - Read` and `Workers AI - Edit`.

## 2. Run a model via API

After creating your API token, authenticate and make requests to the API using your API token in the request.

You will use the [Execute AI model](https://developers.cloudflare.com/api/resources/ai/methods/run/) endpoint to run the [`@cf/meta/llama-3.1-8b-instruct`](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct/) model:

```bash
curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta/llama-3.1-8b-instruct \
  -H 'Authorization: Bearer {API_TOKEN}' \
  -d '{ "prompt": "Where did the phrase Hello World come from" }'
```

Replace the values for `{ACCOUNT_ID}` and `{API_TOKEN}`.

The API response will look like the following:

```json
{
	"result": {
		"response": "Hello, World first appeared in 1974 at Bell Labs when Brian Kernighan included it in the C programming language example. It became widely used as a basic test program due to simplicity and clarity. It represents an inviting greeting from a program to the world."
	},
	"success": true,
	"errors": [],
	"messages": []
}
```

This example execution uses the `@cf/meta/llama-3.1-8b-instruct` model, but you can use any of the models in the [Workers AI models catalog](https://developers.cloudflare.com/workers-ai/models/). If using another model, you will need to replace `{model}` with your desired model name.

By completing this guide, you have created a Cloudflare account (if you did not have one already) and an API token that grants Workers AI read permissions to your account. You executed the [`@cf/meta/llama-3.1-8b-instruct`](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct/) model using a cURL command from the terminal and received an answer to your prompt in a JSON response.

## Related resources

- [Models](https://developers.cloudflare.com/workers-ai/models/) - Browse the Workers AI models catalog.
- [AI SDK](https://developers.cloudflare.com/workers-ai/configuration/ai-sdk) - Learn how to integrate with an AI model.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/get-started/rest-api/#page","headline":"REST API","description":"Use the Cloudflare Workers AI REST API to deploy a large language model (LLM).","url":"https://developers.cloudflare.com/workers-ai/get-started/rest-api/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/get-started/rest-api/og.png?v=5b1fb19ca805e26f","dateModified":"2026-09-15","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Deploy your first Cloudflare Workers AI project using the CLI.
title: Workers Bindings
image: https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/og.png?v=afa2e8cca2301ad1
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Workers Bindings

Last updated Aug 27, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

This guide will instruct you through setting up and deploying your first Workers AI project. You will use [Workers](https://developers.cloudflare.com/workers/), a Workers AI binding, and a large language model (LLM) to deploy your first AI-powered application on the Cloudflare global network.

1. Sign up for a [Cloudflare account ↗︎](https://dash.cloudflare.com/sign-up/workers-and-pages).
2. Install [`Node.js` ↗︎](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).

<details>

<summary>

Node.js version manager

</summary>

Use <a href="https://viteplus.dev/guide/env">Vite+ (<code>vp env</code>) ↗︎</a> to install and manage Node.js versions.

For supported Node.js versions, refer to the <a href="https://developers.cloudflare.com/workers/wrangler/install-and-update/#install-wrangler">Wrangler system requirements</a>.

</details>

## 1. Create a Worker project

You will create a new Worker project using the `create-cloudflare` CLI (C3). [C3 ↗︎](https://github.com/cloudflare/workers-sdk/tree/main/packages/create-cloudflare) is a command-line tool designed to help you set up and deploy new applications to Cloudflare.

Create a new project named `hello-ai` by running:

npmyarnpnpm

```
npm create cloudflare@latest -- hello-ai
```

```
yarn create cloudflare hello-ai
```

```
pnpm create cloudflare@latest hello-ai
```

Running `npm create cloudflare@latest` will prompt you to install the [`create-cloudflare` package ↗︎](https://www.npmjs.com/package/create-cloudflare), and lead you through setup. C3 will also install [Wrangler](https://developers.cloudflare.com/workers/wrangler/), the Cloudflare Developer Platform CLI.

For setup, select the following options:

- For *What would you like to start with?*, choose `Hello World example`.
- For *Which template would you like to use?*, choose `Worker only`.
- For *Which language do you want to use?*, choose `TypeScript`.
- For *Do you want to use git for version control?*, choose `Yes`.
- For *Do you want to add an AGENTS.md file to help AI coding tools understand Cloudflare APIs?*, choose `Yes`.
- For *Do you want to deploy your application?*, choose `No` (we will be making some changes before deploying).

This will create a new `hello-ai` directory. Your new `hello-ai` directory will include:

- A `"Hello World"` [Worker](https://developers.cloudflare.com/workers/get-started/guide/#3-write-code) at `src/index.ts`.
- A [`wrangler.jsonc`](https://developers.cloudflare.com/workers/wrangler/configuration/) configuration file.

Go to your application directory:

```sh
cd hello-ai
```

## 2. Connect your Worker to Workers AI

You must create an AI binding for your Worker to connect to Workers AI. [Bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/) allow your Workers to interact with resources, like Workers AI, on the Cloudflare Developer Platform.

To bind Workers AI to your Worker, add the following to the end of your Wrangler file:

```jsonc
{
	"ai": {
		"binding": "AI"
	}
}
```

```toml
[ai]
binding = "AI"
```

Your binding is [available in your Worker code](https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/#bindings-in-es-modules-format) on [`env.AI`](https://developers.cloudflare.com/workers/runtime-apis/handlers/fetch/).

You can also bind Workers AI to a Pages Function. For more information, refer to [Functions Bindings](https://developers.cloudflare.com/pages/functions/bindings/#workers-ai).

## 3. Run an inference task in your Worker

You are now ready to run an inference task in your Worker. In this case, you will use an LLM, [`gemma-4-26b-a4b-it`](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/), to answer a question.

Update the `index.ts` file in your `hello-ai` application directory with the following code:

*index.jsjs*

```js
export default {
	async fetch(request, env) {
		const response = await env.AI.run("@cf/google/gemma-4-26b-a4b-it", {
			messages: [
				{
					role: "system",
					content: "You are a helpful assistant.",
				},
				{
					role: "user",
					content: "What is the origin of the phrase Hello, World",
				},
			],
			chat_template_kwargs: {
				enable_thinking: false,
			},
		});

		return Response.json(response);
	},
};
```

*index.tsts*

```ts
export interface Env {
	// If you set another name in the Wrangler config file as the value for 'binding',
	// replace "AI" with the variable name you defined.
	AI: Ai;
}

export default {
	async fetch(request, env): Promise<Response> {
		const response = await env.AI.run("@cf/google/gemma-4-26b-a4b-it", {
			messages: [
				{
					role: "system",
					content: "You are a helpful assistant.",
				},
				{
					role: "user",
					content: "What is the origin of the phrase Hello, World",
				},
			],
			chat_template_kwargs: {
				enable_thinking: false,
			},
		});

		return Response.json(response);
	},
} satisfies ExportedHandler<Env>;
```

Up to this point, you have created an AI binding for your Worker and configured your Worker to execute the Gemma 4 26B A4B model with reasoning disabled. You can now test your project locally before you deploy globally.

## 4. Develop locally with Wrangler

While in your project directory, test Workers AI locally by running [`wrangler dev`](https://developers.cloudflare.com/workers/wrangler/commands/general/#dev):

```sh
npx wrangler dev
```

Workers AI local development usage charges

Using Workers AI always accesses your Cloudflare account in order to run AI models and will incur usage charges even in local development.

You will be prompted to log in after you run `wrangler dev`. When you run `npx wrangler dev`, Wrangler will give you a URL (most likely `localhost:8787`) to review your Worker. After you go to the URL Wrangler provides, the response will have a shape similar to the following example:

```json
{
	"id": "<generated id>",
	"object": "chat.completion",
	"created": 0,
	"model": "@cf/google/gemma-4-26b-a4b-it",
	"choices": [
		{
			"index": 0,
			"message": {
				"role": "assistant",
				"content": "<generated response>",
				"refusal": null
			},
			"finish_reason": "stop",
			"logprobs": null
		}
	]
}
```

## 5. Deploy your AI Worker

Before deploying your AI Worker globally, log in with your Cloudflare account by running:

```sh
npx wrangler login
```

You will be directed to a web page asking you to log in to the Cloudflare dashboard. After you have logged in, you will be asked if Wrangler can make changes to your Cloudflare account. Scroll down and select **Allow** to continue.

Finally, deploy your Worker to make your project accessible on the Internet. To deploy your Worker, run:

```sh
npx wrangler deploy
```

```sh
https://hello-ai.<YOUR_SUBDOMAIN>.workers.dev
```

Your Worker will be deployed to your custom [`workers.dev`](https://developers.cloudflare.com/workers/configuration/routing/workers-dev/) subdomain. You can now visit the URL to run your AI Worker.

By finishing this tutorial, you have created a Worker, connected it to Workers AI through an AI binding, and run an inference task using the Gemma 4 26B A4B model.

## Related resources

- [Cloudflare Developers community on Discord ↗︎](https://discord.cloudflare.com) - Submit feature requests, report bugs, and share your feedback directly with the Cloudflare team by joining the Cloudflare Discord server.
- [Models](https://developers.cloudflare.com/workers-ai/models/) - Browse the Workers AI models catalog.
- [AI SDK](https://developers.cloudflare.com/workers-ai/configuration/ai-sdk) - Learn how to integrate with an AI model.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/#page","headline":"Workers Bindings","description":"Deploy your first Cloudflare Workers AI project using the CLI.","url":"https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/og.png?v=afa2e8cca2301ad1","dateModified":"2026-08-27","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Understand how extraction models extract, compute, estimate, and forecast typed values, and how to interpret their results.
title: Extraction models
image: https://developers.cloudflare.com/workers-ai/concepts/extraction-models/og.png?v=ab83122be737302a
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Extraction models

Last updated Oct 19, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/concepts/extraction-models/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Extraction models turn information into specific values your application can use, such as an invoice total, a due date, or an estimated payment amount. They return typed values rather than choosing from a fixed set of options or producing open-ended content. This helps you connect AI predictions to application logic.

You provide an input state and define the values you want the model to return, including each value's type and any additional constraints. The model uses these definitions and the input state to produce a corresponding typed result for each value. Typed results provide a predictable structure but do not guarantee correctness.

## When to use extraction models

Use an extraction model when your application needs to extract, compute, estimate, or forecast a value, such as an amount, date, or duration. Alternatively, use a decision model to select from known options, or a generative model to produce open-ended content.

The following table compares these model types using invoice examples:

| Model type | Use when you need | Invoice example |
| --- | --- | --- |
| Extraction | Extract, compute, estimate, or forecast values, such as amounts, dates, durations, or text. | Read the total and due date from an invoice. |
| Decision | Select from a predefined set of options. | Determine if an invoice requires approval, manual review, or rejection. |
| Generative | Produce open-ended content. | Summarize discrepancies between the invoice, purchase order, and delivery receipt. |

Your application can use returned values in application logic or pass them as inputs to another model.

## How extraction models work

An extraction request combines an input state with a set of named field definitions. The input state supplies the information the model evaluates. Each field definition describes a value to return, specifies its type, and may include constraints. The model uses both to produce a corresponding result for each field.

For example, you provide invoice text that states a total of $1,080 and a due date of 2026-11-01. Separately, you define an invoice total field as a number in USD and a due date field as a date.

The model uses these definitions to identify the requested values in the invoice. It returns `1080` and `2026-11-01` as the corresponding typed results.

Your application can then use the returned values. For example, it can compare the due date with the current date to flag an overdue invoice.

## Extraction model capabilities

Extraction models support extraction, computation, estimation, and forecasting.

### Extraction

Return a value explicitly present in the input, such as the total printed on an invoice. Extraction identifies an existing value rather than calculating or estimating one.

### Computation

Derive a value from facts in the input. For example, calculate how many days an invoice is overdue using its due date and a current date you provide. Unlike extraction, the result does not need to appear explicitly in the input.

### Estimation

Predict a value that the input does not determine, such as when an unpaid invoice will be paid. Unlike computation, estimation addresses an unknown outcome rather than deriving a result from supplied facts.

### Forecasting

Predict a sequence of future values over an interval, such as an invoice's outstanding balance each week for the next month. Unlike a single estimate, a forecast returns a value for each step in the requested period.

## Interpret extraction results

Types and constraints define the form a result can take. They do not guarantee that it answers your question correctly.

### Missing results

For fields that extract or compute a single value, a `null` result indicates that the model considers the input insufficient to determine the answer. The information may be missing, or the model may have failed to identify it.

Lists return an empty list when the model finds no matching values. Estimates and forecasts return predictions even when the input provides little information.

### Uncertainty

The field type determines how uncertainty is represented and how it can be interpreted. Fields that extract and compute a single value include confidence scores for the returned answer. Estimates and forecasts include distributions over possible values.

For example, an estimated payment date might have a 10th percentile of November 5 and a 90th percentile of November 20. These dates mark the middle 80% of the predicted distribution. The actual payment date can still fall outside that interval.

### Constraints

Constraints restrict the values the model can return. They do not guarantee that the answer is correct.

For example, restricting an estimated payment date to November ensures that the returned date falls in November. The invoice could still be paid in December.

### Source spans

Extracted text includes a source span, which identifies its start and end positions in the input. You can use these positions to find the returned text in its original context.

## Design extraction tasks

### Define clear fields

Give each field a descriptive name and use its instructions to explain what value to return. For example, a field named `invoice_total` could have the instructions "Total amount due, including tax and shipping, after discounts." Specify its type and unit separately as a number in USD.

### Choose appropriate types and constraints

Set each field's type according to how your application uses the result. For example, use a date for a payment deadline and a duration for days overdue.

Use the available field settings to specify precision and value bounds. For example, request two decimal places for an invoice amount. When bounding an estimated payment date, choose a window that reflects plausible payment dates, not just your preferred deadline.

### Include task-relevant context

Include the information each task depends on in the input state. For example, calculating days overdue requires the invoice's due date and a current date you provide. State which date to use rather than assuming the model knows when the request runs.

### Match safeguards to risk

Choose safeguards based on the consequences of an incorrect result. Displaying an estimated payment date may require fewer checks than using an extracted amount to authorize a payment.

Decide how your application handles missing or uncertain results. Before consequential or irreversible actions, check results against other evidence or require human review.

## Limitations

- Typed output does not guarantee correctness. A result can satisfy its type and constraints while still answering the question incorrectly.
- Results depend on the available information and field definitions. Returning an estimate does not mean the input provides enough information to predict the outcome accurately.
- Uncertainty estimates are not guarantees. Confidence scores and prediction intervals do not replace application-level checks. An interval's actual coverage can vary across tasks and datasets.
- Capabilities vary by model. Consult the [Clairic model documentation](https://developers.cloudflare.com/workers-ai/models/clairic/) for supported inputs, field types, metadata, context window, and model-specific limitations.

## Next steps

- Review the [Clairic model reference](https://developers.cloudflare.com/workers-ai/models/clairic/) for supported inputs, field types, model-specific limits, request and response schemas, and invoice examples.
- Consult the [Workers AI REST API reference](https://developers.cloudflare.com/api/resources/ai/methods/run/) for the inference endpoint.
- [Configure a Workers AI binding](https://developers.cloudflare.com/workers-ai/configuration/bindings/) to access Workers AI from a Worker.
- [Use the Workers AI REST API](https://developers.cloudflare.com/workers-ai/get-started/rest-api/) to authenticate and send requests over HTTP.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/concepts/extraction-models/#page","headline":"Extraction models","description":"Understand how extraction models extract, compute, estimate, and forecast typed values, and how to interpret their results.","url":"https://developers.cloudflare.com/workers-ai/concepts/extraction-models/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/concepts/extraction-models/og.png?v=ab83122be737302a","dateModified":"2026-10-19","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Browse the catalog of machine learning models available on Workers AI.
title: Workers AI Models
image: https://developers.cloudflare.com/workers-ai/models/og.png?v=40351c4db9a31785
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Workers AI Models

Last updated Aug 12, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model not available

is deprecated, removed, or not found. Choose an available model from the catalog below.

Looking for more models, including external providers?

Check out the [unified AI model catalog](https://developers.cloudflare.com/ai/models/).

Task TypesCapabilitiesAuthorsNewest first

We found 73 modelsClear filters

## Compare models

Compare up to three models.

Close

Clear comparison

No models found

Try a different search term, or broaden your search by removing filters.

[s<h3>apertus-v1.5-8b</h3>swiss-aiText Generation Apertus 1.5 is an 8B parameter language model designed to advance the state of multilingual, multimodal, fully open, and transparent AI. The models support a wide range of languages, handle contexts of up to 262,144 tokens, and it uses only fully open training data whilst delivering performance comparable to other models of similar size. For access, please fill out this form: https://forms.gle/kgvmkr6ucHN3xNuH6](https://developers.cloudflare.com/workers-ai/models/apertus-v1.5-8b/)

- Cloudflare-hosted
- +3

Compare

[![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)<h3>aura-1</h3>DeepgramText-to-Speech Aura is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.](https://developers.cloudflare.com/workers-ai/models/aura-1/)

- Cloudflare-hosted
- +4

Compare

[![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)<h3>aura-2-en</h3>DeepgramText-to-Speech Aura-2 is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.](https://developers.cloudflare.com/workers-ai/models/aura-2-en/)

- Cloudflare-hosted
- +4

Compare

[![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)<h3>aura-2-es</h3>DeepgramText-to-Speech Aura-2 is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.](https://developers.cloudflare.com/workers-ai/models/aura-2-es/)

- Cloudflare-hosted
- +4

Compare

[![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)<h3>bge-base-en-v1.5</h3>BAAIText Embeddings BAAI general embedding (Base) model that transforms any given text into a 768-dimensional vector](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/)

- Cloudflare-hosted
- +2

Compare

[![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)<h3>bge-large-en-v1.5</h3>BAAIText Embeddings BAAI general embedding (Large) model that transforms any given text into a 1024-dimensional vector](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/)

- Cloudflare-hosted
- +2

Compare

[![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)<h3>bge-m3</h3>BAAIText Embeddings Multi-Functionality, Multi-Linguality, and Multi-Granularity embeddings model.](https://developers.cloudflare.com/workers-ai/models/bge-m3/)

- Cloudflare-hosted
- +1

Compare

[![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)<h3>bge-reranker-base</h3>BAAIText Classification Different from embedding model, reranker uses question and document as input and directly output similarity instead of embedding. You can get a relevance score by inputting query and passage to the reranker. And the score can be mapped to a float value in \[0,1\] by sigmoid function.](https://developers.cloudflare.com/workers-ai/models/bge-reranker-base/)

- Cloudflare-hosted
- +1

Compare

[![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)<h3>bge-small-en-v1.5</h3>BAAIText Embeddings BAAI general embedding (Small) model that transforms any given text into a 384-dimensional vector](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/)

- Cloudflare-hosted
- +2

Compare

[Pinned![Cloudflare logo](https://developers.cloudflare.com/_astro/cloudflare.DP8rkHys.svg)<h3>clairic</h3>CloudflareText Generation Clairic is a System One-style model that can extract, compute, estimate, and forecast values from inputs. It is strongly typed and outputs confidence scores and probabilities against its outputs. This model is in preview from the Cloudflare Workers AI team.](https://developers.cloudflare.com/workers-ai/models/clairic/)

- Cloudflare-hosted
- +2

Compare

[Pinned![Cloudflare logo](https://developers.cloudflare.com/_astro/cloudflare.DP8rkHys.svg)<h3>clef</h3>CloudflareText Generation Clef is a 27B multimodal decision model that turns a state and a schema of typed questions into decisions. It reads the state as text, JSON, images, or video, and returns a probability for every allowed option of every question.](https://developers.cloudflare.com/workers-ai/models/clef/)

- Cloudflare-hosted
- +2

Compare

[Pinned![Cloudflare logo](https://developers.cloudflare.com/_astro/cloudflare.DP8rkHys.svg)<h3>clef-flash</h3>CloudflareText Generation Clef-flash is a fast 9B multimodal decision model that turns a state and a schema of typed questions into decisions. It reads the state as text, JSON, images, or video, and returns a probability for every allowed option of every question.](https://developers.cloudflare.com/workers-ai/models/clef-flash/)

- Cloudflare-hosted
- +2

Compare

[Pinned![Cloudflare logo](https://developers.cloudflare.com/_astro/cloudflare.DP8rkHys.svg)<h3>clef-omni</h3>CloudflareText Generation Clef-omni is a multimodal decision model built on a 30B-parameter mixture-of-experts (3B active) backbone. It turns a state and a schema of typed questions into decisions, reads the state as text, JSON, images, audio, or video, and returns a probability for every allowed option of every question.](https://developers.cloudflare.com/workers-ai/models/clef-omni/)

- Cloudflare-hosted
- +2

Compare

[![DeepSeek logo](https://developers.cloudflare.com/_astro/deepseek.CkzAgvN6.svg)<h3>deepseek-r1-distill-qwen-32b</h3>DeepSeekText Generation DeepSeek-R1-Distill-Qwen-32B is a model distilled from DeepSeek-R1 based on Qwen2.5. It outperforms OpenAI-o1-mini across various benchmarks, achieving new state-of-the-art results for dense models.](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/)

- Cloudflare-hosted
- +3

Compare

[![DeepSeek logo](https://developers.cloudflare.com/_astro/deepseek.CkzAgvN6.svg)<h3>deepseek-v4-flash-0731</h3>DeepSeekText Generation DeepSeek-V4-Flash-0731 is the official release of DeepSeek-V4-Flash, superseding the preview version, with substantially enhanced agentic capabilities.](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/)

- Cloudflare-hosted
- +5

Compare

[![DeepSeek logo](https://developers.cloudflare.com/_astro/deepseek.CkzAgvN6.svg)<h3>deepseek-v4-pro-0813</h3>DeepSeekText Generation DeepSeek V4 Pro is a high-capability reasoning model from DeepSeek with a one million token context window, built for long-horizon agentic workflows and complex, multi-step problem-solving](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/)

- Cloudflare-hosted
- +4

Compare

[![DeepSeek logo](https://developers.cloudflare.com/_astro/deepseek.CkzAgvN6.svg)<h3>deepseek-v4.1-flash-1017</h3>DeepSeekText Generation We introduce DeepSeek-V4.1-Flash, a multimodal Mixture-of-Experts (MoE) model with 552B backbone parameters and support for contexts of up to one million tokens. The model natively processes images and text, and generates text autoregressively.](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/)

- Cloudflare-hosted
- +4

Compare

[![HuggingFace logo](https://developers.cloudflare.com/_astro/huggingface.DMS-v5TA.svg)<h3>distilbert-sst-2-int8</h3>HuggingFaceText Classification Distilled BERT model that was finetuned on SST-2 for sentiment classification](https://developers.cloudflare.com/workers-ai/models/distilbert-sst-2-int8/)

- Cloudflare-hosted
- +1

Compare

[l<h3>dreamshaper-8-lcm</h3>lykonText-to-Image Stable Diffusion model that has been fine-tuned to be better at photorealism without sacrificing range.](https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/)

- Cloudflare-hosted
- +2

Compare

[![Google logo](https://developers.cloudflare.com/_astro/google.DyXKPTPP.svg)<h3>embeddinggemma-300m</h3>BetaGoogleText Embeddings EmbeddingGemma is a 300M parameter, state-of-the-art for its size, open embedding model from Google, built from Gemma 3 (with T5Gemma initialization) and the same research and technology used to create Gemini models. EmbeddingGemma produces vector representations of text, making it well-suited for search and retrieval tasks, including classification, clustering, and semantic similarity search. This model was trained with data in 100+ spoken languages.](https://developers.cloudflare.com/workers-ai/models/embeddinggemma-300m/)

- Cloudflare-hosted
- +2

Compare

[u<h3>eurollm-9b-it</h3>utter-projectText Generation EuroLLM-9B is a 9B parameter model trained on 4 trillion tokens divided across the considered languages and several data sources: Web data, parallel data (en-xx and xx-en), and high-quality datasets. For access, please fill out this form: https://forms.gle/kgvmkr6ucHN3xNuH6](https://developers.cloudflare.com/workers-ai/models/eurollm-9b-it/)

- Cloudflare-hosted
- +2

Compare

[![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)<h3>flux</h3>DeepgramAutomatic Speech Recognition Flux is the first conversational speech recognition model built specifically for voice agents.](https://developers.cloudflare.com/workers-ai/models/flux/)

- Cloudflare-hosted
- +3

Compare

[![Black Forest Labs logo](https://developers.cloudflare.com/_astro/blackforestlabs.Ccs-Y4-D.svg)<h3>flux-1-schnell</h3>Black Forest LabsText-to-Image FLUX.1 \[schnell\] is a 12 billion parameter rectified flow transformer capable of generating images from text descriptions.](https://developers.cloudflare.com/workers-ai/models/flux-1-schnell/)

- Cloudflare-hosted
- +1

Compare

[![Black Forest Labs logo](https://developers.cloudflare.com/_astro/blackforestlabs.Ccs-Y4-D.svg)<h3>flux-2-dev</h3>Black Forest LabsText-to-Image FLUX.2 \[dev\] is an image model from Black Forest Labs where you can generate highly realistic and detailed images, with multi-reference support.](https://developers.cloudflare.com/workers-ai/models/flux-2-dev/)

- Cloudflare-hosted
- +2

Compare

[![Black Forest Labs logo](https://developers.cloudflare.com/_astro/blackforestlabs.Ccs-Y4-D.svg)<h3>flux-2-klein-4b</h3>Black Forest LabsText-to-Image FLUX.2 \[klein\] is an ultra-fast, distilled image model. It unifies image generation and editing in a single model, delivering state-of-the-art quality enabling interactive workflows, real-time previews, and latency-critical applications.](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-4b/)

- Cloudflare-hosted
- +2

Compare

[![Black Forest Labs logo](https://developers.cloudflare.com/_astro/blackforestlabs.Ccs-Y4-D.svg)<h3>flux-2-klein-9b</h3>Black Forest LabsText-to-Image FLUX.2 \[klein\] 9B is a 9 billion parameter model that can generate images from text descriptions and supports multi-reference editing capabilities.](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-9b/)

- Cloudflare-hosted
- +2

Compare

[![Google logo](https://developers.cloudflare.com/_astro/google.DyXKPTPP.svg)<h3>gemma-2b-it-lora</h3>BetaGoogleText Generation This is a Gemma-2B base model that Cloudflare dedicates for inference with LoRA adapters. Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models.](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/)

- Cloudflare-hosted
- +3

Compare

[![Google logo](https://developers.cloudflare.com/_astro/google.DyXKPTPP.svg)<h3>gemma-4-26b-a4b-it</h3>GoogleText Generation Gemma 4 is Google's most intelligent family of open models, built from Gemini 3 research to maximize intelligence-per-parameter.](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/)

- Cloudflare-hosted
- +5

Compare

[![Google logo](https://developers.cloudflare.com/_astro/google.DyXKPTPP.svg)<h3>gemma-7b-it-lora</h3>BetaGoogleText Generation This is a Gemma-7B base model that Cloudflare dedicates for inference with LoRA adapters. Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models.](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/)

- Cloudflare-hosted
- +3

Compare

[a<h3>gemma-sea-lion-v4-27b-it</h3>aisingaporeText Generation SEA-LION stands for Southeast Asian Languages In One Network, which is a collection of Large Language Models (LLMs) which have been pretrained and instruct-tuned for the Southeast Asia (SEA) region.](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/)

- Cloudflare-hosted
- +1

Compare

[![Zhipu AI logo](https://developers.cloudflare.com/_astro/zai-org.Dj2vcayE.svg)<h3>glm-4.7-flash</h3>Zhipu AIText Generation GLM-4.7-Flash is a fast and efficient multilingual text generation model with a 131,072 token context window. Optimized for dialogue, instruction-following, and multi-turn tool calling across 100+ languages.](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/)

- Cloudflare-hosted
- +3

Compare

[![Zhipu AI logo](https://developers.cloudflare.com/_astro/zai-org.Dj2vcayE.svg)<h3>glm-5.2</h3>Zhipu AIText Generation Z.ai's flagship agentic coding model](https://developers.cloudflare.com/workers-ai/models/glm-5.2/)

- Cloudflare-hosted
- +4

Compare

[![Zhipu AI logo](https://developers.cloudflare.com/_astro/zai-org.Dj2vcayE.svg)<h3>glm-5.3</h3>Zhipu AIText Generation GLM-5.3 is Z.ai's flagship agentic coding model, pairing a 1M-token context window with reasoning, function calling, and structured outputs to power multi-step, tool-driven development workflows.](https://developers.cloudflare.com/workers-ai/models/glm-5.3/)

- Cloudflare-hosted
- +3

Compare

[![Zhipu AI logo](https://developers.cloudflare.com/_astro/zai-org.Dj2vcayE.svg)<h3>glm-5.3-flash</h3>Zhipu AIText Generation The first natively multimodal model in the GLM-5 series. With 320B total parameters and just 18B active parameters, it outperforms GLM-5.2 across benchmarks and real-world workloads at one-tenth the price, while approaching Claude Opus 4.8 on coding and agentic benchmarks.](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/)

- Cloudflare-hosted
- +5

Compare

[![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)<h3>gpt-oss-120b</h3>OpenAIText Generation OpenAI’s open-weight models designed for powerful reasoning, agentic tasks, and versatile developer use cases – gpt-oss-120b is for production, general purpose, high reasoning use-cases.](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/)

- Cloudflare-hosted
- +4

Compare

[![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)<h3>gpt-oss-20b</h3>OpenAIText Generation OpenAI’s open-weight models designed for powerful reasoning, agentic tasks, and versatile developer use cases – gpt-oss-20b is for lower latency, and local or specialized use-cases.](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/)

- Cloudflare-hosted
- +4

Compare

[![IBM logo](https://developers.cloudflare.com/_astro/ibm.CYdLt4EI.svg)<h3>granite-4.0-h-micro</h3>IBMText Generation Granite 4.0 instruct models deliver strong performance across benchmarks, achieving industry-leading results in key agentic tasks like instruction following and function calling. These efficiencies make the models well-suited for a wide range of use cases like retrieval-augmented generation (RAG), multi-agent workflows, and edge deployments.](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/)

- Cloudflare-hosted
- +2

Compare

[a<h3>indictrans2-en-indic-1B</h3>ai4bharatTranslation IndicTrans2 is the first open-source transformer-based multilingual NMT model that supports high-quality translations across all the 22 scheduled Indic languages](https://developers.cloudflare.com/workers-ai/models/indictrans2-en-indic-1B/)

- Cloudflare-hosted
- +1

Compare

[![Moonshot AI logo](https://developers.cloudflare.com/_astro/moonshotai.DjWMkXUS.svg)<h3>kimi-k2.6</h3>Moonshot AIText Generation Kimi K2.6 is a frontier-scale open-source 1T parameter model with a 262.1k context window, multi-turn tool calling, vision inputs, and structured outputs for agentic workloads.](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/)

- Cloudflare-hosted
- +6

Compare

[![Moonshot AI logo](https://developers.cloudflare.com/_astro/moonshotai.DjWMkXUS.svg)<h3>kimi-k2.7-code</h3>Moonshot AIText Generation Kimi K2.7 is a frontier-scale open-source 1T parameter model with a 262.1k context window, multi-turn tool calling, vision inputs, and structured outputs for agentic workloads.](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/)

- Cloudflare-hosted
- +5

Compare

[![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)<h3>llama-2-7b-chat-hf-lora</h3>BetaMetaText Generation This is a Llama2 base model that Cloudflare dedicated for inference with LoRA adapters. Llama 2 is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 7B fine-tuned model, optimized for dialogue use cases and converted for the Hugging Face Transformers format.](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/)

- Cloudflare-hosted
- +3

Compare

[![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)<h3>llama-3.1-8b-instruct-fp8</h3>MetaText Generation Llama 3.1 8B quantized to FP8 precision](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/)

- Cloudflare-hosted
- +2

Compare

[![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)<h3>llama-3.2-11b-vision-instruct</h3>MetaText Generation The Llama 3.2-Vision instruction-tuned models are optimized for visual recognition, image reasoning, captioning, and answering general questions about an image.](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/)

- Cloudflare-hosted
- +3

Compare

[![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)<h3>llama-3.2-1b-instruct</h3>MetaText Generation The Llama 3.2 instruction-tuned text only models are optimized for multilingual dialogue use cases, including agentic retrieval and summarization tasks.](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/)

- Cloudflare-hosted
- +2

Compare

[![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)<h3>llama-3.2-3b-instruct</h3>MetaText Generation The Llama 3.2 instruction-tuned text only models are optimized for multilingual dialogue use cases, including agentic retrieval and summarization tasks.](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/)

- Cloudflare-hosted
- +3

Compare

[![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)<h3>llama-3.3-70b-instruct-fp8-fast</h3>MetaText Generation Llama 3.3 70B quantized to fp8 precision, optimized to be faster.](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/)

- Cloudflare-hosted
- +3

Compare

[![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)<h3>llama-4-scout-17b-16e-instruct</h3>MetaText Generation Meta's Llama 4 Scout is a 17 billion parameter model with 16 experts that is natively multimodal. These models leverage a mixture-of-experts architecture to offer industry-leading performance in text and image understanding.](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/)

- Cloudflare-hosted
- +4

Compare

[![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)<h3>llama-guard-3-8b</h3>MetaText Generation Llama Guard 3 is a Llama-3.1-8B pretrained model, fine-tuned for content safety classification. Similar to previous versions, it can be used to classify content in both LLM inputs (prompt classification) and in LLM responses (response classification). It acts as an LLM – it generates text in its output that indicates whether a given prompt or response is safe or unsafe, and if unsafe, it also lists the content categories violated.](https://developers.cloudflare.com/workers-ai/models/llama-guard-3-8b/)

- Cloudflare-hosted
- +2

Compare

[l<h3>llava-1.5-7b-hf</h3>Betallava-hfImage-to-Text LLaVA is an open-source chatbot trained by fine-tuning LLaMA/Vicuna on GPT-generated multimodal instruction-following data. It is an auto-regressive language model, based on the transformer architecture.](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/)

- Cloudflare-hosted
- +2

Compare

[![Leonardo logo](https://developers.cloudflare.com/_astro/leonardo.JZysY-g3.svg)<h3>lucid-origin</h3>LeonardoText-to-Image Lucid Origin from Leonardo.AI is their most adaptable and prompt-responsive model to date. Whether you're generating images with sharp graphic design, stunning full-HD renders, or highly specific creative direction, it adheres closely to your prompts, renders text with accuracy, and supports a wide array of visual styles and aesthetics – from stylized concept art to crisp product mockups.](https://developers.cloudflare.com/workers-ai/models/lucid-origin/)

- Cloudflare-hosted
- +2

Compare

[![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)<h3>m2m100-1.2b</h3>MetaTranslation Multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many multilingual translation](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/)

- Cloudflare-hosted
- +2

Compare

[![MyShell logo](https://developers.cloudflare.com/_astro/myshell.6ROagMV2.svg)<h3>melotts</h3>MyShellText-to-Speech MeloTTS is a high-quality multi-lingual text-to-speech library by MyShell.ai.](https://developers.cloudflare.com/workers-ai/models/melotts/)

- Cloudflare-hosted
- +2

Compare

[![MistralAI logo](https://developers.cloudflare.com/_astro/mistralai.Bn9UMUMu.svg)<h3>mistral-7b-instruct-v0.2-lora</h3>MistralAIText Generation The Mistral-7B-Instruct-v0.2 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.2.](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/)

- Cloudflare-hosted
- +2

Compare

[![MistralAI logo](https://developers.cloudflare.com/_astro/mistralai.Bn9UMUMu.svg)<h3>mistral-small-3.1-24b-instruct</h3>MistralAIText Generation Building upon Mistral Small 3 (2501), Mistral Small 3.1 (2503) adds state-of-the-art vision understanding and enhances long context capabilities up to 128k tokens without compromising text performance. With 24 billion parameters, this model achieves top-tier capabilities in both text and vision tasks.](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/)

- Cloudflare-hosted
- +2

Compare

[m<h3>moondream3.1-9B-A2B</h3>moondreamImage-to-Text Moondream 3 is a fast, efficient 9B mixture-of-experts vision language model (2B active parameters) that delivers frontier-level visual reasoning for tasks like object detection, pointing, OCR, and structured output.](https://developers.cloudflare.com/workers-ai/models/moondream3.1-9B-A2B/)

- Cloudflare-hosted
- +2

Compare

[![NVIDIA logo](https://developers.cloudflare.com/_astro/nvidia.DI1bb8hH.svg)<h3>nemotron-3-120b-a12b</h3>NVIDIAText Generation NVIDIA Nemotron 3 Super is a hybrid MoE model with leading accuracy for multi-agent applications and specialized agentic AI systems.](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/)

- Cloudflare-hosted
- +4

Compare

[![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)<h3>nova-3</h3>DeepgramAutomatic Speech Recognition Transcribe audio using Deepgram’s speech-to-text model](https://developers.cloudflare.com/workers-ai/models/nova-3/)

- Cloudflare-hosted
- +4

Compare

[![Leonardo logo](https://developers.cloudflare.com/_astro/leonardo.JZysY-g3.svg)<h3>phoenix-1.0</h3>LeonardoText-to-Image Phoenix 1.0 is a model by Leonardo.Ai that generates images with exceptional prompt adherence and coherent text.](https://developers.cloudflare.com/workers-ai/models/phoenix-1.0/)

- Cloudflare-hosted
- +2

Compare

[d<h3>phonellm-mini-alpha-2</h3>daily-coText Generation PhoneLLM is an open model tuned for voice agents. The model is based on Nemotron Nano 30B base capabilities and excels at typical voice agent tasks with thinking disabled.](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/)

- Cloudflare-hosted
- +2

Compare

[p<h3>plamo-embedding-1b</h3>pfnetText Embeddings PLaMo-Embedding-1B is a Japanese text embedding model developed by Preferred Networks, Inc. It can convert Japanese text input into numerical vectors and can be used for a wide range of applications, including information retrieval, text classification, and clustering.](https://developers.cloudflare.com/workers-ai/models/plamo-embedding-1b/)

- Cloudflare-hosted
- +1

Compare

[![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)<h3>qwen2.5-coder-32b-instruct</h3>QwenText Generation Qwen2.5-Coder is the latest series of Code-Specific Qwen large language models (formerly known as CodeQwen). As of now, Qwen2.5-Coder has covered six mainstream model sizes, 0.5, 1.5, 3, 7, 14, 32 billion parameters, to meet the needs of different developers. Qwen2.5-Coder brings the following improvements upon CodeQwen1.5:](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/)

- Cloudflare-hosted
- +2

Compare

[![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)<h3>qwen3-30b-a3b-fp8</h3>QwenText Generation Qwen3 is the latest generation of large language models in Qwen series, offering a comprehensive suite of dense and mixture-of-experts (MoE) models. Built upon extensive training, Qwen3 delivers groundbreaking advancements in reasoning, instruction-following, agent capabilities, and multilingual support.](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/)

- Cloudflare-hosted
- +5

Compare

[![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)<h3>qwen3-embedding-0.6b</h3>QwenText Embeddings The Qwen3 Embedding model series is the latest proprietary model of the Qwen family, specifically designed for text embedding and ranking tasks.](https://developers.cloudflare.com/workers-ai/models/qwen3-embedding-0.6b/)

- Cloudflare-hosted
- +1

Compare

[![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)<h3>qwen3.8-27b</h3>QwenText Generation Qwen 3.8 27B is a 27-billion-parameter instruction-tuned language model from Alibaba's Qwen family, designed for vision, efficient general-purpose text generation and agentic workloads.](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/)

- Cloudflare-hosted
- +5

Compare

[![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)<h3>qwq-32b</h3>QwenText Generation QwQ is the reasoning model of the Qwen series. Compared with conventional instruction-tuned models, QwQ, which is capable of thinking and reasoning, can achieve significantly enhanced performance in downstream tasks, especially hard problems. QwQ-32B is the medium-sized reasoning model, which is capable of achieving competitive performance against state-of-the-art reasoning models, e.g., DeepSeek-R1, o1-mini.](https://developers.cloudflare.com/workers-ai/models/qwq-32b/)

- Cloudflare-hosted
- +4

Compare

[![Microsoft logo](https://developers.cloudflare.com/_astro/microsoft.LujcDJ--.svg)<h3>resnet-50</h3>MicrosoftImage Classification 50 layers deep image classification CNN trained on more than 1M images from ImageNet](https://developers.cloudflare.com/workers-ai/models/resnet-50/)

- Cloudflare-hosted
- +1

Compare

[![Pipecat logo](https://developers.cloudflare.com/_astro/pipecat.B-PNBdef.svg)<h3>smart-turn-v2</h3>PipecatDumb Pipe An open source, community-driven, native audio turn detection model in 2nd version](https://developers.cloudflare.com/workers-ai/models/smart-turn-v2/)

- Cloudflare-hosted
- +3

Compare

[![RunwayML logo](https://developers.cloudflare.com/_astro/runway.Cq8Cjov4.svg)<h3>stable-diffusion-v1-5-inpainting</h3>BetaRunwayMLText-to-Image Stable Diffusion Inpainting is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input, with the extra capability of inpainting the pictures by using a mask.](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-inpainting/)

- Cloudflare-hosted
- +2

Compare

[![Stability.ai logo](https://developers.cloudflare.com/_astro/stabilityai.VsBx3CKv.svg)<h3>stable-diffusion-xl-base-1.0</h3>BetaStability.aiText-to-Image Diffusion-based text-to-image generative model by Stability AI. Generates and modify images based on text prompts.](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-base-1.0/)

- Cloudflare-hosted
- +2

Compare

[![ByteDance logo](https://developers.cloudflare.com/_astro/bytedance.T1uiROQ6.svg)<h3>stable-diffusion-xl-lightning</h3>BetaByteDanceText-to-Image SDXL-Lightning is a lightning-fast text-to-image generation model. It can generate high-quality 1024px images in a few steps.](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/)

- Cloudflare-hosted
- +2

Compare

[![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)<h3>whisper</h3>OpenAIAutomatic Speech Recognition Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse audio and is also a multitasking model that can perform multilingual speech recognition, speech translation, and language identification.](https://developers.cloudflare.com/workers-ai/models/whisper/)

- Cloudflare-hosted
- +1

Compare

[![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)<h3>whisper-large-v3-turbo</h3>OpenAIAutomatic Speech Recognition Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation.](https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/)

- Cloudflare-hosted
- +2

Compare

[![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)<h3>whisper-tiny-en</h3>BetaOpenAIAutomatic Speech Recognition Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation. Trained on 680k hours of labelled data, Whisper models demonstrate a strong ability to generalize to many datasets and domains without the need for fine-tuning. This is the English-only version of the Whisper Tiny model which was trained on the task of speech recognition.](https://developers.cloudflare.com/workers-ai/models/whisper-tiny-en/)

- Cloudflare-hosted
- +2

Compare

Compare models

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/models/#page","headline":"Workers AI Models","description":"Browse the catalog of machine learning models available on Workers AI.","url":"https://developers.cloudflare.com/workers-ai/models/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/models/og.png?v=40351c4db9a31785","dateModified":"2026-08-12","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: IndicTrans2 is the first open-source transformer-based multilingual NMT model that supports high-quality translations across all the 22 scheduled Indic languages
title: indictrans2-en-indic-1B
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

a

# indictrans2-en-indic-1B

Translation • ai4bharat

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/indictrans2-en-indic-1B/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/ai4bharat/indictrans2-en-indic-1B` Copy

- Cloudflare-hosted
- Zero data retention

IndicTrans2 is the first open-source transformer-based multilingual NMT model that supports high-quality translations across all the 22 scheduled Indic languages

| Model Info | |
| --- | --- |
| Zero data retention | Yes |
| Unit Pricing | $0.342 per M input tokens, $0.342 per M output tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const response = await env.AI.run(
      "@cf/ai4bharat/indictrans2-en-indic-1B",
      {
        text: "Hello, how are you?",
        target_language: "hin_Deva",
      }
    );

    return new Response(JSON.stringify(response));
  },
} satisfies ExportedHandler<Env>;
```

```py
import requests

API_BASE_URL = "https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/"
headers = {"Authorization": "Bearer {API_TOKEN}"}

def run(model, input):
    response = requests.post(f"{API_BASE_URL}{model}", headers=headers, json=input)
    return response.json()

output = run('@cf/ai4bharat/indictrans2-en-indic-1B', {
  "text": "Hello, how are you?",
  "target_language": "hin_Deva"
})

print(output)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/ai4bharat/indictrans2-en-indic-1B  \
    -X POST  \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
    -d '{ "text": "Hello, how are you?", "target_language": "hin_Deva" }'
```

## Parameters

▶text

`one of`required

target\_language

`string`requireddefault: hin\_Devaenum: asm\_Beng, awa\_Deva, ben\_Beng, bho\_Deva, brx\_Deva, doi\_Deva, eng\_Latn, gom\_Deva, gon\_Deva, guj\_Gujr, hin\_Deva, hne\_Deva, kan\_Knda, kas\_Arab, kas\_Deva, kha\_Latn, lus\_Latn, mag\_Deva, mai\_Deva, mal\_Mlym, mar\_Deva, mni\_Beng, mni\_Mtei, npi\_Deva, ory\_Orya, pan\_Guru, san\_Deva, sat\_Olck, snd\_Arab, snd\_Deva, tam\_Taml, tel\_Telu, urd\_Arab, unr\_DevaTarget langauge to translate to

▶translations\[]

`array`Translated texts

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/indictrans2-en-indic-1B/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/indictrans2-en-indic-1B/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/indictrans2-en-indic-1B/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/indictrans2-en-indic-1B/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/indictrans2-en-indic-1B/#page","headline":"indictrans2-en-indic-1B","description":"IndicTrans2 is the first open-source transformer-based multilingual NMT model that supports high-quality translations across all the 22 scheduled Indic languages","url":"https://developers.cloudflare.com/workers-ai/models/indictrans2-en-indic-1B/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: SEA-LION stands for Southeast Asian Languages In One Network, which is a collection of Large Language Models (LLMs) which have been pretrained and instruct-tuned for the Southeast Asia (SEA) region.
title: gemma-sea-lion-v4-27b-it
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

a

# gemma-sea-lion-v4-27b-it

Text Generation • aisingapore

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/aisingapore/gemma-sea-lion-v4-27b-it` Copy

- Cloudflare-hosted
- Zero data retention

SEA-LION stands for Southeast Asian Languages In One Network, which is a collection of Large Language Models (LLMs) which have been pretrained and instruct-tuned for the Southeast Asia (SEA) region.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 128,000 tokens |
| Zero data retention | Yes |
| Unit Pricing | $0.351 per M input tokens, $0.555 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/aisingapore/gemma-sea-lion-v4-27b-it)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/aisingapore/gemma-sea-lion-v4-27b-it", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/aisingapore/gemma-sea-lion-v4-27b-it", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/aisingapore/gemma-sea-lion-v4-27b-it",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/aisingapore/gemma-sea-lion-v4-27b-it \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 2000The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

id

<code>string</code>Unique identifier for the completion

object

<code>string</code>enum: chat.completionObject type identifier

created

<code>number</code>Unix timestamp of when the completion was created

model

<code>string</code>Model used for the completion

▶choices\[]

<code>array</code>List of completion choices

▶usage{}

<code>object</code>Usage statistics for the inference request

prompt\_logprobs{}

<code>object</code>Log probabilities for the prompt (if requested)

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 2000The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>required

id

<code>string</code>Unique identifier for the completion

object

<code>string</code>enum: chat.completionObject type identifier

created

<code>number</code>Unix timestamp of when the completion was created

model

<code>string</code>Model used for the completion

▶choices\[]

<code>array</code>List of completion choices

▶usage{}

<code>object</code>Usage statistics for the inference request

prompt\_logprobs{}

<code>object</code>Log probabilities for the prompt (if requested)

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/#page","headline":"gemma-sea-lion-v4-27b-it","description":"SEA-LION stands for Southeast Asian Languages In One Network, which is a collection of Large Language Models (LLMs) which have been pretrained and instruct-tuned for the Southeast Asia (SEA) region.","url":"https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: BAAI general embedding (Base) model that transforms any given text into a 768-dimensional vector
title: bge-base-en-v1.5
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)

# bge-base-en-v1.5

Text Embeddings • BAAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/baai/bge-base-en-v1.5` Copy

- Cloudflare-hosted
- Batch
- Zero data retention

BAAI general embedding (Base) model that transforms any given text into a 768-dimensional vector

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 153,600 tokens |
| More information | [link ↗](https://huggingface.co/BAAI/bge-base-en-v1.5) |
| Maximum Input Tokens | 512 |
| Output Dimensions | 768 |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.0666 per M input tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    // Can be a string or array of strings]
    const stories = [
      "This is a story about an orange cloud",
      "This is a story about a llama",
      "This is a story about a hugging emoji",
    ];

    const embeddings = await env.AI.run(
      "@cf/baai/bge-base-en-v1.5",
      {
        text: stories,
      }
    );

    return Response.json(embeddings);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests


ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

stories = [
  'This is a story about an orange cloud',
  'This is a story about a llama',
  'This is a story about a hugging emoji'
]

response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/baai/bge-base-en-v1.5",
  headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
  json={"text": stories}
)

print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/baai/bge-base-en-v1.5  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "text": ["This is a story about an orange cloud", "This is a story about a llama", "This is a story about a hugging emoji"] }'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/).

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



▶text

<code>one of</code>required

pooling

<code>string</code>default: meanenum: mean, clsThe pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.

▶shape\[]

<code>array</code>

▶data\[]

<code>array</code>Embeddings of the requested text values

pooling

<code>string</code>enum: mean, clsThe pooling method used in the embedding process.

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>requiredBatch of the embeddings requests to run using async-queue

▶shape\[]

<code>array</code>

▶data\[]

<code>array</code>Embeddings of the requested text values

pooling

<code>string</code>enum: mean, clsThe pooling method used in the embedding process.

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/sync-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/#page","headline":"bge-base-en-v1.5","description":"BAAI general embedding (Base) model that transforms any given text into a 768-dimensional vector","url":"https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: BAAI general embedding (Large) model that transforms any given text into a 1024-dimensional vector
title: bge-large-en-v1.5
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)

# bge-large-en-v1.5

Text Embeddings • BAAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/baai/bge-large-en-v1.5` Copy

- Cloudflare-hosted
- Batch
- Zero data retention

BAAI general embedding (Large) model that transforms any given text into a 1024-dimensional vector

| Model Info | |
| --- | --- |
| More information | [link ↗](https://huggingface.co/BAAI/bge-large-en-v1.5) |
| Maximum Input Tokens | 512 |
| Output Dimensions | 1,024 |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.204 per M input tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    // Can be a string or array of strings]
    const stories = [
      "This is a story about an orange cloud",
      "This is a story about a llama",
      "This is a story about a hugging emoji",
    ];

    const embeddings = await env.AI.run(
      "@cf/baai/bge-large-en-v1.5",
      {
        text: stories,
      }
    );

    return Response.json(embeddings);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests


ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

stories = [
  'This is a story about an orange cloud',
  'This is a story about a llama',
  'This is a story about a hugging emoji'
]

response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/baai/bge-large-en-v1.5",
  headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
  json={"text": stories}
)

print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/baai/bge-large-en-v1.5  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "text": ["This is a story about an orange cloud", "This is a story about a llama", "This is a story about a hugging emoji"] }'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/).

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



▶text

<code>one of</code>required

pooling

<code>string</code>default: meanenum: mean, clsThe pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.

▶shape\[]

<code>array</code>

▶data\[]

<code>array</code>Embeddings of the requested text values

pooling

<code>string</code>enum: mean, clsThe pooling method used in the embedding process.

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>requiredBatch of the embeddings requests to run using async-queue

▶shape\[]

<code>array</code>

▶data\[]

<code>array</code>Embeddings of the requested text values

pooling

<code>string</code>enum: mean, clsThe pooling method used in the embedding process.

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/sync-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/#page","headline":"bge-large-en-v1.5","description":"BAAI general embedding (Large) model that transforms any given text into a 1024-dimensional vector","url":"https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Multi-Functionality, Multi-Linguality, and Multi-Granularity embeddings model.
title: bge-m3
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)

# bge-m3

Text Embeddings • BAAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/bge-m3/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/baai/bge-m3` Copy

- Cloudflare-hosted
- Zero data retention

Multi-Functionality, Multi-Linguality, and Multi-Granularity embeddings model.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 60,000 tokens |
| Zero data retention | Yes |
| Unit Pricing | $0.0118 per M input tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    // Can be a string or array of strings]
    const stories = [
      "This is a story about an orange cloud",
      "This is a story about a llama",
      "This is a story about a hugging emoji",
    ];

    const embeddings = await env.AI.run(
      "@cf/baai/bge-m3",
      {
        text: stories,
      }
    );

    return Response.json(embeddings);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests


ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

stories = [
  'This is a story about an orange cloud',
  'This is a story about a llama',
  'This is a story about a hugging emoji'
]

response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/baai/bge-m3",
  headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
  json={"text": stories}
)

print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/baai/bge-m3  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "text": ["This is a story about an orange cloud", "This is a story about a llama", "This is a story about a hugging emoji"] }'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/).

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



query

<code>string</code>minLength: 1A query you wish to perform against the provided contexts. If no query is provided the model with respond with embeddings for contexts

▶contexts\[]

<code>array</code>requiredList of provided contexts. Note that the index in this array is important, as the response will refer to it.

truncate\_inputs

<code>boolean</code>default: falseWhen provided with too long context should the model error out or truncate the context to fit?

request\_id

<code>string</code>The async request id that can be used to obtain the results.

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>requiredBatch of the embeddings requests to run using async-queue

request\_id

<code>string</code>The async request id that can be used to obtain the results.

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/bge-m3/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-m3/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/bge-m3/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-m3/sync-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/bge-m3/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-m3/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/bge-m3/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-m3/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/bge-m3/#page","headline":"bge-m3","description":"Multi-Functionality, Multi-Linguality, and Multi-Granularity embeddings model.","url":"https://developers.cloudflare.com/workers-ai/models/bge-m3/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "Different from embedding model, reranker uses question and document as input and directly output similarity instead of embedding. You can get a relevance score by inputting query and passage to the reranker. And the score can be mapped to a float value in [0,1] by sigmoid function.\n\n"
title: bge-reranker-base
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)

# bge-reranker-base

Text Classification • BAAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/bge-reranker-base/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/baai/bge-reranker-base` Copy

- Cloudflare-hosted
- Zero data retention

Different from embedding model, reranker uses question and document as input and directly output similarity instead of embedding. You can get a relevance score by inputting query and passage to the reranker. And the score can be mapped to a float value in \[0,1] by sigmoid function.

| Model Info | |
| --- | --- |
| Zero data retention | Yes |
| Unit Pricing | $0.00311 per M input tokens |

## Usage

```ts
export interface Env {
	AI: Ai;
}

export default {
	async fetch(request, env): Promise<Response> {
		const query = 'Which one is cooler?'
		const contexts = [
			{
				text: 'a cyberpunk lizzard'
			},
			{
				text: 'a cyberpunk cat'
			}
		];

		const response = await env.AI.run('@cf/baai/bge-reranker-base', { query, contexts });

		return Response.json(response);
	},
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/baai/bge-reranker-base",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
	  "query": "Which one is better?",
      "contexts": [
        {"text": "a cyberpunk lizzard"},
		    {"text": "a cyberpunk car"},
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/baai/bge-reranker-base \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "query": "Which one is better?", "contexts": [{ "text": "a cyberpunk lizzard" }, {"text": "a cyberpunk cat"}]}'
```

## Parameters

query

`string`requiredminLength: 1A query you wish to perform against the provided contexts.

top\_k

`integer`minimum: 1Number of returned results starting with the best score.

▶contexts\[]

`array`requiredList of provided contexts. Note that the index in this array is important, as the response will refer to it.

▶response\[]

`array`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/bge-reranker-base/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-reranker-base/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/bge-reranker-base/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-reranker-base/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/bge-reranker-base/#page","headline":"bge-reranker-base","description":"Different from embedding model, reranker uses question and document as input and directly output similarity instead of embedding. You can get a relevance score by inputting query and passage to the reranker. And the score can be mapped to a float value in [0,1] by sigmoid function.","url":"https://developers.cloudflare.com/workers-ai/models/bge-reranker-base/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: BAAI general embedding (Small) model that transforms any given text into a 384-dimensional vector
title: bge-small-en-v1.5
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![BAAI logo](https://developers.cloudflare.com/_astro/baai.BooZR_xF.svg)

# bge-small-en-v1.5

Text Embeddings • BAAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/baai/bge-small-en-v1.5` Copy

- Cloudflare-hosted
- Batch
- Zero data retention

BAAI general embedding (Small) model that transforms any given text into a 384-dimensional vector

| Model Info | |
| --- | --- |
| More information | [link ↗](https://huggingface.co/BAAI/bge-small-en-v1.5) |
| Maximum Input Tokens | 512 |
| Output Dimensions | 384 |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.0202 per M input tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    // Can be a string or array of strings]
    const stories = [
      "This is a story about an orange cloud",
      "This is a story about a llama",
      "This is a story about a hugging emoji",
    ];

    const embeddings = await env.AI.run(
      "@cf/baai/bge-small-en-v1.5",
      {
        text: stories,
      }
    );

    return Response.json(embeddings);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests


ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

stories = [
  'This is a story about an orange cloud',
  'This is a story about a llama',
  'This is a story about a hugging emoji'
]

response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/baai/bge-small-en-v1.5",
  headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
  json={"text": stories}
)

print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/baai/bge-small-en-v1.5  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "text": ["This is a story about an orange cloud", "This is a story about a llama", "This is a story about a hugging emoji"] }'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/).

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



▶text

<code>one of</code>required

pooling

<code>string</code>default: meanenum: mean, clsThe pooling method used in the embedding process. `cls` pooling will generate more accurate embeddings on larger inputs - however, embeddings created with cls pooling are not compatible with embeddings generated with mean pooling. The default pooling method is `mean` in order for this to not be a breaking change, but we highly suggest using the new `cls` pooling for better accuracy.

▶shape\[]

<code>array</code>

▶data\[]

<code>array</code>Embeddings of the requested text values

pooling

<code>string</code>enum: mean, clsThe pooling method used in the embedding process.

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>requiredBatch of the embeddings requests to run using async-queue

▶shape\[]

<code>array</code>

▶data\[]

<code>array</code>Embeddings of the requested text values

pooling

<code>string</code>enum: mean, clsThe pooling method used in the embedding process.

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/sync-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/#page","headline":"bge-small-en-v1.5","description":"BAAI general embedding (Small) model that transforms any given text into a 384-dimensional vector","url":"https://developers.cloudflare.com/workers-ai/models/bge-small-en-v1.5/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "FLUX.1 [schnell] is a 12 billion parameter rectified flow transformer capable of generating images from text descriptions. "
title: flux-1-schnell
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Black Forest Labs logo](https://developers.cloudflare.com/_astro/blackforestlabs.Ccs-Y4-D.svg)

# flux-1-schnell

Text-to-Image • Black Forest Labs

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/flux-1-schnell/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/black-forest-labs/flux-1-schnell` Copy

- Cloudflare-hosted
- Zero data retention

FLUX.1 \[schnell] is a 12 billion parameter rectified flow transformer capable of generating images from text descriptions.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://bfl.ai/legal/terms-of-service) |
| Zero data retention | Yes |

## Usage

```ts
export interface Env {
	AI: Ai;
}

export default {
	async fetch(request, env): Promise<Response> {
		const response = await env.AI.run('@cf/black-forest-labs/flux-1-schnell', {
			prompt: 'a cyberpunk lizard',
			seed: Math.floor(Math.random() * 10)
		});
		// response.image is base64 encoded which can be used directly as an <img src=""> data URI
		const dataURI = `data:image/jpeg;charset=utf-8;base64,${response.image}`;
		return Response.json({ dataURI });
	},
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
	AI: Ai;
}

export default {
	async fetch(request, env): Promise<Response> {
		const response = await env.AI.run('@cf/black-forest-labs/flux-1-schnell', {
			prompt: 'a cyberpunk lizard',
			seed: Math.floor(Math.random() * 10)
		});
		// Convert from base64 string
		const binaryString = atob(response.image);
		// Create byte representation
		const img = Uint8Array.from(binaryString, (m) => m.codePointAt(0));
		return new Response(img, {
			headers: {
				'Content-Type': 'image/jpeg',
			},
		});
	},
} satisfies ExportedHandler<Env>;
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/black-forest-labs/flux-1-schnell  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "prompt": "cyberpunk cat", "seed": "Random positive integer" }'
```

## Parameters

prompt

`string`requiredminLength: 1maxLength: 2048A text description of the image you want to generate.

steps

`integer`maximum: 8The number of diffusion steps; higher values can improve quality but take longer. Default is 4

image

`string`The generated image in Base64 format.

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/flux-1-schnell/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux-1-schnell/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/flux-1-schnell/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux-1-schnell/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/flux-1-schnell/#page","headline":"flux-1-schnell","description":"FLUX.1 [schnell] is a 12 billion parameter rectified flow transformer capable of generating images from text descriptions.","url":"https://developers.cloudflare.com/workers-ai/models/flux-1-schnell/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: FLUX.2 [dev] is an image model from Black Forest Labs where you can generate highly realistic and detailed images, with multi-reference support.
title: flux-2-dev
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Black Forest Labs logo](https://developers.cloudflare.com/_astro/blackforestlabs.Ccs-Y4-D.svg)

# flux-2-dev

Text-to-Image • Black Forest Labs

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/flux-2-dev/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/black-forest-labs/flux-2-dev` Copy

- Cloudflare-hosted
- Partner
- Zero data retention

FLUX.2 \[dev] is an image model from Black Forest Labs where you can generate highly realistic and detailed images, with multi-reference support.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://bfl.ai/legal/terms-of-service) |
| Zero data retention | Yes |
| Partner | Yes |

## Parameters

▶multipart{}

`object`required

image

`string`Generated image as Base64 string.

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/flux-2-dev/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux-2-dev/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/flux-2-dev/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux-2-dev/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/flux-2-dev/#page","headline":"flux-2-dev","description":"FLUX.2 [dev] is an image model from Black Forest Labs where you can generate highly realistic and detailed images, with multi-reference support.","url":"https://developers.cloudflare.com/workers-ai/models/flux-2-dev/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: FLUX.2 [klein] is an ultra-fast, distilled image model. It unifies image generation and editing in a single model, delivering state-of-the-art quality enabling interactive workflows, real-time previews, and latency-critical applications.
title: flux-2-klein-4b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Black Forest Labs logo](https://developers.cloudflare.com/_astro/blackforestlabs.Ccs-Y4-D.svg)

# flux-2-klein-4b

Text-to-Image • Black Forest Labs

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-4b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/black-forest-labs/flux-2-klein-4b` Copy

- Cloudflare-hosted
- Partner
- Zero data retention

FLUX.2 \[klein] is an ultra-fast, distilled image model. It unifies image generation and editing in a single model, delivering state-of-the-art quality enabling interactive workflows, real-time previews, and latency-critical applications.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://bfl.ai/legal/terms-of-service) |
| Zero data retention | Yes |
| Partner | Yes |

## Parameters

▶multipart{}

`object`required

image

`string`Generated image as Base64 string.

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-4b/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-4b/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-4b/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-4b/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/flux-2-klein-4b/#page","headline":"flux-2-klein-4b","description":"FLUX.2 [klein] is an ultra-fast, distilled image model. It unifies image generation and editing in a single model, delivering state-of-the-art quality enabling interactive workflows, real-time previews, and latency-critical applications.","url":"https://developers.cloudflare.com/workers-ai/models/flux-2-klein-4b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: FLUX.2 [klein] 9B is a 9 billion parameter model that can generate images from text descriptions and supports multi-reference editing capabilities.
title: flux-2-klein-9b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Black Forest Labs logo](https://developers.cloudflare.com/_astro/blackforestlabs.Ccs-Y4-D.svg)

# flux-2-klein-9b

Text-to-Image • Black Forest Labs

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-9b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/black-forest-labs/flux-2-klein-9b` Copy

- Cloudflare-hosted
- Partner
- Zero data retention

FLUX.2 \[klein] 9B is a 9 billion parameter model that can generate images from text descriptions and supports multi-reference editing capabilities.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://bfl.ai/legal/terms-of-service) |
| Zero data retention | Yes |
| Partner | Yes |

## Parameters

▶multipart{}

`object`required

image

`string`Generated image as Base64 string.

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-9b/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-9b/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-9b/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-9b/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/flux-2-klein-9b/#page","headline":"flux-2-klein-9b","description":"FLUX.2 [klein] 9B is a 9 billion parameter model that can generate images from text descriptions and supports multi-reference editing capabilities.","url":"https://developers.cloudflare.com/workers-ai/models/flux-2-klein-9b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: SDXL-Lightning is a lightning-fast text-to-image generation model. It can generate high-quality 1024px images in a few steps.
title: stable-diffusion-xl-lightning
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![ByteDance logo](https://developers.cloudflare.com/_astro/bytedance.T1uiROQ6.svg)

# stable-diffusion-xl-lightning

Beta

Text-to-Image • ByteDance

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/bytedance/stable-diffusion-xl-lightning` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

SDXL-Lightning is a lightning-fast text-to-image generation model. It can generate high-quality 1024px images in a few steps.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| More information | [link ↗](https://huggingface.co/ByteDance/SDXL-Lightning) |
| Zero data retention | Yes |
| Beta | Yes |
| Unit Pricing | $0.00 per step |

## Parameters

prompt

`string`requiredminLength: 1A text description of the image you want to generate

negative\_prompt

`string`Text describing elements to avoid in the generated image

height

`integer`minimum: 256maximum: 2048The height of the generated image in pixels

width

`integer`minimum: 256maximum: 2048The width of the generated image in pixels

▶image\[]

`array`For use with img2img tasks. An array of integers that represent the image data constrained to 8-bit unsigned integer values

image\_b64

`string`For use with img2img tasks. A base64-encoded string of the input image

▶mask\[]

`array`An array representing An array of integers that represent mask image data for inpainting constrained to 8-bit unsigned integer values

num\_steps

`integer`default: 20maximum: 20The number of diffusion steps; higher values can improve quality but take longer

strength

`number`default: 1A value between 0 and 1 indicating how strongly to apply the transformation during img2img tasks; lower values make the output closer to the input image

guidance

`number`default: 7.5Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt

seed

`integer`Random seed for reproducibility of the image generation

The binding returns a `ReadableStream` with the output (check the model's output schema).

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/#page","headline":"stable-diffusion-xl-lightning","description":"SDXL-Lightning is a lightning-fast text-to-image generation model. It can generate high-quality 1024px images in a few steps.","url":"https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-lightning/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Clairic is a System One-style model that can extract, compute, estimate, and forecast values from inputs. It is strongly typed and outputs confidence scores and probabilities against its outputs. This model is in preview from the Cloudflare Workers AI team.
title: clairic
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Cloudflare logo](https://developers.cloudflare.com/_astro/cloudflare.DP8rkHys.svg)

# clairic

Text Generation • Cloudflare

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/clairic/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/cloudflare/clairic` Copy

- Cloudflare-hosted
- Vision
- Zero data retention

Clairic is a System One-style model that can extract, compute, estimate, and forecast values from inputs. It is strongly typed and outputs confidence scores and probabilities against its outputs. This model is in preview from the Cloudflare Workers AI team.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 65,536 tokens |
| Terms and License | [link](#terms) |
| Vision | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.10 per M input tokens |

## Usage

```ts
export interface Env {
	AI: Ai;
}

export default {
	async fetch(request, env): Promise<Response> {
		const response = await env.AI.run("@cf/cloudflare/clairic", {
			model: "clairic",
			state: "Invoice INV-2291 from Northwind Supply, issued 2026-09-02, net 30. 4 pallets at $250.00 each, shipping $80.00. Contact: Dana Ruiz, Priya Shah.",
			fields: {
				invoice_number: { type: "text" },
				due_date: {
					type: "date",
					instructions: "Issue date plus the net payment days",
				},
				total: {
					type: "number",
					decimals: 2,
					unit: "USD",
					instructions: "Amount due including shipping",
				},
				contacts: { type: "list", items: "text" },
				po_number: { type: "text", instructions: "Purchase order number" },
				days_to_pay: {
					type: "estimate",
					min: 0,
					max: 120,
					step: 1,
					instructions: "Days after issue until this invoice is paid",
				},
			},
		});

		// response.answers.invoice_number -> exact span of the state, with character offsets
		// response.answers.due_date       -> date worked out from the issue date and terms
		// response.answers.po_number      -> null: the invoice has no PO number
		// response.answers.days_to_pay    -> median and 80% interval (p10 to p90)
		return Response.json(response);
	},
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

response = requests.post(
    f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/cloudflare/clairic",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
        "model": "clairic",
        "state": "Invoice INV-2291 from Northwind Supply, issued 2026-09-02, net 30. 4 pallets at $250.00 each, shipping $80.00. Contact: Dana Ruiz, Priya Shah.",
        "fields": {
            "invoice_number": {"type": "text"},
            "due_date": {
                "type": "date",
                "instructions": "Issue date plus the net payment days",
            },
            "total": {
                "type": "number",
                "decimals": 2,
                "unit": "USD",
                "instructions": "Amount due including shipping",
            },
            "contacts": {"type": "list", "items": "text"},
            "po_number": {"type": "text", "instructions": "Purchase order number"},
            "days_to_pay": {
                "type": "estimate",
                "min": 0,
                "max": 120,
                "step": 1,
                "instructions": "Days after issue until this invoice is paid",
            },
        },
    },
)
print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/cloudflare/clairic \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{
    "model": "clairic",
    "state": "Invoice INV-2291 from Northwind Supply, issued 2026-09-02, net 30. 4 pallets at $250.00 each, shipping $80.00. Contact: Dana Ruiz, Priya Shah.",
    "fields": {
      "invoice_number": { "type": "text" },
      "due_date": { "type": "date", "instructions": "Issue date plus the net payment days" },
      "total": { "type": "number", "decimals": 2, "unit": "USD", "instructions": "Amount due including shipping" },
      "contacts": { "type": "list", "items": "text" },
      "po_number": { "type": "text", "instructions": "Purchase order number" },
      "days_to_pay": {
        "type": "estimate",
        "min": 0,
        "max": 120,
        "step": 1,
        "instructions": "Days after issue until this invoice is paid"
      }
    }
  }'
```

```json
{
  "model": "clairic",
  "answers": {
    "invoice_number": {"type": "text", "p_null": 3.8e-10, "span": [8, 16], "guess": "INV-2291", "confidence": 1, "value": "INV-2291"},
    "due_date": {"type": "date", "p_null": 1.9e-08, "guess": "2026-10-02", "confidence": 0.9999, "value": "2026-10-02"},
    "total": {"type": "number", "p_null": 2.3e-08, "guess": 1080, "confidence": 0.9999, "value": 1080},
    "contacts": {"type": "list", "value": ["Dana Ruiz", "Priya Shah"], "spans": [[120, 129], [131, 141]], "confidence": 0.9999},
    "po_number": {"type": "text", "p_null": 1, "span": [8, 16], "guess": "INV-2291", "confidence": 0.9995, "value": null},
    "days_to_pay": {"type": "estimate", "value": 30, "mean": 29.535, "median": 30, "p10": 21, "p90": 38, "p_below": 5.9e-06, "p_above": 1.2e-05}
  },
  "truncated": false,
  "usage": {"state_tokens": 61, "image_tokens": 0, "schema_tokens": 472, "input_tokens": 655, "output_tokens": 0, "passes": 3}
}
```

## Parameters

model

`string`requireddefault: clairicpattern: ^(clairic|@cf/cloudflare/clairic)$Required. The model selector: "clairic".

state

`string`default: The text to read and predict from. Must be non-empty unless images are sent. Text answers are spans of this string.

▶fields{}

`object`requiredminProperties: 1Required. Map of field name to a typed field spec. At least one field; no upper limit. Fields that do not fit next to the state in one 8,192-token pass are split across parallel passes.

▶images\[]

`array`maxItems: 4Optional embedded PNG, JPEG or WebP images placed before the state (max 4; 4 MiB each, 8 MiB total decoded; request body max 16 MiB). Remote URLs are not accepted.

reference\_date

`string`ISO date that anchors dates written without a year.

▶options{}

`object`

model

`string`

▶answers{}

`object`One answer per field, keyed by field name. value is null when the input does not determine it.

truncated

`boolean`

state\_text

`string`

▶usage{}

`object`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/clairic/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/clairic/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/clairic/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/clairic/schema-output.json)

## Terms

You may access or use this model at your sole discretion. Cloudflare does not make any representations, warranties, or guarantees regarding the model, including, but not limited to, as to its continued availability and integrity. If Cloudflare makes the model available to you, it is on an “AS IS” and “AS AVAILABLE” basis, and Cloudflare has no obligation to indemnify you for any claims arising from your use of the model. Cloudflare may cease providing it without entitling you to any refund, credit, or other compensation. Cloudflare will not be directly or indirectly responsible or liable to you in any manner, for any harms, damages, loss, lost profits, special or consequential damages, or claims, arising out of or in connection with the use of, or reliance on the performance of the model.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/clairic/#page","headline":"clairic","description":"Clairic is a System One-style model that can extract, compute, estimate, and forecast values from inputs. It is strongly typed and outputs confidence scores and probabilities against its outputs. This model is in preview from the Cloudflare Workers AI team.","url":"https://developers.cloudflare.com/workers-ai/models/clairic/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Clef is a 27B multimodal decision model that turns a state and a schema of typed questions into decisions. It reads the state as text, JSON, images, or video, and returns a probability for every allowed option of every question.
title: clef
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Cloudflare logo](https://developers.cloudflare.com/_astro/cloudflare.DP8rkHys.svg)

# clef

Text Generation • Cloudflare

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/clef/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/cloudflare/clef` Copy

- Cloudflare-hosted
- Vision
- Zero data retention

Clef is a 27B multimodal decision model that turns a state and a schema of typed questions into decisions. It reads the state as text, JSON, images, or video, and returns a probability for every allowed option of every question.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 65,536 tokens |
| Terms and License | [link ↗](https://huggingface.co/Cloudflare/clef/blob/main/LICENSE) |
| More information | [link ↗](https://huggingface.co/Cloudflare/clef) |
| Vision | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.24 per M input tokens |

How media inputs are billed

Clef models convert media inputs to input tokens and bill them at the model's input token rate. Clef models do not charge for output tokens. For per-model rates, refer to [pricing](https://developers.cloudflare.com/workers-ai/platform/pricing/).

Images are tokenized as follows:

1. **Resize**: The image keeps its aspect ratio, but:
   - Each side is rounded to a multiple of 32 pixels.
   - If the area is under about 65,000 pixels (256x256), it is scaled up to reach that.
   - If the area is over about 1 megapixel, it is scaled down to fit.
2. **Count patches**: Each 32x32-pixel block is one token: `tokens = (width / 32) x (height / 32)`.
3. **Add markers**: 3 tokens are added to mark where the image starts and ends.

Each image is capped at 1,024 tokens.

Media tokens count toward the model's context window, together with the questions. If they exceed the context window, the request fails. Otherwise, the text `state` is truncated to fit the remaining space.

## Usage

```ts
export interface Env {
	AI: Ai;
}

export default {
	async fetch(request, env): Promise<Response> {
		const response = await env.AI.run("@cf/cloudflare/clef", {
			model: "clef",
			state: "Checkout has been failing for every customer for the last hour.",
			questions: {
				urgent: {
					type: "noul",
					instructions: "Is this support request urgent?",
				},
				team: {
					type: "choice",
					instructions: "Which team should handle this request?",
					criteria: {
						billing: "Payments, invoices, and refunds",
						technical: "Outages, errors, and configuration",
						sales: "Plans and upgrades",
					},
				},
				severity: {
					type: "score",
					instructions: "How severe is the customer impact?",
					criteria: ["No impact", "Minor", "Major", "Critical"],
				},
			},
		});

		// response.answers.urgent   -> probability the request is urgent
		// response.answers.team     -> chosen team with per-option probabilities
		// response.answers.severity -> probability-weighted score (0 = lowest level)
		return Response.json(response);
	},
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

response = requests.post(
    f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/cloudflare/clef",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
        "model": "clef",
        "state": "Checkout has been failing for every customer for the last hour.",
        "questions": {
            "urgent": {
                "type": "noul",
                "instructions": "Is this support request urgent?",
            },
            "team": {
                "type": "choice",
                "instructions": "Which team should handle this request?",
                "criteria": {
                    "billing": "Payments, invoices, and refunds",
                    "technical": "Outages, errors, and configuration",
                    "sales": "Plans and upgrades",
                },
            },
            "severity": {
                "type": "score",
                "instructions": "How severe is the customer impact?",
                "criteria": ["No impact", "Minor", "Major", "Critical"],
            },
        },
    },
)
print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/cloudflare/clef \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{
    "model": "clef",
    "state": "Checkout has been failing for every customer for the last hour.",
    "questions": {
      "urgent": { "type": "noul", "instructions": "Is this support request urgent?" },
      "team": {
        "type": "choice",
        "instructions": "Which team should handle this request?",
        "criteria": {
          "billing": "Payments, invoices, and refunds",
          "technical": "Outages, errors, and configuration",
          "sales": "Plans and upgrades"
        }
      },
      "severity": {
        "type": "score",
        "instructions": "How severe is the customer impact?",
        "criteria": ["No impact", "Minor", "Major", "Critical"]
      }
    }
  }'
```

## Parameters

model

`string`requiredpattern: ^\\s\*(clef|clef-flash)\\s\*$Required. The model selector: "clef" for @cf/cloudflare/clef, "clef-flash" for @cf/cloudflare/clef-flash.

state

requiredRequired. The content to evaluate: a string, or structured data (object/array) such as records, chat logs, or application state. Long text state is truncated to fit the model's token limit.

▶questions{}

`object`requiredminProperties: 1maxProperties: 64Map of question id to a typed question (noul, choice, or score). 1 to 64 questions; ids may use letters, digits, '\_', '.', '-' (max 100 chars). Answers are returned under the same ids.

▶images\[]

`array`maxItems: 4Clef extension to the System One API. Optional embedded PNG, JPEG, or WebP images placed before the state (max 4; 4 MiB and 16 megapixels each, 8 MiB total decoded; whole request body max 13 MiB). Remote URLs are not accepted.

model

`string`The model that performed the evaluation.

▶answers{}

`object`One answer per question, keyed by the question ids from the request.

▶usage{}

`object`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/clef/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/clef/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/clef/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/clef/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/clef/#page","headline":"clef","description":"Clef is a 27B multimodal decision model that turns a state and a schema of typed questions into decisions. It reads the state as text, JSON, images, or video, and returns a probability for every allowed option of every question.","url":"https://developers.cloudflare.com/workers-ai/models/clef/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Clef-flash is a fast 9B multimodal decision model that turns a state and a schema of typed questions into decisions. It reads the state as text, JSON, images, or video, and returns a probability for every allowed option of every question.
title: clef-flash
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Cloudflare logo](https://developers.cloudflare.com/_astro/cloudflare.DP8rkHys.svg)

# clef-flash

Text Generation • Cloudflare

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/clef-flash/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/cloudflare/clef-flash` Copy

- Cloudflare-hosted
- Vision
- Zero data retention

Clef-flash is a fast 9B multimodal decision model that turns a state and a schema of typed questions into decisions. It reads the state as text, JSON, images, or video, and returns a probability for every allowed option of every question.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 24,576 tokens |
| Terms and License | [link ↗](https://huggingface.co/Cloudflare/clef-flash/blob/main/LICENSE) |
| More information | [link ↗](https://huggingface.co/Cloudflare/clef-flash) |
| Vision | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.038 per M input tokens |

How media inputs are billed

Clef models convert media inputs to input tokens and bill them at the model's input token rate. Clef models do not charge for output tokens. For per-model rates, refer to [pricing](https://developers.cloudflare.com/workers-ai/platform/pricing/).

Images are tokenized as follows:

1. **Resize**: The image keeps its aspect ratio, but:
   - Each side is rounded to a multiple of 32 pixels.
   - If the area is under about 65,000 pixels (256x256), it is scaled up to reach that.
   - If the area is over about 1 megapixel, it is scaled down to fit.
2. **Count patches**: Each 32x32-pixel block is one token: `tokens = (width / 32) x (height / 32)`.
3. **Add markers**: 3 tokens are added to mark where the image starts and ends.

Each image is capped at 1,024 tokens.

Media tokens count toward the model's context window, together with the questions. If they exceed the context window, the request fails. Otherwise, the text `state` is truncated to fit the remaining space.

## Usage

```ts
export interface Env {
	AI: Ai;
}

export default {
	async fetch(request, env): Promise<Response> {
		const response = await env.AI.run("@cf/cloudflare/clef-flash", {
			model: "clef-flash",
			state: "Checkout has been failing for every customer for the last hour.",
			questions: {
				urgent: {
					type: "noul",
					instructions: "Is this support request urgent?",
				},
				team: {
					type: "choice",
					instructions: "Which team should handle this request?",
					criteria: {
						billing: "Payments, invoices, and refunds",
						technical: "Outages, errors, and configuration",
						sales: "Plans and upgrades",
					},
				},
				severity: {
					type: "score",
					instructions: "How severe is the customer impact?",
					criteria: ["No impact", "Minor", "Major", "Critical"],
				},
			},
		});

		// response.answers.urgent   -> probability the request is urgent
		// response.answers.team     -> chosen team with per-option probabilities
		// response.answers.severity -> probability-weighted score (0 = lowest level)
		return Response.json(response);
	},
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

response = requests.post(
    f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/cloudflare/clef-flash",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
        "model": "clef-flash",
        "state": "Checkout has been failing for every customer for the last hour.",
        "questions": {
            "urgent": {
                "type": "noul",
                "instructions": "Is this support request urgent?",
            },
            "team": {
                "type": "choice",
                "instructions": "Which team should handle this request?",
                "criteria": {
                    "billing": "Payments, invoices, and refunds",
                    "technical": "Outages, errors, and configuration",
                    "sales": "Plans and upgrades",
                },
            },
            "severity": {
                "type": "score",
                "instructions": "How severe is the customer impact?",
                "criteria": ["No impact", "Minor", "Major", "Critical"],
            },
        },
    },
)
print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/cloudflare/clef-flash \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{
    "model": "clef-flash",
    "state": "Checkout has been failing for every customer for the last hour.",
    "questions": {
      "urgent": { "type": "noul", "instructions": "Is this support request urgent?" },
      "team": {
        "type": "choice",
        "instructions": "Which team should handle this request?",
        "criteria": {
          "billing": "Payments, invoices, and refunds",
          "technical": "Outages, errors, and configuration",
          "sales": "Plans and upgrades"
        }
      },
      "severity": {
        "type": "score",
        "instructions": "How severe is the customer impact?",
        "criteria": ["No impact", "Minor", "Major", "Critical"]
      }
    }
  }'
```

## Parameters

model

`string`requiredpattern: ^\\s\*(clef|clef-flash)\\s\*$Required. The model selector: "clef" for @cf/cloudflare/clef, "clef-flash" for @cf/cloudflare/clef-flash.

state

requiredRequired. The content to evaluate: a string, or structured data (object/array) such as records, chat logs, or application state. Long text state is truncated to fit the model's token limit.

▶questions{}

`object`requiredminProperties: 1maxProperties: 64Map of question id to a typed question (noul, choice, or score). 1 to 64 questions; ids may use letters, digits, '\_', '.', '-' (max 100 chars). Answers are returned under the same ids.

▶images\[]

`array`maxItems: 4Clef extension to the System One API. Optional embedded PNG, JPEG, or WebP images placed before the state (max 4; 4 MiB and 16 megapixels each, 8 MiB total decoded; whole request body max 13 MiB). Remote URLs are not accepted.

model

`string`The model that performed the evaluation.

▶answers{}

`object`One answer per question, keyed by the question ids from the request.

▶usage{}

`object`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/clef-flash/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/clef-flash/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/clef-flash/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/clef-flash/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/clef-flash/#page","headline":"clef-flash","description":"Clef-flash is a fast 9B multimodal decision model that turns a state and a schema of typed questions into decisions. It reads the state as text, JSON, images, or video, and returns a probability for every allowed option of every question.","url":"https://developers.cloudflare.com/workers-ai/models/clef-flash/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Clef-omni is a multimodal decision model built on a 30B-parameter mixture-of-experts (3B active) backbone. It turns a state and a schema of typed questions into decisions, reads the state as text, JSON, images, audio, or video, and returns a probability for every allowed option of every question.
title: clef-omni
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Cloudflare logo](https://developers.cloudflare.com/_astro/cloudflare.DP8rkHys.svg)

# clef-omni

Text Generation • Cloudflare

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/clef-omni/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/cloudflare/clef-omni` Copy

- Cloudflare-hosted
- Vision
- Zero data retention

Clef-omni is a multimodal decision model built on a 30B-parameter mixture-of-experts (3B active) backbone. It turns a state and a schema of typed questions into decisions, reads the state as text, JSON, images, audio, or video, and returns a probability for every allowed option of every question.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 64,000 tokens |
| Terms and License | [link ↗](https://huggingface.co/Cloudflare/clef-omni/blob/main/LICENSE) |
| More information | [link ↗](https://huggingface.co/Cloudflare/clef-omni) |
| Vision | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.15 per M input tokens |

How media inputs are billed

Clef models convert media inputs to input tokens and bill them at the model's input token rate. Clef models do not charge for output tokens. For per-model rates, refer to [pricing](https://developers.cloudflare.com/workers-ai/platform/pricing/).

Images are tokenized as follows:

1. **Resize**: The image keeps its aspect ratio, but:
   - Each side is rounded to a multiple of 32 pixels.
   - If the area is under about 65,000 pixels (256x256), it is scaled up to reach that.
   - If the area is over about 1 megapixel, it is scaled down to fit.
2. **Count patches**: Each 32x32-pixel block is one token: `tokens = (width / 32) x (height / 32)`.
3. **Add markers**: 3 tokens are added to mark where the image starts and ends.

Each image is capped at 1,024 tokens.

Audio and video are tokenized by duration:

- **Audio**: about 780 tokens per minute.
- **Video**: up to about 15,400 tokens per minute at maximum resolution, plus about 780 tokens per minute if the video has sound. A 480p clip uses about 8,600 frame tokens per minute (144 tokens per second).

Each request accepts up to 4 audio clips and 2 videos.

Media tokens count toward the model's context window, together with the questions. If they exceed the context window, the request fails. Otherwise, the text `state` is truncated to fit the remaining space.

## Usage

```ts
export interface Env {
	AI: Ai;
}

export default {
	async fetch(request, env): Promise<Response> {
		const response = await env.AI.run("@cf/cloudflare/clef-omni", {
			model: "clef-omni",
			state: "Checkout has been failing for every customer for the last hour.",
			questions: {
				urgent: {
					type: "noul",
					instructions: "Is this support request urgent?",
				},
				team: {
					type: "choice",
					instructions: "Which team should handle this request?",
					criteria: {
						billing: "Payments, invoices, and refunds",
						technical: "Outages, errors, and configuration",
						sales: "Plans and upgrades",
					},
				},
				severity: {
					type: "score",
					instructions: "How severe is the customer impact?",
					criteria: ["No impact", "Minor", "Major", "Critical"],
				},
			},
		});

		// response.answers.urgent   -> probability the request is urgent
		// response.answers.team     -> chosen team with per-option probabilities
		// response.answers.severity -> probability-weighted score (0 = lowest level)
		return Response.json(response);
	},
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

response = requests.post(
    f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/cloudflare/clef-omni",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
        "model": "clef-omni",
        "state": "Checkout has been failing for every customer for the last hour.",
        "questions": {
            "urgent": {
                "type": "noul",
                "instructions": "Is this support request urgent?",
            },
            "team": {
                "type": "choice",
                "instructions": "Which team should handle this request?",
                "criteria": {
                    "billing": "Payments, invoices, and refunds",
                    "technical": "Outages, errors, and configuration",
                    "sales": "Plans and upgrades",
                },
            },
            "severity": {
                "type": "score",
                "instructions": "How severe is the customer impact?",
                "criteria": ["No impact", "Minor", "Major", "Critical"],
            },
        },
    },
)
print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/cloudflare/clef-omni \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{
    "model": "clef-omni",
    "state": "Checkout has been failing for every customer for the last hour.",
    "questions": {
      "urgent": { "type": "noul", "instructions": "Is this support request urgent?" },
      "team": {
        "type": "choice",
        "instructions": "Which team should handle this request?",
        "criteria": {
          "billing": "Payments, invoices, and refunds",
          "technical": "Outages, errors, and configuration",
          "sales": "Plans and upgrades"
        }
      },
      "severity": {
        "type": "score",
        "instructions": "How severe is the customer impact?",
        "criteria": ["No impact", "Minor", "Major", "Critical"]
      }
    }
  }'
```

## Parameters

model

`string`requireddefault: clef-omnipattern: ^\\s\*clef-omni\\s\*$Required. The model selector: "clef-omni" for @cf/cloudflare/clef-omni.

state

requiredRequired. The content to evaluate: a string, or structured data (object/array) such as records, chat logs, or application state. Long text state is truncated to fit the model's token limit.

▶questions{}

`object`requiredminProperties: 1maxProperties: 64Map of question id to a typed question (noul, choice, or score). 1 to 64 questions; ids may use letters, digits, '\_', '.', '-' (max 100 chars). Answers are returned under the same ids.

▶images\[]

`array`maxItems: 4Clef extension to the System One API. Optional embedded PNG, JPEG, or WebP images placed before the state (max 4; 4 MiB and 16 megapixels each, 8 MiB total decoded). Each image costs 64 to 1,024 input tokens. Remote URLs are not accepted.

▶audio\[]

`array`maxItems: 4Clef-Omni extension. Optional embedded audio clips (max 4; 8 MiB and 300 seconds each). Audio and video clips together may total at most 16 MiB decoded. Remote URLs are not accepted.

▶videos\[]

`array`maxItems: 2Clef-Omni extension. Optional embedded videos (max 2; 16 MiB and 60 seconds each), sampled at 2 frames per second. A video's soundtrack is heard with its frames when every video in the request has one. Audio and video clips together may total at most 16 MiB decoded. Each second of video costs up to 256 input tokens. Remote URLs are not accepted.

model

`string`The model that performed the evaluation.

▶answers{}

`object`One answer per question, keyed by the question ids from the request.

▶usage{}

`object`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/clef-omni/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/clef-omni/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/clef-omni/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/clef-omni/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/clef-omni/#page","headline":"clef-omni","description":"Clef-omni is a multimodal decision model built on a 30B-parameter mixture-of-experts (3B active) backbone. It turns a state and a schema of typed questions into decisions, reads the state as text, JSON, images, audio, or video, and returns a probability for every allowed option of every question.","url":"https://developers.cloudflare.com/workers-ai/models/clef-omni/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: PhoneLLM is an open model tuned for voice agents. The model is based on Nemotron Nano 30B base capabilities and excels at typical voice agent tasks with thinking disabled.
title: phonellm-mini-alpha-2
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

d

# phonellm-mini-alpha-2

Text Generation • daily-co

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/daily-co/phonellm-mini-alpha-2` Copy

- Cloudflare-hosted
- Function calling
- Zero data retention

PhoneLLM is an open model tuned for voice agents. The model is based on Nemotron Nano 30B base capabilities and excels at typical voice agent tasks with thinking disabled.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 262,140 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.06 per M input tokens, $0.24 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/daily-co/phonellm-mini-alpha-2)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/daily-co/phonellm-mini-alpha-2", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/daily-co/phonellm-mini-alpha-2", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/daily-co/phonellm-mini-alpha-2",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/daily-co/phonellm-mini-alpha-2 \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

model

`string`ID of the model to use (for example, '@cf/daily-co/phonellm-mini-alpha-2').

▶audio{}

`object`Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

`number | null`Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

`object | null`Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

`boolean | null`Whether to return log probabilities of the output tokens.

top\_logprobs

`integer | null`How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

`integer | null`The maximum number of tokens to generate.

max\_completion\_tokens

`integer | null`An upper bound for the number of tokens that can be generated for a completion.

metadata

`object | null`Set of key-value pairs that can be attached to the object.

modalities

`array | null`Output types requested from the model.

n

`integer | null`How many chat completion choices to generate for each input message.

parallel\_tool\_calls

`boolean`default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

`object`

presence\_penalty

`number | null`Penalizes new tokens based on whether they appear in the text so far.

▶chat\_template\_kwargs{}

`object`Chat-template controls.

▶response\_format

`one of`Specifies the format the model must output.

seed

`integer | null`If specified, the system will make a best effort to sample deterministically.

▶stop

`one of`

store

`boolean | null`Whether to store the output for model distillation or evaluation.

stream

`boolean | null`If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

`object`

temperature

`number | null`Sampling temperature between 0 and 2.

▶tool\_choice

`one of`Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

`array`A list of tools the model may call.

top\_p

`number | null`Nucleus sampling: considers the results of the tokens with top\_p probability mass.

user

`string`A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

`object`Options for the web search tool (when using built-in web search).

▶function\_call

`one of`

▶functions\[]

`array`minItems: 1maxItems: 128

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/#page","headline":"phonellm-mini-alpha-2","description":"PhoneLLM is an open model tuned for voice agents. The model is based on Nemotron Nano 30B base capabilities and excels at typical voice agent tasks with thinking disabled.","url":"https://developers.cloudflare.com/workers-ai/models/phonellm-mini-alpha-2/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Aura is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.
title: aura-1
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)

# aura-1

Text-to-Speech • Deepgram

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/aura-1/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/deepgram/aura-1` Copy

- Cloudflare-hosted
- Batch
- Partner
- Real-time
- Zero data retention

Aura is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://deepgram.com/terms) |
| Zero data retention | Yes |
| Batch | Yes |
| Partner | Yes |
| Real-time | Yes |
| Unit Pricing | $0.015 per 1k characters |

## Usage

```ts
export default {
  async fetch(request, env, ctx): Promise<Response> {
      const resp = await env.AI.run("@cf/deepgram/aura-1", {
        "text":"Hello World!"
      }, {
        returnRawResponse: true
      });

      return resp;
  },
} satisfies ExportedHandler<Env>;
```

```sh
curl --request POST   --url 'https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/deepgram/aura-1'   --header 'Authorization: Bearer {TOKEN}'   --header 'Content-Type: application/json'   --data '{
    "text":"Hello world!"
}'
```

## Parameters

speaker

`string`default: angusenum: angus, asteria, arcas, orion, orpheus, athena, luna, zeus, perseus, helios, hera, stellaSpeaker used to produce the audio.

encoding

`string`enum: linear16, flac, mulaw, alaw, mp3, opus, aacEncoding of the output audio.

container

`string`enum: none, wav, oggContainer specifies the file format wrapper for the output audio. The available options depend on the encoding type..

text

`string`requiredThe text content to be converted to speech

sample\_rate

`number`Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable

bit\_rate

`number`The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.

The binding returns a `ReadableStream` with the audio in MPEG format (check the model's output schema).

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/aura-1/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/aura-1/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/aura-1/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/aura-1/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/aura-1/#page","headline":"aura-1","description":"Aura is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.","url":"https://developers.cloudflare.com/workers-ai/models/aura-1/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Aura-2 is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.
title: aura-2-en
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)

# aura-2-en

Text-to-Speech • Deepgram

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/aura-2-en/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/deepgram/aura-2-en` Copy

- Cloudflare-hosted
- Batch
- Partner
- Real-time
- Zero data retention

Aura-2 is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://deepgram.com/terms) |
| Zero data retention | Yes |
| Batch | Yes |
| Partner | Yes |
| Real-time | Yes |
| Unit Pricing | $0.03 per 1k characters |

## Parameters

speaker

`string`default: lunaenum: amalthea, andromeda, apollo, arcas, aries, asteria, athena, atlas, aurora, callista, cora, cordelia, delia, draco, electra, harmonia, helena, hera, hermes, hyperion, iris, janus, juno, jupiter, luna, mars, minerva, neptune, odysseus, ophelia, orion, orpheus, pandora, phoebe, pluto, saturn, thalia, theia, vesta, zeusSpeaker used to produce the audio.

encoding

`string`enum: linear16, flac, mulaw, alaw, mp3, opus, aacEncoding of the output audio.

container

`string`enum: none, wav, oggContainer specifies the file format wrapper for the output audio. The available options depend on the encoding type..

text

`string`The text content to be converted to speech

sample\_rate

`number`Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable

bit\_rate

`number`The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.

The binding returns a `ReadableStream` with the audio in MPEG format (check the model's output schema).

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/aura-2-en/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/aura-2-en/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/aura-2-en/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/aura-2-en/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/aura-2-en/#page","headline":"aura-2-en","description":"Aura-2 is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.","url":"https://developers.cloudflare.com/workers-ai/models/aura-2-en/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Aura-2 is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.
title: aura-2-es
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)

# aura-2-es

Text-to-Speech • Deepgram

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/aura-2-es/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/deepgram/aura-2-es` Copy

- Cloudflare-hosted
- Batch
- Partner
- Real-time
- Zero data retention

Aura-2 is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://deepgram.com/terms) |
| Zero data retention | Yes |
| Batch | Yes |
| Partner | Yes |
| Real-time | Yes |
| Unit Pricing | $0.03 per 1k characters |

## Parameters

speaker

`string`default: aquilaenum: sirio, nestor, carina, celeste, alvaro, diana, aquila, selena, estrella, javierSpeaker used to produce the audio.

encoding

`string`enum: linear16, flac, mulaw, alaw, mp3, opus, aacEncoding of the output audio.

container

`string`enum: none, wav, oggContainer specifies the file format wrapper for the output audio. The available options depend on the encoding type..

text

`string`The text content to be converted to speech

sample\_rate

`number`Sample Rate specifies the sample rate for the output audio. Based on the encoding, different sample rates are supported. For some encodings, the sample rate is not configurable

bit\_rate

`number`The bitrate of the audio in bits per second. Choose from predefined ranges or specific values based on the encoding type.

The binding returns a `ReadableStream` with the audio in MPEG format (check the model's output schema).

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/aura-2-es/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/aura-2-es/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/aura-2-es/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/aura-2-es/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/aura-2-es/#page","headline":"aura-2-es","description":"Aura-2 is a context-aware text-to-speech (TTS) model that applies natural pacing, expressiveness, and fillers based on the context of the provided text. The quality of your text input directly impacts the naturalness of the audio output.","url":"https://developers.cloudflare.com/workers-ai/models/aura-2-es/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Flux is the first conversational speech recognition model built specifically for voice agents.
title: flux
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)

# flux

Automatic Speech Recognition • Deepgram

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/flux/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/deepgram/flux` Copy

- Cloudflare-hosted
- Partner
- Real-time
- Zero data retention

Flux is the first conversational speech recognition model built specifically for voice agents.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://deepgram.com/terms) |
| Zero data retention | Yes |
| Partner | Yes |
| Real-time | Yes |
| Unit Pricing | $0.0077 per audio minute (websocket) |

## Parameters

encoding

`string`enum: linear16Encoding of the audio stream. Currently only supports raw signed little-endian 16-bit PCM.

sample\_rate

`string`pattern: ^\[0-9]+$Sample rate of the audio stream in Hz.

eager\_eot\_threshold

`string`End-of-turn confidence required to fire an eager end-of-turn event. When set, enables EagerEndOfTurn and TurnResumed events. Valid Values 0.3 - 0.9.

eot\_threshold

`string`default: 0.7End-of-turn confidence required to finish a turn. Valid Values 0.5 - 0.9.

eot\_timeout\_ms

`string`default: 5000pattern: ^\[0-9]+$A turn will be finished when this much time has passed after speech, regardless of EOT confidence.

keyterm

`string`Keyterm prompting can improve recognition of specialized terminology. Pass multiple keyterm query parameters to boost multiple keyterms.

mip\_opt\_out

`string`default: falseenum: true, falseOpts out requests from the Deepgram Model Improvement Program. Refer to Deepgram Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip

tag

`string`Label your requests for the purpose of identification during usage reporting

request\_id

`string`The unique identifier of the request (uuid)

sequence\_id

`integer`minimum: 0Starts at 0 and increments for each message the server sends to the client.

event

`string`enum: Update, StartOfTurn, EagerEndOfTurn, TurnResumed, EndOfTurnThe type of event being reported.

turn\_index

`integer`minimum: 0The index of the current turn

audio\_window\_start

`number`Start time in seconds of the audio range that was transcribed

audio\_window\_end

`number`End time in seconds of the audio range that was transcribed

transcript

`string`Text that was said over the course of the current turn

▶words\[]

`array`The words in the transcript

end\_of\_turn\_confidence

`number`Confidence that no more speech is coming in this turn

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/flux/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/flux/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/flux/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/flux/#page","headline":"flux","description":"Flux is the first conversational speech recognition model built specifically for voice agents.","url":"https://developers.cloudflare.com/workers-ai/models/flux/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Transcribe audio using Deepgram’s speech-to-text model
title: nova-3
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Deepgram logo](https://developers.cloudflare.com/_astro/deepgram.BYzW8KfF.svg)

# nova-3

Automatic Speech Recognition • Deepgram

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/nova-3/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/deepgram/nova-3` Copy

- Cloudflare-hosted
- Batch
- Partner
- Real-time
- Zero data retention

Transcribe audio using Deepgram’s speech-to-text model

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://deepgram.com/terms) |
| Zero data retention | Yes |
| Batch | Yes |
| Partner | Yes |
| Real-time | Yes |
| Unit Pricing | $0.0052 per audio minute, $0.0092 per audio minute (websocket) |

Note

The [pricing of this model](https://developers.cloudflare.com/workers-ai/platform/pricing) is different based on transport. Transport-based pricing does not apply to all models.

- WebSocket: $0.0092 per audio minute output (836.36 neurons per audio minute output)
- Regular HTTP: $0.0052 per audio minute output (472.73 neurons per audio minute output)

## Parameters

▶audio{}

`object`required

custom\_topic\_mode

`string`enum: extended, strictSets how the model will interpret strings submitted to the custom\_topic param. When strict, the model will only return topics submitted using the custom\_topic param. When extended, the model will return its own detected topics in addition to those submitted using the custom\_topic param.

custom\_topic

`string`Custom topics you want the model to detect within your input audio or text if present Submit up to 100

custom\_intent\_mode

`string`enum: extended, strictSets how the model will interpret intents submitted to the custom\_intent param. When strict, the model will only return intents submitted using the custom\_intent param. When extended, the model will return its own detected intents in addition those submitted using the custom\_intents param

custom\_intent

`string`Custom intents you want the model to detect within your input audio if present

detect\_entities

`boolean`Identifies and extracts key entities from content in submitted audio

detect\_language

`boolean`Identifies the dominant language spoken in submitted audio

diarize

`boolean`Recognize speaker changes. Each word in the transcript will be assigned a speaker number starting at 0

dictation

`boolean`Identify and extract key entities from content in submitted audio

encoding

`string`enum: linear16, flac, mulaw, amr-nb, amr-wb, opus, speex, g729Specify the expected encoding of your submitted audio

extra

`string`Arbitrary key-value pairs that are attached to the API response for usage in downstream processing

filler\_words

`boolean`Filler Words can help transcribe interruptions in your audio, like 'uh' and 'um'

keyterm

`string`Key term prompting can boost or suppress specialized terminology and brands.

keywords

`string`Keywords can boost or suppress specialized terminology and brands.

language

`string`The BCP-47 language tag that hints at the primary spoken language. Depending on the Model and API endpoint you choose only certain languages are available.

measurements

`boolean`Spoken measurements will be converted to their corresponding abbreviations.

mip\_opt\_out

`boolean`Opts out requests from the Deepgram Model Improvement Program. Refer to our Docs for pricing impacts before setting this to true. https://dpgr.am/deepgram-mip.

mode

`string`enum: general, medical, financeMode of operation for the model representing broad area of topic that will be talked about in the supplied audio

multichannel

`boolean`Transcribe each audio channel independently.

numerals

`boolean`Numerals converts numbers from written format to numerical format.

paragraphs

`boolean`Splits audio into paragraphs to improve transcript readability.

profanity\_filter

`boolean`Profanity Filter looks for recognized profanity and converts it to the nearest recognized non-profane word or removes it from the transcript completely.

punctuate

`boolean`Add punctuation and capitalization to the transcript.

redact

`string`Redaction removes sensitive information from your transcripts.

replace

`string`Search for terms or phrases in submitted audio and replaces them.

search

`string`Search for terms or phrases in submitted audio.

sentiment

`boolean`Recognizes the sentiment throughout a transcript or text.

smart\_format

`boolean`Apply formatting to transcript output. When set to true, additional formatting will be applied to transcripts to improve readability.

topics

`boolean`Detect topics throughout a transcript or text.

utterances

`boolean`Segments speech into meaningful semantic units.

utt\_split

`number`Seconds to wait before detecting a pause between words in submitted audio.

channels

`number`The number of channels in the submitted audio

interim\_results

`boolean`Specifies whether the streaming endpoint should provide ongoing transcription updates as more audio is received. When set to true, the endpoint sends continuous updates, meaning transcription results may evolve over time. Note: Supported only for webosockets.

endpointing

`string`Indicates how long model will wait to detect whether a speaker has finished speaking or pauses for a significant period of time. When set to a value, the streaming endpoint immediately finalizes the transcription for the processed time range and returns the transcript with a speech\_final parameter set to true. Can also be set to false to disable endpointing

vad\_events

`boolean`Indicates that speech has started. You'll begin receiving Speech Started messages upon speech starting. Note: Supported only for webosockets.

utterance\_end\_ms

`boolean`Indicates how long model will wait to send an UtteranceEnd message after a word has been transcribed. Use with interim\_results. Note: Supported only for webosockets.

▶results{}

`object`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/nova-3/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/nova-3/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/nova-3/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/nova-3/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/nova-3/#page","headline":"nova-3","description":"Transcribe audio using Deepgram’s speech-to-text model","url":"https://developers.cloudflare.com/workers-ai/models/nova-3/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: DeepSeek-R1-Distill-Qwen-32B is a model distilled from DeepSeek-R1 based on Qwen2.5. It outperforms OpenAI-o1-mini across various benchmarks, achieving new state-of-the-art results for dense models.
title: deepseek-r1-distill-qwen-32b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![DeepSeek logo](https://developers.cloudflare.com/_astro/deepseek.CkzAgvN6.svg)

# deepseek-r1-distill-qwen-32b

Text Generation • DeepSeek

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/deepseek-ai/deepseek-r1-distill-qwen-32b` Copy

- Cloudflare-hosted
- Reasoning
- Planned deprecation
- Zero data retention

DeepSeek-R1-Distill-Qwen-32B is a model distilled from DeepSeek-R1 based on Qwen2.5. It outperforms OpenAI-o1-mini across various benchmarks, achieving new state-of-the-art results for dense models.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 80,000 tokens |
| Terms and License | [link ↗](https://github.com/deepseek-ai/DeepSeek-R1/blob/main/LICENSE) |
| Reasoning | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.497 per M input tokens, $4.881 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/deepseek-ai/deepseek-r1-distill-qwen-32b)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/deepseek-ai/deepseek-r1-distill-qwen-32b", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/deepseek-ai/deepseek-r1-distill-qwen-32b",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/deepseek-ai/deepseek-r1-distill-qwen-32b \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/#page","headline":"deepseek-r1-distill-qwen-32b","description":"DeepSeek-R1-Distill-Qwen-32B is a model distilled from DeepSeek-R1 based on Qwen2.5. It outperforms OpenAI-o1-mini across various benchmarks, achieving new state-of-the-art results for dense models.","url":"https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "DeepSeek-V4-Flash-0731 is the official release of DeepSeek-V4-Flash, superseding the preview version, with substantially enhanced agentic capabilities. "
title: deepseek-v4-flash-0731
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![DeepSeek logo](https://developers.cloudflare.com/_astro/deepseek.CkzAgvN6.svg)

# deepseek-v4-flash-0731

Text Generation • DeepSeek

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/deepseek-ai/deepseek-v4-flash-0731` Copy

- Cloudflare-hosted
- Batch
- Function calling
- Reasoning
- Planned deprecation
- Zero data retention

DeepSeek-V4-Flash-0731 is the official release of DeepSeek-V4-Flash, superseding the preview version, with substantially enhanced agentic capabilities.

Paid access required

This model is not available through standard Workers Free billing. To use it, upgrade to the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) or use prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/).

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 1,048,576 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `none``low``high` (default)`max` |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.44 per M input tokens, $1.32 per M output tokens, $0.014 per M cached input tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/deepseek-ai/deepseek-v4-flash-0731)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/deepseek-ai/deepseek-v4-flash-0731", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/deepseek-ai/deepseek-v4-flash-0731", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/deepseek-ai/deepseek-v4-flash-0731",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/deepseek-ai/deepseek-v4-flash-0731 \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, low, noneReasoning effort. Supported levels: max, high, low, none. Compatibility aliases: minimal maps to low; medium maps to high; xhigh maps to high.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, low, noneReasoning effort. Supported levels: max, high, low, none. Compatibility aliases: minimal maps to low; medium maps to high; xhigh maps to high.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/#page","headline":"deepseek-v4-flash-0731","description":"DeepSeek-V4-Flash-0731 is the official release of DeepSeek-V4-Flash, superseding the preview version, with substantially enhanced agentic capabilities.","url":"https://developers.cloudflare.com/workers-ai/models/deepseek-v4-flash-0731/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: DeepSeek V4 Pro is a high-capability reasoning model from DeepSeek with a one million token context window, built for long-horizon agentic workflows and complex, multi-step problem-solving
title: deepseek-v4-pro-0813
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![DeepSeek logo](https://developers.cloudflare.com/_astro/deepseek.CkzAgvN6.svg)

# deepseek-v4-pro-0813

Text Generation • DeepSeek

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/deepseek-ai/deepseek-v4-pro-0813` Copy

- Cloudflare-hosted
- Function calling
- Reasoning
- Planned deprecation
- Zero data retention

DeepSeek V4 Pro is a high-capability reasoning model from DeepSeek with a one million token context window, built for long-horizon agentic workflows and complex, multi-step problem-solving

Paid access required

This model is not available through standard Workers Free billing. To use it, upgrade to the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) or use prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/).

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 1,048,576 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `none``low``high` (default)`max` |
| Zero data retention | Yes |
| Unit Pricing | $1.32 per M input tokens, $3.96 per M output tokens, $0.044 per M cached input tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/deepseek-ai/deepseek-v4-pro-0813)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/deepseek-ai/deepseek-v4-pro-0813", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/deepseek-ai/deepseek-v4-pro-0813", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/deepseek-ai/deepseek-v4-pro-0813",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/deepseek-ai/deepseek-v4-pro-0813 \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, low, noneReasoning effort. Supported levels: max, high, low, none. Compatibility aliases: minimal maps to low; medium maps to high; xhigh maps to high.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, low, noneReasoning effort. Supported levels: max, high, low, none. Compatibility aliases: minimal maps to low; medium maps to high; xhigh maps to high.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/#page","headline":"deepseek-v4-pro-0813","description":"DeepSeek V4 Pro is a high-capability reasoning model from DeepSeek with a one million token context window, built for long-horizon agentic workflows and complex, multi-step problem-solving","url":"https://developers.cloudflare.com/workers-ai/models/deepseek-v4-pro-0813/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: We introduce DeepSeek-V4.1-Flash, a multimodal Mixture-of-Experts (MoE) model with 552B backbone parameters and support for contexts of up to one million tokens. The model natively processes images and text, and generates text autoregressively.
title: deepseek-v4.1-flash-1017
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![DeepSeek logo](https://developers.cloudflare.com/_astro/deepseek.CkzAgvN6.svg)

# deepseek-v4.1-flash-1017

Text Generation • DeepSeek

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/deepseek-ai/deepseek-v4.1-flash-1017` Copy

- Cloudflare-hosted
- Function calling
- Reasoning
- Vision
- Zero data retention

We introduce DeepSeek-V4.1-Flash, a multimodal Mixture-of-Experts (MoE) model with 552B backbone parameters and support for contexts of up to one million tokens. The model natively processes images and text, and generates text autoregressively.

Paid access required

This model is not available through standard Workers Free billing. To use it, upgrade to the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) or use prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/).

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 1,048,576 tokens |
| Terms and License | [link ↗](https://huggingface.co/deepseek-ai/DeepSeek-V4.1-Flash-1017/blob/main/LICENSE) |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `none``low``high` (default)`max` |
| Vision | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.30 per M input tokens, $1.20 per M output tokens, $0.006 per M cached input tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/deepseek-ai/deepseek-v4.1-flash-1017)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/deepseek-ai/deepseek-v4.1-flash-1017", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/deepseek-ai/deepseek-v4.1-flash-1017", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/deepseek-ai/deepseek-v4.1-flash-1017",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/deepseek-ai/deepseek-v4.1-flash-1017 \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, low, noneReasoning effort. Supported levels: max, high, low, none. Compatibility aliases: auto maps to high; minimal maps to none; medium maps to high; xhigh maps to max.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, low, noneReasoning effort. Supported levels: max, high, low, none. Compatibility aliases: auto maps to high; minimal maps to none; medium maps to high; xhigh maps to max.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/#page","headline":"deepseek-v4.1-flash-1017","description":"We introduce DeepSeek-V4.1-Flash, a multimodal Mixture-of-Experts (MoE) model with 552B backbone parameters and support for contexts of up to one million tokens. The model natively processes images and text, and generates text autoregressively.","url":"https://developers.cloudflare.com/workers-ai/models/deepseek-v4.1-flash-1017/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: EmbeddingGemma is a 300M parameter, state-of-the-art for its size, open embedding model from Google, built from Gemma 3 (with T5Gemma initialization) and the same research and technology used to create Gemini models. EmbeddingGemma produces vector representations of text, making it well-suited for search and retrieval tasks, including classification, clustering, and semantic similarity search. This model was trained with data in 100+ spoken languages.
title: embeddinggemma-300m
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Google logo](https://developers.cloudflare.com/_astro/google.DyXKPTPP.svg)

# embeddinggemma-300m

Beta

Text Embeddings • Google

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/embeddinggemma-300m/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/google/embeddinggemma-300m` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

EmbeddingGemma is a 300M parameter, state-of-the-art for its size, open embedding model from Google, built from Gemma 3 (with T5Gemma initialization) and the same research and technology used to create Gemini models. EmbeddingGemma produces vector representations of text, making it well-suited for search and retrieval tasks, including classification, clustering, and semantic similarity search. This model was trained with data in 100+ spoken languages.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Zero data retention | Yes |
| Beta | Yes |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    // Can be a string or array of strings]
    const stories = [
      "This is a story about an orange cloud",
      "This is a story about a llama",
      "This is a story about a hugging emoji",
    ];

    const embeddings = await env.AI.run(
      "@cf/google/embeddinggemma-300m",
      {
        text: stories,
      }
    );

    return Response.json(embeddings);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests


ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

stories = [
  'This is a story about an orange cloud',
  'This is a story about a llama',
  'This is a story about a hugging emoji'
]

response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/google/embeddinggemma-300m",
  headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
  json={"text": stories}
)

print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/google/embeddinggemma-300m  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "text": ["This is a story about an orange cloud", "This is a story about a llama", "This is a story about a hugging emoji"] }'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/).

## Parameters

▶text

`one of`required

▶shape\[]

`array`

▶data\[]

`array`Embeddings of the requested text values

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/embeddinggemma-300m/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/embeddinggemma-300m/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/embeddinggemma-300m/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/embeddinggemma-300m/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/embeddinggemma-300m/#page","headline":"embeddinggemma-300m","description":"EmbeddingGemma is a 300M parameter, state-of-the-art for its size, open embedding model from Google, built from Gemma 3 (with T5Gemma initialization) and the same research and technology used to create Gemini models. EmbeddingGemma produces vector representations of text, making it well-suited for search and retrieval tasks, including classification, clustering, and semantic similarity search. This model was trained with data in 100+ spoken languages.","url":"https://developers.cloudflare.com/workers-ai/models/embeddinggemma-300m/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: This is a Gemma-2B base model that Cloudflare dedicates for inference with LoRA adapters. Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models.
title: gemma-2b-it-lora
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Google logo](https://developers.cloudflare.com/_astro/google.DyXKPTPP.svg)

# gemma-2b-it-lora

Beta

Text Generation • Google

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/google/gemma-2b-it-lora` Copy

- Cloudflare-hosted
- LoRA
- Planned deprecation
- Zero data retention

This is a Gemma-2B base model that Cloudflare dedicates for inference with LoRA adapters. Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 8,192 tokens |
| Zero data retention | Yes |
| LoRA | Yes |
| Beta | Yes |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/google/gemma-2b-it-lora)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/google/gemma-2b-it-lora", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/google/gemma-2b-it-lora", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/google/gemma-2b-it-lora",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/google/gemma-2b-it-lora \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/#page","headline":"gemma-2b-it-lora","description":"This is a Gemma-2B base model that Cloudflare dedicates for inference with LoRA adapters. Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models.","url":"https://developers.cloudflare.com/workers-ai/models/gemma-2b-it-lora/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Gemma 4 is Google's most intelligent family of open models, built from Gemini 3 research to maximize intelligence-per-parameter.
title: gemma-4-26b-a4b-it
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Google logo](https://developers.cloudflare.com/_astro/google.DyXKPTPP.svg)

# gemma-4-26b-a4b-it

Text Generation • Google

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/google/gemma-4-26b-a4b-it` Copy

- Cloudflare-hosted
- Batch
- Function calling
- Reasoning
- Vision
- Zero data retention

Gemma 4 is Google's most intelligent family of open models, built from Gemini 3 research to maximize intelligence-per-parameter.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 256,000 tokens |
| Terms and License | [link ↗](https://ai.google.dev/gemma/docs/gemma_4_license) |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | Yes |
| Vision | Yes |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.10 per M input tokens, $0.30 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/google/gemma-4-26b-a4b-it)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/google/gemma-4-26b-a4b-it", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/google/gemma-4-26b-a4b-it", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/google/gemma-4-26b-a4b-it",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/google/gemma-4-26b-a4b-it \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

skip\_special\_tokens

<code>boolean</code>default: false

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

skip\_special\_tokens

<code>boolean</code>default: false

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/#page","headline":"gemma-4-26b-a4b-it","description":"Gemma 4 is Google's most intelligent family of open models, built from Gemini 3 research to maximize intelligence-per-parameter.","url":"https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "  This is a Gemma-7B base model that Cloudflare dedicates for inference with LoRA adapters. Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models."
title: gemma-7b-it-lora
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Google logo](https://developers.cloudflare.com/_astro/google.DyXKPTPP.svg)

# gemma-7b-it-lora

Beta

Text Generation • Google

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/google/gemma-7b-it-lora` Copy

- Cloudflare-hosted
- LoRA
- Planned deprecation
- Zero data retention

This is a Gemma-7B base model that Cloudflare dedicates for inference with LoRA adapters. Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 3,500 tokens |
| Zero data retention | Yes |
| LoRA | Yes |
| Beta | Yes |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/google/gemma-7b-it-lora)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/google/gemma-7b-it-lora", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/google/gemma-7b-it-lora", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/google/gemma-7b-it-lora",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/google/gemma-7b-it-lora \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/#page","headline":"gemma-7b-it-lora","description":"This is a Gemma-7B base model that Cloudflare dedicates for inference with LoRA adapters. Gemma is a family of lightweight, state-of-the-art open models from Google, built from the same research and technology used to create the Gemini models.","url":"https://developers.cloudflare.com/workers-ai/models/gemma-7b-it-lora/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Distilled BERT model that was finetuned on SST-2 for sentiment classification
title: distilbert-sst-2-int8
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![HuggingFace logo](https://developers.cloudflare.com/_astro/huggingface.DMS-v5TA.svg)

# distilbert-sst-2-int8

Text Classification • HuggingFace

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/distilbert-sst-2-int8/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/huggingface/distilbert-sst-2-int8` Copy

- Cloudflare-hosted
- Zero data retention

Distilled BERT model that was finetuned on SST-2 for sentiment classification

| Model Info | |
| --- | --- |
| More information | [link ↗](https://huggingface.co/Intel/distilbert-base-uncased-finetuned-sst-2-english-int8-static) |
| Zero data retention | Yes |
| Unit Pricing | $0.0263 per M input tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const response = await env.AI.run(
      "@cf/huggingface/distilbert-sst-2-int8",
      {
        text: "This pizza is great!",
      }
    );

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
API_BASE_URL = "https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/"
headers = {"Authorization": "Bearer {API_KEY}"}

def run(model, input):
    response = requests.post(f"{API_BASE_URL}{model}", headers=headers, json=input)
    return response.json()

output = run("@cf/huggingface/distilbert-sst-2-int8", { "text": "This pizza is great!" })
print(output)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/huggingface/distilbert-sst-2-int8  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "text": "This pizza is great!" }'
```

## Parameters

text

`string`requiredminLength: 1The text that you want to classify

type

`array`

contentType

`application/json`

description

`An array of classification results for the input text`

items

`[object Object]`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/distilbert-sst-2-int8/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/distilbert-sst-2-int8/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/distilbert-sst-2-int8/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/distilbert-sst-2-int8/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/distilbert-sst-2-int8/#page","headline":"distilbert-sst-2-int8","description":"Distilled BERT model that was finetuned on SST-2 for sentiment classification","url":"https://developers.cloudflare.com/workers-ai/models/distilbert-sst-2-int8/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Granite 4.0 instruct models deliver strong performance across benchmarks, achieving industry-leading results in key agentic tasks like instruction following and function calling. These efficiencies make the models well-suited for a wide range of use cases like retrieval-augmented generation (RAG), multi-agent workflows, and edge deployments.
title: granite-4.0-h-micro
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![IBM logo](https://developers.cloudflare.com/_astro/ibm.CYdLt4EI.svg)

# granite-4.0-h-micro

Text Generation • IBM

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/ibm-granite/granite-4.0-h-micro` Copy

- Cloudflare-hosted
- Function calling
- Zero data retention

Granite 4.0 instruct models deliver strong performance across benchmarks, achieving industry-leading results in key agentic tasks like instruction following and function calling. These efficiencies make the models well-suited for a wide range of use cases like retrieval-augmented generation (RAG), multi-agent workflows, and edge deployments.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 131,000 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.017 per M input tokens, $0.112 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/ibm-granite/granite-4.0-h-micro)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/ibm-granite/granite-4.0-h-micro", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/ibm-granite/granite-4.0-h-micro", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/ibm-granite/granite-4.0-h-micro",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/ibm-granite/granite-4.0-h-micro \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/#page","headline":"granite-4.0-h-micro","description":"Granite 4.0 instruct models deliver strong performance across benchmarks, achieving industry-leading results in key agentic tasks like instruction following and function calling. These efficiencies make the models well-suited for a wide range of use cases like retrieval-augmented generation (RAG), multi-agent workflows, and edge deployments.","url":"https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "Lucid Origin from Leonardo.AI is their most adaptable and prompt-responsive model to date. Whether you're generating images with sharp graphic design, stunning full-HD renders, or highly specific creative direction, it adheres closely to your prompts, renders text with accuracy, and supports a wide array of visual styles and aesthetics – from stylized concept art to crisp product mockups.\n"
title: lucid-origin
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Leonardo logo](https://developers.cloudflare.com/_astro/leonardo.JZysY-g3.svg)

# lucid-origin

Text-to-Image • Leonardo

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/lucid-origin/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/leonardo/lucid-origin` Copy

- Cloudflare-hosted
- Partner
- Zero data retention

Lucid Origin from Leonardo.AI is their most adaptable and prompt-responsive model to date. Whether you're generating images with sharp graphic design, stunning full-HD renders, or highly specific creative direction, it adheres closely to your prompts, renders text with accuracy, and supports a wide array of visual styles and aesthetics – from stylized concept art to crisp product mockups.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://leonardo.ai/terms-of-service/) |
| Zero data retention | Yes |
| Partner | Yes |
| Unit Pricing | $0.007 per 512 by 512 tile, $0.000132 per step |

## Parameters

prompt

`string`requiredminLength: 1A text description of the image you want to generate.

guidance

`number`default: 4.5minimum: 0maximum: 10Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt

seed

`integer`minimum: 0Random seed for reproducibility of the image generation

height

`integer`default: 1120minimum: 0maximum: 2500The height of the generated image in pixels

width

`integer`default: 1120minimum: 0maximum: 2500The width of the generated image in pixels

num\_steps

`integer`minimum: 1maximum: 40The number of diffusion steps; higher values can improve quality but take longer

steps

`integer`minimum: 1maximum: 40The number of diffusion steps; higher values can improve quality but take longer

image

`string`The generated image in Base64 format.

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/lucid-origin/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/lucid-origin/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/lucid-origin/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/lucid-origin/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/lucid-origin/#page","headline":"lucid-origin","description":"Lucid Origin from Leonardo.AI is their most adaptable and prompt-responsive model to date. Whether you're generating images with sharp graphic design, stunning full-HD renders, or highly specific creative direction, it adheres closely to your prompts, renders text with accuracy, and supports a wide array of visual styles and aesthetics – from stylized concept art to crisp product mockups.","url":"https://developers.cloudflare.com/workers-ai/models/lucid-origin/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Phoenix 1.0 is a model by Leonardo.Ai that generates images with exceptional prompt adherence and coherent text.
title: phoenix-1.0
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Leonardo logo](https://developers.cloudflare.com/_astro/leonardo.JZysY-g3.svg)

# phoenix-1.0

Text-to-Image • Leonardo

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/phoenix-1.0/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/leonardo/phoenix-1.0` Copy

- Cloudflare-hosted
- Partner
- Zero data retention

Phoenix 1.0 is a model by Leonardo.Ai that generates images with exceptional prompt adherence and coherent text.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://leonardo.ai/terms-of-service/) |
| Zero data retention | Yes |
| Partner | Yes |
| Unit Pricing | $0.00583 per 512 by 512 tile, $0.00011 per step |

## Parameters

prompt

`string`requiredminLength: 1A text description of the image you want to generate.

guidance

`number`default: 2minimum: 2maximum: 10Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt

seed

`integer`minimum: 0Random seed for reproducibility of the image generation

height

`integer`default: 1024minimum: 0maximum: 2048The height of the generated image in pixels

width

`integer`default: 1024minimum: 0maximum: 2048The width of the generated image in pixels

num\_steps

`integer`default: 25minimum: 1maximum: 50The number of diffusion steps; higher values can improve quality but take longer

negative\_prompt

`string`minLength: 1Specify what to exclude from the generated images

The binding returns a `ReadableStream` with the output (check the model's output schema).

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/phoenix-1.0/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/phoenix-1.0/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/phoenix-1.0/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/phoenix-1.0/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/phoenix-1.0/#page","headline":"phoenix-1.0","description":"Phoenix 1.0 is a model by Leonardo.Ai that generates images with exceptional prompt adherence and coherent text.","url":"https://developers.cloudflare.com/workers-ai/models/phoenix-1.0/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: LLaVA is an open-source chatbot trained by fine-tuning LLaMA/Vicuna on GPT-generated multimodal instruction-following data. It is an auto-regressive language model, based on the transformer architecture.
title: llava-1.5-7b-hf
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

l

# llava-1.5-7b-hf

Beta

Image-to-Text • llava-hf

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/llava-hf/llava-1.5-7b-hf` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

LLaVA is an open-source chatbot trained by fine-tuning LLaMA/Vicuna on GPT-generated multimodal instruction-following data. It is an auto-regressive language model, based on the transformer architecture.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Zero data retention | Yes |
| Beta | Yes |

## Parameters

Option 1

stringformat: binary

Binary string representing the image contents.

▶Option 2{}

object

description

`string`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/#page","headline":"llava-1.5-7b-hf","description":"LLaVA is an open-source chatbot trained by fine-tuning LLaMA/Vicuna on GPT-generated multimodal instruction-following data. It is an auto-regressive language model, based on the transformer architecture.","url":"https://developers.cloudflare.com/workers-ai/models/llava-1.5-7b-hf/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Stable Diffusion model that has been fine-tuned to be better at photorealism without sacrificing range.
title: dreamshaper-8-lcm
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

l

# dreamshaper-8-lcm

Text-to-Image • lykon

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/lykon/dreamshaper-8-lcm` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

Stable Diffusion model that has been fine-tuned to be better at photorealism without sacrificing range.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| More information | [link ↗](https://huggingface.co/Lykon/DreamShaper) |
| Zero data retention | Yes |

## Parameters

prompt

`string`requiredminLength: 1A text description of the image you want to generate

negative\_prompt

`string`Text describing elements to avoid in the generated image

height

`integer`minimum: 256maximum: 2048The height of the generated image in pixels

width

`integer`minimum: 256maximum: 2048The width of the generated image in pixels

▶image\[]

`array`For use with img2img tasks. An array of integers that represent the image data constrained to 8-bit unsigned integer values

image\_b64

`string`For use with img2img tasks. A base64-encoded string of the input image

▶mask\[]

`array`An array representing An array of integers that represent mask image data for inpainting constrained to 8-bit unsigned integer values

num\_steps

`integer`default: 20maximum: 20The number of diffusion steps; higher values can improve quality but take longer

strength

`number`default: 1A value between 0 and 1 indicating how strongly to apply the transformation during img2img tasks; lower values make the output closer to the input image

guidance

`number`default: 7.5Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt

seed

`integer`Random seed for reproducibility of the image generation

The binding returns a `ReadableStream` with the output (check the model's output schema).

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/#page","headline":"dreamshaper-8-lcm","description":"Stable Diffusion model that has been fine-tuned to be better at photorealism without sacrificing range.","url":"https://developers.cloudflare.com/workers-ai/models/dreamshaper-8-lcm/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "This is a Llama2 base model that Cloudflare dedicated for inference with LoRA adapters. Llama 2 is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 7B fine-tuned model, optimized for dialogue use cases and converted for the Hugging Face Transformers format. "
title: llama-2-7b-chat-hf-lora
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)

# llama-2-7b-chat-hf-lora

Beta

Text Generation • Meta

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/meta-llama/llama-2-7b-chat-hf-lora` Copy

- Cloudflare-hosted
- LoRA
- Planned deprecation
- Zero data retention

This is a Llama2 base model that Cloudflare dedicated for inference with LoRA adapters. Llama 2 is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 7B fine-tuned model, optimized for dialogue use cases and converted for the Hugging Face Transformers format.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 8,192 tokens |
| Zero data retention | Yes |
| LoRA | Yes |
| Beta | Yes |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/meta-llama/llama-2-7b-chat-hf-lora)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/meta-llama/llama-2-7b-chat-hf-lora", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/meta-llama/llama-2-7b-chat-hf-lora", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta-llama/llama-2-7b-chat-hf-lora",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta-llama/llama-2-7b-chat-hf-lora \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/#page","headline":"llama-2-7b-chat-hf-lora","description":"This is a Llama2 base model that Cloudflare dedicated for inference with LoRA adapters. Llama 2 is a collection of pretrained and fine-tuned generative text models ranging in scale from 7 billion to 70 billion parameters. This is the repository for the 7B fine-tuned model, optimized for dialogue use cases and converted for the Hugging Face Transformers format.","url":"https://developers.cloudflare.com/workers-ai/models/llama-2-7b-chat-hf-lora/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Llama 3.1 8B quantized to FP8 precision
title: llama-3.1-8b-instruct-fp8
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)

# llama-3.1-8b-instruct-fp8

Text Generation • Meta

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/meta/llama-3.1-8b-instruct-fp8` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

Llama 3.1 8B quantized to FP8 precision

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 32,000 tokens |
| Terms and License | [link ↗](https://github.com/meta-llama/llama-models/blob/main/models/llama3_1/LICENSE) |
| Zero data retention | Yes |
| Unit Pricing | $0.152 per M input tokens, $0.287 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/meta/llama-3.1-8b-instruct-fp8)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/meta/llama-3.1-8b-instruct-fp8", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/meta/llama-3.1-8b-instruct-fp8", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta/llama-3.1-8b-instruct-fp8",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/llama-3.1-8b-instruct-fp8 \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/#page","headline":"llama-3.1-8b-instruct-fp8","description":"Llama 3.1 8B quantized to FP8 precision","url":"https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct-fp8/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: " The Llama 3.2-Vision instruction-tuned models are optimized for visual recognition, image reasoning, captioning, and answering general questions about an image."
title: llama-3.2-11b-vision-instruct
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)

# llama-3.2-11b-vision-instruct

Text Generation • Meta

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/meta/llama-3.2-11b-vision-instruct` Copy

- Cloudflare-hosted
- LoRA
- Vision
- Zero data retention

The Llama 3.2-Vision instruction-tuned models are optimized for visual recognition, image reasoning, captioning, and answering general questions about an image.

Note

To use Llama 3.2 11b Vision Instruct, you need to agree to the [Meta License](https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/LICENSE) and [Acceptable Use Policy](https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/USE_POLICY.md). To do so, please send an initial request to`@cf/meta/llama-3.2-11b-vision-instruct` with`"prompt" : "agree"`. After that, you'll be able to use the model as normal.

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/llama-3.2-11b-vision-instruct \
   -X POST \
   -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
   -d '{ "prompt": "agree"}'
```

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 128,000 tokens |
| Terms and License | [link ↗](https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/LICENSE) |
| Vision | Yes |
| Zero data retention | Yes |
| LoRA | Yes |
| Unit Pricing | $0.0485 per M input tokens, $0.676 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/meta/llama-3.2-11b-vision-instruct)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/meta/llama-3.2-11b-vision-instruct", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/meta/llama-3.2-11b-vision-instruct", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta/llama-3.2-11b-vision-instruct",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/llama-3.2-11b-vision-instruct \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1maxLength: 131072The input text prompt for the model to generate a response.

▶image

`one of`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0maximum: 2Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: 0maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: 0maximum: 2Increases the likelihood of the model introducing new topics.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/#page","headline":"llama-3.2-11b-vision-instruct","description":"The Llama 3.2-Vision instruction-tuned models are optimized for visual recognition, image reasoning, captioning, and answering general questions about an image.","url":"https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: The Llama 3.2 instruction-tuned text only models are optimized for multilingual dialogue use cases, including agentic retrieval and summarization tasks.
title: llama-3.2-1b-instruct
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)

# llama-3.2-1b-instruct

Text Generation • Meta

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/meta/llama-3.2-1b-instruct` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

The Llama 3.2 instruction-tuned text only models are optimized for multilingual dialogue use cases, including agentic retrieval and summarization tasks.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 60,000 tokens |
| Terms and License | [link ↗](https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/LICENSE) |
| Zero data retention | Yes |
| Unit Pricing | $0.027 per M input tokens, $0.201 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/meta/llama-3.2-1b-instruct)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/meta/llama-3.2-1b-instruct", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/meta/llama-3.2-1b-instruct", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta/llama-3.2-1b-instruct",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/llama-3.2-1b-instruct \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/#page","headline":"llama-3.2-1b-instruct","description":"The Llama 3.2 instruction-tuned text only models are optimized for multilingual dialogue use cases, including agentic retrieval and summarization tasks.","url":"https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: The Llama 3.2 instruction-tuned text only models are optimized for multilingual dialogue use cases, including agentic retrieval and summarization tasks.
title: llama-3.2-3b-instruct
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)

# llama-3.2-3b-instruct

Text Generation • Meta

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/meta/llama-3.2-3b-instruct` Copy

- Cloudflare-hosted
- LoRA
- Planned deprecation
- Zero data retention

The Llama 3.2 instruction-tuned text only models are optimized for multilingual dialogue use cases, including agentic retrieval and summarization tasks.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 80,000 tokens |
| Terms and License | [link ↗](https://github.com/meta-llama/llama-models/blob/main/models/llama3_2/LICENSE) |
| Zero data retention | Yes |
| LoRA | Yes |
| Unit Pricing | $0.0509 per M input tokens, $0.335 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/meta/llama-3.2-3b-instruct)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/meta/llama-3.2-3b-instruct", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/meta/llama-3.2-3b-instruct", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta/llama-3.2-3b-instruct",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/llama-3.2-3b-instruct \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/#page","headline":"llama-3.2-3b-instruct","description":"The Llama 3.2 instruction-tuned text only models are optimized for multilingual dialogue use cases, including agentic retrieval and summarization tasks.","url":"https://developers.cloudflare.com/workers-ai/models/llama-3.2-3b-instruct/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Llama 3.3 70B quantized to fp8 precision, optimized to be faster.
title: llama-3.3-70b-instruct-fp8-fast
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)

# llama-3.3-70b-instruct-fp8-fast

Text Generation • Meta

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/meta/llama-3.3-70b-instruct-fp8-fast` Copy

- Cloudflare-hosted
- Batch
- Function calling
- Zero data retention

Llama 3.3 70B quantized to fp8 precision, optimized to be faster.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 24,000 tokens |
| Terms and License | [link ↗](https://github.com/meta-llama/llama-models/blob/main/models/llama3_3/LICENSE) |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.293 per M input tokens, $2.253 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/meta/llama-3.3-70b-instruct-fp8-fast)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/meta/llama-3.3-70b-instruct-fp8-fast", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/meta/llama-3.3-70b-instruct-fp8-fast", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta/llama-3.3-70b-instruct-fp8-fast",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/llama-3.3-70b-instruct-fp8-fast \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 256The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 256The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/#page","headline":"llama-3.3-70b-instruct-fp8-fast","description":"Llama 3.3 70B quantized to fp8 precision, optimized to be faster.","url":"https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Meta's Llama 4 Scout is a 17 billion parameter model with 16 experts that is natively multimodal. These models leverage a mixture-of-experts architecture to offer industry-leading performance in text and image understanding.
title: llama-4-scout-17b-16e-instruct
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)

# llama-4-scout-17b-16e-instruct

Text Generation • Meta

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/meta/llama-4-scout-17b-16e-instruct` Copy

- Cloudflare-hosted
- Batch
- Function calling
- Vision
- Zero data retention

Meta's Llama 4 Scout is a 17 billion parameter model with 16 experts that is natively multimodal. These models leverage a mixture-of-experts architecture to offer industry-leading performance in text and image understanding.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 131,000 tokens |
| Terms and License | [link ↗](https://github.com/meta-llama/llama-models/blob/main/models/llama4/LICENSE) |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Vision | Yes |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.27 per M input tokens, $0.85 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/meta/llama-4-scout-17b-16e-instruct)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/meta/llama-4-scout-17b-16e-instruct", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/meta/llama-4-scout-17b-16e-instruct", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta/llama-4-scout-17b-16e-instruct",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/llama-4-scout-17b-16e-instruct \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

guided\_json{}

<code>object</code>JSON schema that should be fulfilled for the response.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 256The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.15minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0maximum: 2Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: 0maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: 0maximum: 2Increases the likelihood of the model introducing new topics.

response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

guided\_json{}

<code>object</code>JSON schema that should be fulfilled for the response.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 256The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.15minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0maximum: 2Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: 0maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: 0maximum: 2Increases the likelihood of the model introducing new topics.

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>required

response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/#page","headline":"llama-4-scout-17b-16e-instruct","description":"Meta's Llama 4 Scout is a 17 billion parameter model with 16 experts that is natively multimodal. These models leverage a mixture-of-experts architecture to offer industry-leading performance in text and image understanding.","url":"https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Llama Guard 3 is a Llama-3.1-8B pretrained model, fine-tuned for content safety classification. Similar to previous versions, it can be used to classify content in both LLM inputs (prompt classification) and in LLM responses (response classification). It acts as an LLM – it generates text in its output that indicates whether a given prompt or response is safe or unsafe, and if unsafe, it also lists the content categories violated.
title: llama-guard-3-8b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)

# llama-guard-3-8b

Text Generation • Meta

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/llama-guard-3-8b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/meta/llama-guard-3-8b` Copy

- Cloudflare-hosted
- LoRA
- Zero data retention

Llama Guard 3 is a Llama-3.1-8B pretrained model, fine-tuned for content safety classification. Similar to previous versions, it can be used to classify content in both LLM inputs (prompt classification) and in LLM responses (response classification). It acts as an LLM – it generates text in its output that indicates whether a given prompt or response is safe or unsafe, and if unsafe, it also lists the content categories violated.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 131,072 tokens |
| Zero data retention | Yes |
| LoRA | Yes |
| Unit Pricing | $0.484 per M input tokens, $0.03 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/meta/llama-guard-3-8b)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/meta/llama-guard-3-8b", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/meta/llama-guard-3-8b", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/meta/llama-guard-3-8b",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/llama-guard-3-8b \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

▶messages\[]

`array`requiredAn array of message objects representing the conversation history.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

▶response\_format{}

`object`Dictate the output format of the generated response.

▶response

`one of`

▶usage{}

`object`Usage statistics for the inference request

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/llama-guard-3-8b/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-guard-3-8b/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/llama-guard-3-8b/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/llama-guard-3-8b/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/llama-guard-3-8b/#page","headline":"llama-guard-3-8b","description":"Llama Guard 3 is a Llama-3.1-8B pretrained model, fine-tuned for content safety classification. Similar to previous versions, it can be used to classify content in both LLM inputs (prompt classification) and in LLM responses (response classification). It acts as an LLM – it generates text in its output that indicates whether a given prompt or response is safe or unsafe, and if unsafe, it also lists the content categories violated.","url":"https://developers.cloudflare.com/workers-ai/models/llama-guard-3-8b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many multilingual translation
title: m2m100-1.2b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Meta logo](https://developers.cloudflare.com/_astro/meta.CTzB_ysm.svg)

# m2m100-1.2b

Translation • Meta

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/meta/m2m100-1.2b` Copy

- Cloudflare-hosted
- Batch
- Zero data retention

Multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many multilingual translation

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://github.com/facebookresearch/fairseq/blob/main/LICENSE) |
| More information | [link ↗](https://github.com/facebookresearch/fairseq/tree/main/examples/m2m_100) |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.342 per M input tokens, $0.342 per M output tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const response = await env.AI.run(
      "@cf/meta/m2m100-1.2b",
      {
        text: "I'll have an order of the moule frites",
        source_lang: "english", // defaults to english
        target_lang: "french",
      }
    );

    return new Response(JSON.stringify(response));
  },
} satisfies ExportedHandler<Env>;
```

```py
import requests

API_BASE_URL = "https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/"
headers = {"Authorization": "Bearer {API_TOKEN}"}

def run(model, input):
    response = requests.post(f"{API_BASE_URL}{model}", headers=headers, json=input)
    return response.json()

output = run('@cf/meta/m2m100-1.2b', {
  "text": "I'll have an order of the moule frites",
  "source_lang": "english",
  "target_lang": "french"
})

print(output)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/m2m100-1.2b  \
    -X POST  \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
    -d '{ "text": "Ill have an order of the moule frites", "source_lang": "english", "target_lang": "french" }'
```

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



text

<code>string</code>requiredminLength: 1The text to be translated

source\_lang

<code>string</code>default: enThe language code of the source text (e.g., 'en' for English). Defaults to 'en' if not specified

target\_lang

<code>string</code>requiredThe language code to translate the text into (e.g., 'es' for Spanish)

request\_id

<code>string</code>The async request id that can be used to obtain the results.

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>requiredBatch of the embeddings requests to run using async-queue

request\_id

<code>string</code>The async request id that can be used to obtain the results.

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/sync-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/#page","headline":"m2m100-1.2b","description":"Multilingual encoder-decoder (seq-to-seq) model trained for Many-to-Many multilingual translation","url":"https://developers.cloudflare.com/workers-ai/models/m2m100-1.2b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: 50 layers deep image classification CNN trained on more than 1M images from ImageNet
title: resnet-50
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Microsoft logo](https://developers.cloudflare.com/_astro/microsoft.LujcDJ--.svg)

# resnet-50

Image Classification • Microsoft

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/resnet-50/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/microsoft/resnet-50` Copy

- Cloudflare-hosted
- Zero data retention

50 layers deep image classification CNN trained on more than 1M images from ImageNet

| Model Info | |
| --- | --- |
| More information | [link ↗](https://www.microsoft.com/en-us/research/blog/microsoft-vision-model-resnet-50-combines-web-scale-data-and-multi-task-learning-to-achieve-state-of-the-art/) |
| Zero data retention | Yes |
| Unit Pricing | $0.00000251 per inference request |

## Parameters

Option 1

stringformat: binary

The image to classify

▶Option 2{}

object

type

`array`

contentType

`application/json`

items

`[object Object]`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/resnet-50/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/resnet-50/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/resnet-50/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/resnet-50/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/resnet-50/#page","headline":"resnet-50","description":"50 layers deep image classification CNN trained on more than 1M images from ImageNet","url":"https://developers.cloudflare.com/workers-ai/models/resnet-50/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: The Mistral-7B-Instruct-v0.2 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.2.
title: mistral-7b-instruct-v0.2-lora
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![MistralAI logo](https://developers.cloudflare.com/_astro/mistralai.Bn9UMUMu.svg)

# mistral-7b-instruct-v0.2-lora

Text Generation • MistralAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/mistral/mistral-7b-instruct-v0.2-lora` Copy

- Cloudflare-hosted
- LoRA
- Zero data retention

The Mistral-7B-Instruct-v0.2 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.2.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 15,000 tokens |
| Zero data retention | Yes |
| LoRA | Yes |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/mistral/mistral-7b-instruct-v0.2-lora)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/mistral/mistral-7b-instruct-v0.2-lora", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/mistral/mistral-7b-instruct-v0.2-lora", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/mistral/mistral-7b-instruct-v0.2-lora",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/mistral/mistral-7b-instruct-v0.2-lora \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/#page","headline":"mistral-7b-instruct-v0.2-lora","description":"The Mistral-7B-Instruct-v0.2 Large Language Model (LLM) is an instruct fine-tuned version of the Mistral-7B-v0.2.","url":"https://developers.cloudflare.com/workers-ai/models/mistral-7b-instruct-v0.2-lora/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Building upon Mistral Small 3 (2501), Mistral Small 3.1 (2503) adds state-of-the-art vision understanding and enhances long context capabilities up to 128k tokens without compromising text performance. With 24 billion parameters, this model achieves top-tier capabilities in both text and vision tasks.
title: mistral-small-3.1-24b-instruct
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![MistralAI logo](https://developers.cloudflare.com/_astro/mistralai.Bn9UMUMu.svg)

# mistral-small-3.1-24b-instruct

Text Generation • MistralAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/mistralai/mistral-small-3.1-24b-instruct` Copy

- Cloudflare-hosted
- Function calling
- Zero data retention

Building upon Mistral Small 3 (2501), Mistral Small 3.1 (2503) adds state-of-the-art vision understanding and enhances long context capabilities up to 128k tokens without compromising text performance. With 24 billion parameters, this model achieves top-tier capabilities in both text and vision tasks.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 128,000 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.351 per M input tokens, $0.555 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/mistralai/mistral-small-3.1-24b-instruct)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/mistralai/mistral-small-3.1-24b-instruct", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/mistralai/mistral-small-3.1-24b-instruct", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/mistralai/mistral-small-3.1-24b-instruct",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/mistralai/mistral-small-3.1-24b-instruct \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

guided\_json{}

`object`JSON schema that should be fulfilled for the response.

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.15minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0maximum: 2Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: 0maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: 0maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/#page","headline":"mistral-small-3.1-24b-instruct","description":"Building upon Mistral Small 3 (2501), Mistral Small 3.1 (2503) adds state-of-the-art vision understanding and enhances long context capabilities up to 128k tokens without compromising text performance. With 24 billion parameters, this model achieves top-tier capabilities in both text and vision tasks.","url":"https://developers.cloudflare.com/workers-ai/models/mistral-small-3.1-24b-instruct/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Moondream 3 is a fast, efficient 9B mixture-of-experts vision language model (2B active parameters) that delivers frontier-level visual reasoning for tasks like object detection, pointing, OCR, and structured output.
title: moondream3.1-9B-A2B
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

m

# moondream3.1-9B-A2B

Image-to-Text • moondream

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/moondream3.1-9B-A2B/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/moondream/moondream3.1-9B-A2B` Copy

- Cloudflare-hosted
- Vision
- Zero data retention

Moondream 3 is a fast, efficient 9B mixture-of-experts vision language model (2B active parameters) that delivers frontier-level visual reasoning for tasks like object detection, pointing, OCR, and structured output.

| Model Info | |
| --- | --- |
| Terms and License | [link ↗](https://moondream.ai/licenses/model/1.0) |
| Vision | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.30 per M input tokens, $1.00 per M output tokens |

## Parameters

task

`string`default: queryenum: query, caption, point, detectWhich Moondream skill to run.

image

`string`Input image as a public HTTPS URL or base64 data URI. Optional for \`query\`; required for \`caption\`, \`point\`, and \`detect\`.

question

`string`default: What's in this image?Question for the \`query\` task.

caption\_length

`string`default: normalenum: short, normal, longCaption length for the \`caption\` task.

target

`string`default: personObject phrase to locate for \`point\` and \`detect\` tasks (e.g. 'person wearing a red shirt').

reasoning

`boolean`default: trueEnable reasoning trace for the \`query\` task.

temperature

`number`default: 0.2minimum: 0maximum: 2Sampling temperature.

top\_p

`number`default: 0.9minimum: 0maximum: 1Top-p (nucleus) sampling.

max\_tokens

`integer`default: 8192minimum: 1maximum: 28672Max tokens to generate for \`query\` and \`caption\`.

max\_objects

`integer`default: 150minimum: 1maximum: 500Max objects to return for \`point\` and \`detect\`.

stream

`boolean`default: falseReturn incremental tokens for \`query\` and \`caption\`. \`point\` and \`detect\` do not support streaming.

finish\_reason

`string`Reason the generation finished.

▶metrics{}

`object`

answer

`string`Answer text for the \`query\` task. Null for other tasks.

caption

`string`Caption text for the \`caption\` task. Null for other tasks.

▶points\[]

`array`Located points for the \`point\` task. Null for other tasks.

▶objects\[]

`array`Detected bounding boxes for the \`detect\` task. Null for other tasks.

▶reasoning{}

`object`Reasoning trace for the \`query\` task when reasoning=true. Null otherwise.

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/moondream3.1-9B-A2B/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/moondream3.1-9B-A2B/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/moondream3.1-9B-A2B/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/moondream3.1-9B-A2B/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/moondream3.1-9B-A2B/#page","headline":"moondream3.1-9B-A2B","description":"Moondream 3 is a fast, efficient 9B mixture-of-experts vision language model (2B active parameters) that delivers frontier-level visual reasoning for tasks like object detection, pointing, OCR, and structured output.","url":"https://developers.cloudflare.com/workers-ai/models/moondream3.1-9B-A2B/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Kimi K2.6 is a frontier-scale open-source 1T parameter model with a 262.1k context window, multi-turn tool calling, vision inputs, and structured outputs for agentic workloads.
title: kimi-k2.6
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Moonshot AI logo](https://developers.cloudflare.com/_astro/moonshotai.DjWMkXUS.svg)

# kimi-k2.6

Text Generation • Moonshot AI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/moonshotai/kimi-k2.6` Copy

- Cloudflare-hosted
- Batch
- Function calling
- Reasoning
- Vision
- Planned deprecation
- Zero data retention

Kimi K2.6 is a frontier-scale open-source 1T parameter model with a 262.1k context window, multi-turn tool calling, vision inputs, and structured outputs for agentic workloads.

Paid access required

This model is not available through standard Workers Free billing. To use it, upgrade to the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) or use prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/).

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 262,144 tokens |
| Terms and License | [link ↗](https://huggingface.co/moonshotai/Kimi-K2.6/blob/main/LICENSE) |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `none``high` (default) |
| Vision | Yes |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.95 per M input tokens, $4.00 per M output tokens, $0.16 per M cached input tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/moonshotai/kimi-k2.6)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/moonshotai/kimi-k2.6", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/moonshotai/kimi-k2.6", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/moonshotai/kimi-k2.6",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/moonshotai/kimi-k2.6 \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: high, noneReasoning effort. Supported levels: high, none. Compatibility aliases: low maps to high; medium maps to high; max maps to high.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: high, noneReasoning effort. Supported levels: high, none. Compatibility aliases: low maps to high; medium maps to high; max maps to high.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/#page","headline":"kimi-k2.6","description":"Kimi K2.6 is a frontier-scale open-source 1T parameter model with a 262.1k context window, multi-turn tool calling, vision inputs, and structured outputs for agentic workloads.","url":"https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Kimi K2.7 is a frontier-scale open-source 1T parameter model with a 262.1k context window, multi-turn tool calling, vision inputs, and structured outputs for agentic workloads.
title: kimi-k2.7-code
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Moonshot AI logo](https://developers.cloudflare.com/_astro/moonshotai.DjWMkXUS.svg)

# kimi-k2.7-code

Text Generation • Moonshot AI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/moonshotai/kimi-k2.7-code` Copy

- Cloudflare-hosted
- Function calling
- Reasoning
- Vision
- Planned deprecation
- Zero data retention

Kimi K2.7 is a frontier-scale open-source 1T parameter model with a 262.1k context window, multi-turn tool calling, vision inputs, and structured outputs for agentic workloads.

Paid access required

This model is not available through standard Workers Free billing. To use it, upgrade to the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) or use prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/).

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 262,144 tokens |
| Terms and License | [link ↗](https://huggingface.co/moonshotai/Kimi-K2.7-Code/blob/main/LICENSE) |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | Always on |
| Vision | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.95 per M input tokens, $4.00 per M output tokens, $0.19 per M cached input tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/moonshotai/kimi-k2.7-code)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/moonshotai/kimi-k2.7-code", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/moonshotai/kimi-k2.7-code", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/moonshotai/kimi-k2.7-code",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/moonshotai/kimi-k2.7-code \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/#page","headline":"kimi-k2.7-code","description":"Kimi K2.7 is a frontier-scale open-source 1T parameter model with a 262.1k context window, multi-turn tool calling, vision inputs, and structured outputs for agentic workloads.","url":"https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: MeloTTS is a high-quality multi-lingual text-to-speech library by MyShell.ai.
title: melotts
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![MyShell logo](https://developers.cloudflare.com/_astro/myshell.6ROagMV2.svg)

# melotts

Text-to-Speech • MyShell

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/melotts/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/myshell-ai/melotts` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

MeloTTS is a high-quality multi-lingual text-to-speech library by MyShell.ai.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Zero data retention | Yes |
| Unit Pricing | $0.000205 per audio minute |

## Parameters

prompt

`string`requiredminLength: 1A text description of the audio you want to generate

lang

`string`default: enThe speech language (e.g., 'en' for English, 'fr' for French). Defaults to 'en' if not specified

▶Option 1{}

objectcontentType: application/json

Option 2

stringcontentType: audio/mpegformat: binary

The generated audio in MP3 format

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/melotts/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/melotts/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/melotts/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/melotts/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/melotts/#page","headline":"melotts","description":"MeloTTS is a high-quality multi-lingual text-to-speech library by MyShell.ai.","url":"https://developers.cloudflare.com/workers-ai/models/melotts/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: NVIDIA Nemotron 3 Super is a hybrid MoE model with leading accuracy for multi-agent applications and specialized agentic AI systems.
title: nemotron-3-120b-a12b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![NVIDIA logo](https://developers.cloudflare.com/_astro/nvidia.DI1bb8hH.svg)

# nemotron-3-120b-a12b

Text Generation • NVIDIA

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/nvidia/nemotron-3-120b-a12b` Copy

- Cloudflare-hosted
- Function calling
- Reasoning
- Planned deprecation
- Zero data retention

NVIDIA Nemotron 3 Super is a hybrid MoE model with leading accuracy for multi-agent applications and specialized agentic AI systems.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 256,000 tokens |
| Terms and License | [link ↗](https://www.nvidia.com/en-us/agreements/enterprise-software/nvidia-nemotron-open-model-license/) |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.50 per M input tokens, $1.50 per M output tokens |

## Reasoning effort

Nemotron supports normal reasoning, low reasoning, and reasoning turned off. It does not currently select these modes from the top-level`reasoning_effort` field. Pass the corresponding options through `chat_template_kwargs` instead.

To use low reasoning, set both `enable_thinking` and`low_effort`:

```python
response = client.chat.completions.create(
    model="@cf/nvidia/nemotron-3-120b-a12b",
    messages=[{"role": "user", "content": "What is the capital of Japan?"}],
    max_tokens=16000,
    temperature=1.0,
    top_p=0.95,
    extra_body={
        "chat_template_kwargs": {
            "enable_thinking": True,
            "low_effort": True,
        }
    },
)
```

The low-effort option appends `{reasoning effort: low}` to the latest user message. To turn reasoning off, set`enable_thinking` to `False`. For coding agents, set`force_nonempty_content` to `True` in the same`chat_template_kwargs` object.

For more information, refer to [NVIDIA's Nemotron API client example](https://huggingface.co/nvidia/NVIDIA-Nemotron-3-Super-120B-A12B-FP8#api-client).

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/nvidia/nemotron-3-120b-a12b)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/nvidia/nemotron-3-120b-a12b", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/nvidia/nemotron-3-120b-a12b", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/nvidia/nemotron-3-120b-a12b",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/nvidia/nemotron-3-120b-a12b \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

model

`string`ID of the model to use (for example, '@cf/nvidia/nemotron-3-120b-a12b').

▶audio{}

`object`Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

`number | null`Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

`object | null`Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

`boolean | null`Whether to return log probabilities of the output tokens.

top\_logprobs

`integer | null`How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

`integer | null`The maximum number of tokens to generate.

max\_completion\_tokens

`integer | null`An upper bound for the number of tokens that can be generated for a completion.

metadata

`object | null`Set of key-value pairs that can be attached to the object.

modalities

`array | null`Output types requested from the model.

n

`integer | null`How many chat completion choices to generate for each input message.

parallel\_tool\_calls

`boolean`default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

`object`

presence\_penalty

`number | null`Penalizes new tokens based on whether they appear in the text so far.

▶chat\_template\_kwargs{}

`object`Nemotron chat-template controls for normal reasoning, low-effort reasoning, and non-reasoning responses.

▶response\_format

`one of`Specifies the format the model must output.

seed

`integer | null`If specified, the system will make a best effort to sample deterministically.

▶stop

`one of`

store

`boolean | null`Whether to store the output for model distillation or evaluation.

stream

`boolean | null`If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

`object`

temperature

`number | null`Sampling temperature between 0 and 2.

▶tool\_choice

`one of`Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

`array`A list of tools the model may call.

top\_p

`number | null`Nucleus sampling: considers the results of the tokens with top\_p probability mass.

user

`string`A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

`object`Options for the web search tool (when using built-in web search).

▶function\_call

`one of`

▶functions\[]

`array`minItems: 1maxItems: 128

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/#page","headline":"nemotron-3-120b-a12b","description":"NVIDIA Nemotron 3 Super is a hybrid MoE model with leading accuracy for multi-agent applications and specialized agentic AI systems.","url":"https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: OpenAI’s open-weight models designed for powerful reasoning, agentic tasks, and versatile developer use cases – gpt-oss-120b is for production, general purpose, high reasoning use-cases.
title: gpt-oss-120b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)

# gpt-oss-120b

Text Generation • OpenAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/openai/gpt-oss-120b` Copy

- Cloudflare-hosted
- Batch
- Function calling
- Reasoning
- Zero data retention

OpenAI’s open-weight models designed for powerful reasoning, agentic tasks, and versatile developer use cases – gpt-oss-120b is for production, general purpose, high reasoning use-cases.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 128,000 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `low``medium` (default)`high` |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.35 per M input tokens, $0.75 per M output tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/openai/gpt-oss-120b", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/openai/gpt-oss-120b", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/openai/gpt-oss-120b",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/openai/gpt-oss-120b \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 256The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

type

<code>object</code>

contentType

<code>application/json</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 256The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>required

type

<code>object</code>

contentType

<code>application/json</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/#page","headline":"gpt-oss-120b","description":"OpenAI’s open-weight models designed for powerful reasoning, agentic tasks, and versatile developer use cases – gpt-oss-120b is for production, general purpose, high reasoning use-cases.","url":"https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: OpenAI’s open-weight models designed for powerful reasoning, agentic tasks, and versatile developer use cases – gpt-oss-20b is for lower latency, and local or specialized use-cases.
title: gpt-oss-20b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)

# gpt-oss-20b

Text Generation • OpenAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/openai/gpt-oss-20b` Copy

- Cloudflare-hosted
- Batch
- Function calling
- Reasoning
- Zero data retention

OpenAI’s open-weight models designed for powerful reasoning, agentic tasks, and versatile developer use cases – gpt-oss-20b is for lower latency, and local or specialized use-cases.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 128,000 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `low``medium` (default)`high` |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.20 per M input tokens, $0.30 per M output tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/openai/gpt-oss-20b", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/openai/gpt-oss-20b", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/openai/gpt-oss-20b",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/openai/gpt-oss-20b \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 256The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

type

<code>object</code>

contentType

<code>application/json</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 256The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>required

type

<code>object</code>

contentType

<code>application/json</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/#page","headline":"gpt-oss-20b","description":"OpenAI’s open-weight models designed for powerful reasoning, agentic tasks, and versatile developer use cases – gpt-oss-20b is for lower latency, and local or specialized use-cases.","url":"https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse audio and is also a multitasking model that can perform multilingual speech recognition, speech translation, and language identification.
title: whisper
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)

# whisper

Automatic Speech Recognition • OpenAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/whisper/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/openai/whisper` Copy

- Cloudflare-hosted
- Zero data retention

Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse audio and is also a multitasking model that can perform multilingual speech recognition, speech translation, and language identification.

| Model Info | |
| --- | --- |
| More information | [link ↗](https://openai.com/research/whisper) |
| Zero data retention | Yes |
| Unit Pricing | $0.000453 per audio minute |

## Parameters

Option 1

stringformat: binary

▶Option 2{}

object

text

`string`The transcription

word\_count

`number`

▶words\[]

`array`

vtt

`string`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/whisper/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/whisper/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/whisper/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/whisper/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/whisper/#page","headline":"whisper","description":"Whisper is a general-purpose speech recognition model. It is trained on a large dataset of diverse audio and is also a multitasking model that can perform multilingual speech recognition, speech translation, and language identification.","url":"https://developers.cloudflare.com/workers-ai/models/whisper/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation. "
title: whisper-large-v3-turbo
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)

# whisper-large-v3-turbo

Automatic Speech Recognition • OpenAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/openai/whisper-large-v3-turbo` Copy

- Cloudflare-hosted
- Batch
- Zero data retention

Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation.

| Model Info | |
| --- | --- |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.000513 per audio minute |

## Parameters

▶audio

`one of`required

task

`string`default: transcribeSupported tasks are 'translate' or 'transcribe'.

language

`string`The language of the audio being transcribed or translated.

vad\_filter

`boolean`default: falsePreprocess the audio with a voice activity detection model.

initial\_prompt

`string`A text prompt to help provide context to the model on the contents of the audio.

prefix

`string`The prefix appended to the beginning of the output of the transcription and can guide the transcription result.

beam\_size

`integer`default: 5The number of beams to use in beam search decoding. Higher values may improve accuracy at the cost of speed.

condition\_on\_previous\_text

`boolean`default: trueWhether to condition on previous text during transcription. Setting to false may help prevent hallucination loops.

no\_speech\_threshold

`number`default: 0.6Threshold for detecting no-speech segments. Segments with no-speech probability above this value are skipped.

compression\_ratio\_threshold

`number`default: 2.4Threshold for filtering out segments with high compression ratio, which often indicate repetitive or hallucinated text.

log\_prob\_threshold

`number`default: -1Threshold for filtering out segments with low average log probability, indicating low confidence.

hallucination\_silence\_threshold

`number`Optional threshold (in seconds) to skip silent periods that may cause hallucinations.

▶transcription\_info{}

`object`

text

`string`The complete transcription of the audio.

word\_count

`number`The total number of words in the transcription.

▶segments\[]

`array`

vtt

`string`The transcription in WebVTT format, which includes timing and text information for use in subtitles.

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/#page","headline":"whisper-large-v3-turbo","description":"Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation.","url":"https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation. Trained on 680k hours of labelled data, Whisper models demonstrate a strong ability to generalize to many datasets and domains without the need for fine-tuning. This is the English-only version of the Whisper Tiny model which was trained on the task of speech recognition.
title: whisper-tiny-en
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![OpenAI logo](https://developers.cloudflare.com/_astro/openai.BBwNKzBb.svg)

# whisper-tiny-en

Beta

Automatic Speech Recognition • OpenAI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/whisper-tiny-en/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/openai/whisper-tiny-en` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation. Trained on 680k hours of labelled data, Whisper models demonstrate a strong ability to generalize to many datasets and domains without the need for fine-tuning. This is the English-only version of the Whisper Tiny model which was trained on the task of speech recognition.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Zero data retention | Yes |
| Beta | Yes |

## Parameters

Option 1

stringformat: binary

▶Option 2{}

object

text

`string`The transcription

word\_count

`number`

▶words\[]

`array`

vtt

`string`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/whisper-tiny-en/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/whisper-tiny-en/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/whisper-tiny-en/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/whisper-tiny-en/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/whisper-tiny-en/#page","headline":"whisper-tiny-en","description":"Whisper is a pre-trained model for automatic speech recognition (ASR) and speech translation. Trained on 680k hours of labelled data, Whisper models demonstrate a strong ability to generalize to many datasets and domains without the need for fine-tuning. This is the English-only version of the Whisper Tiny model which was trained on the task of speech recognition.","url":"https://developers.cloudflare.com/workers-ai/models/whisper-tiny-en/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "PLaMo-Embedding-1B is a Japanese text embedding model developed by Preferred Networks, Inc.\n\nIt can convert Japanese text input into numerical vectors and can be used for a wide range of applications, including information retrieval, text classification, and clustering."
title: plamo-embedding-1b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

p

# plamo-embedding-1b

Text Embeddings • pfnet

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/plamo-embedding-1b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/pfnet/plamo-embedding-1b` Copy

- Cloudflare-hosted
- Zero data retention

PLaMo-Embedding-1B is a Japanese text embedding model developed by Preferred Networks, Inc. It can convert Japanese text input into numerical vectors and can be used for a wide range of applications, including information retrieval, text classification, and clustering.

| Model Info | |
| --- | --- |
| Zero data retention | Yes |
| Unit Pricing | $0.0186 per M input tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    // Can be a string or array of strings]
    const stories = [
      "This is a story about an orange cloud",
      "This is a story about a llama",
      "This is a story about a hugging emoji",
    ];

    const embeddings = await env.AI.run(
      "@cf/pfnet/plamo-embedding-1b",
      {
        text: stories,
      }
    );

    return Response.json(embeddings);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests


ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

stories = [
  'This is a story about an orange cloud',
  'This is a story about a llama',
  'This is a story about a hugging emoji'
]

response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/pfnet/plamo-embedding-1b",
  headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
  json={"text": stories}
)

print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/pfnet/plamo-embedding-1b  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "text": ["This is a story about an orange cloud", "This is a story about a llama", "This is a story about a hugging emoji"] }'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/).

## Parameters

▶text

`one of`required

▶data\[]

`array`Embedding vectors, where each vector is a list of floats.

▶shape\[]

`array`minItems: 2maxItems: 2Shape of the embedding data as \[number\_of\_embeddings, embedding\_dimension].

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/plamo-embedding-1b/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/plamo-embedding-1b/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/plamo-embedding-1b/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/plamo-embedding-1b/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/plamo-embedding-1b/#page","headline":"plamo-embedding-1b","description":"PLaMo-Embedding-1B is a Japanese text embedding model developed by Preferred Networks, Inc.\n\nIt can convert Japanese text input into numerical vectors and can be used for a wide range of applications, including information retrieval, text classification, and clustering.","url":"https://developers.cloudflare.com/workers-ai/models/plamo-embedding-1b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: An open source, community-driven, native audio turn detection model in 2nd version
title: smart-turn-v2
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Pipecat logo](https://developers.cloudflare.com/_astro/pipecat.B-PNBdef.svg)

# smart-turn-v2

Dumb Pipe • Pipecat

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/smart-turn-v2/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/pipecat-ai/smart-turn-v2` Copy

- Cloudflare-hosted
- Batch
- Real-time
- Zero data retention

An open source, community-driven, native audio turn detection model in 2nd version

| Model Info | |
| --- | --- |
| Zero data retention | Yes |
| Batch | Yes |
| Real-time | Yes |
| Unit Pricing | $0.000338 per audio minute |

## Parameters

▶Option 1{}

object

▶Option 2{}

object

is\_complete

`boolean`if true, end-of-turn was detected

probability

`number`probability of the end-of-turn detection

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/smart-turn-v2/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/smart-turn-v2/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/smart-turn-v2/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/smart-turn-v2/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/smart-turn-v2/#page","headline":"smart-turn-v2","description":"An open source, community-driven, native audio turn detection model in 2nd version","url":"https://developers.cloudflare.com/workers-ai/models/smart-turn-v2/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "Qwen2.5-Coder is the latest series of Code-Specific Qwen large language models (formerly known as CodeQwen). As of now, Qwen2.5-Coder has covered six mainstream model sizes, 0.5, 1.5, 3, 7, 14, 32 billion parameters, to meet the needs of different developers. Qwen2.5-Coder brings the following improvements upon CodeQwen1.5:"
title: qwen2.5-coder-32b-instruct
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)

# qwen2.5-coder-32b-instruct

Text Generation • Qwen

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/qwen/qwen2.5-coder-32b-instruct` Copy

- Cloudflare-hosted
- LoRA
- Zero data retention

Qwen2.5-Coder is the latest series of Code-Specific Qwen large language models (formerly known as CodeQwen). As of now, Qwen2.5-Coder has covered six mainstream model sizes, 0.5, 1.5, 3, 7, 14, 32 billion parameters, to meet the needs of different developers. Qwen2.5-Coder brings the following improvements upon CodeQwen1.5:

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 32,768 tokens |
| Zero data retention | Yes |
| LoRA | Yes |
| Unit Pricing | $0.66 per M input tokens, $1.00 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/qwen/qwen2.5-coder-32b-instruct)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/qwen/qwen2.5-coder-32b-instruct", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/qwen/qwen2.5-coder-32b-instruct", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/qwen/qwen2.5-coder-32b-instruct",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/qwen/qwen2.5-coder-32b-instruct \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

lora

`string`Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

`object`

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0maximum: 2Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: 0maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: 0maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/#page","headline":"qwen2.5-coder-32b-instruct","description":"Qwen2.5-Coder is the latest series of Code-Specific Qwen large language models (formerly known as CodeQwen). As of now, Qwen2.5-Coder has covered six mainstream model sizes, 0.5, 1.5, 3, 7, 14, 32 billion parameters, to meet the needs of different developers. Qwen2.5-Coder brings the following improvements upon CodeQwen1.5:","url":"https://developers.cloudflare.com/workers-ai/models/qwen2.5-coder-32b-instruct/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Qwen3 is the latest generation of large language models in Qwen series, offering a comprehensive suite of dense and mixture-of-experts (MoE) models. Built upon extensive training, Qwen3 delivers groundbreaking advancements in reasoning, instruction-following, agent capabilities, and multilingual support.
title: qwen3-30b-a3b-fp8
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)

# qwen3-30b-a3b-fp8

Text Generation • Qwen

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/qwen/qwen3-30b-a3b-fp8` Copy

- Cloudflare-hosted
- Batch
- Function calling
- Reasoning
- Planned deprecation
- Zero data retention

Qwen3 is the latest generation of large language models in Qwen series, offering a comprehensive suite of dense and mixture-of-experts (MoE) models. Built upon extensive training, Qwen3 delivers groundbreaking advancements in reasoning, instruction-following, agent capabilities, and multilingual support.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 32,768 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | Yes |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.0509 per M input tokens, $0.335 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/qwen/qwen3-30b-a3b-fp8)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/qwen/qwen3-30b-a3b-fp8", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/qwen/qwen3-30b-a3b-fp8", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/qwen/qwen3-30b-a3b-fp8",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/qwen/qwen3-30b-a3b-fp8 \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 2000The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

id

<code>string</code>Unique identifier for the completion

object

<code>string</code>enum: chat.completionObject type identifier

created

<code>number</code>Unix timestamp of when the completion was created

model

<code>string</code>Model used for the completion

▶choices\[]

<code>array</code>List of completion choices

▶usage{}

<code>object</code>Usage statistics for the inference request

prompt\_logprobs{}

<code>object</code>Log probabilities for the prompt (if requested)

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

lora

<code>string</code>Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

▶response\_format{}

<code>object</code>

raw

<code>boolean</code>default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

<code>boolean</code>default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

<code>integer</code>default: 2000The maximum number of tokens to generate in the response.

temperature

<code>number</code>default: 0.6minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

<code>number</code>minimum: 0.001maximum: 1Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

<code>integer</code>minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

<code>integer</code>minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

<code>number</code>minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

<code>number</code>minimum: -2maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

<code>number</code>minimum: -2maximum: 2Increases the likelihood of the model introducing new topics.

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>required

id

<code>string</code>Unique identifier for the completion

object

<code>string</code>enum: chat.completionObject type identifier

created

<code>number</code>Unix timestamp of when the completion was created

model

<code>string</code>Model used for the completion

▶choices\[]

<code>array</code>List of completion choices

▶usage{}

<code>object</code>Usage statistics for the inference request

prompt\_logprobs{}

<code>object</code>Log probabilities for the prompt (if requested)

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/#page","headline":"qwen3-30b-a3b-fp8","description":"Qwen3 is the latest generation of large language models in Qwen series, offering a comprehensive suite of dense and mixture-of-experts (MoE) models. Built upon extensive training, Qwen3 delivers groundbreaking advancements in reasoning, instruction-following, agent capabilities, and multilingual support.","url":"https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "The Qwen3 Embedding model series is the latest proprietary model of the Qwen family, specifically designed for text embedding and ranking tasks. "
title: qwen3-embedding-0.6b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)

# qwen3-embedding-0.6b

Text Embeddings • Qwen

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/qwen3-embedding-0.6b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/qwen/qwen3-embedding-0.6b` Copy

- Cloudflare-hosted
- Zero data retention

The Qwen3 Embedding model series is the latest proprietary model of the Qwen family, specifically designed for text embedding and ranking tasks.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 8,192 tokens |
| Zero data retention | Yes |
| Unit Pricing | $0.0118 per M input tokens |

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    // Can be a string or array of strings]
    const stories = [
      "This is a story about an orange cloud",
      "This is a story about a llama",
      "This is a story about a hugging emoji",
    ];

    const embeddings = await env.AI.run(
      "@cf/qwen/qwen3-embedding-0.6b",
      {
        text: stories,
      }
    );

    return Response.json(embeddings);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests


ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

stories = [
  'This is a story about an orange cloud',
  'This is a story about a llama',
  'This is a story about a hugging emoji'
]

response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/qwen/qwen3-embedding-0.6b",
  headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
  json={"text": stories}
)

print(response.json())
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/qwen/qwen3-embedding-0.6b  \
  -X POST  \
  -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"  \
  -d '{ "text": ["This is a story about an orange cloud", "This is a story about a llama", "This is a story about a hugging emoji"] }'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/).

## Parameters

▶queries

`one of`

instruction

`string`default: Given a web search query, retrieve relevant passages that answer the queryOptional instruction for the task

▶documents

`one of`

▶text

`one of`

▶data\[]

`array`

▶shape\[]

`array`

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/qwen3-embedding-0.6b/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3-embedding-0.6b/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/qwen3-embedding-0.6b/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3-embedding-0.6b/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/qwen3-embedding-0.6b/#page","headline":"qwen3-embedding-0.6b","description":"The Qwen3 Embedding model series is the latest proprietary model of the Qwen family, specifically designed for text embedding and ranking tasks.","url":"https://developers.cloudflare.com/workers-ai/models/qwen3-embedding-0.6b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Qwen 3.8 27B is a 27-billion-parameter instruction-tuned language model from Alibaba's Qwen family, designed for vision, efficient general-purpose text generation and agentic workloads.
title: qwen3.8-27b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)

# qwen3.8-27b

Text Generation • Qwen

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/qwen/qwen3.8-27b` Copy

- Cloudflare-hosted
- Batch
- Function calling
- Reasoning
- Vision
- Zero data retention

Qwen 3.8 27B is a 27-billion-parameter instruction-tuned language model from Alibaba's Qwen family, designed for vision, efficient general-purpose text generation and agentic workloads.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 262,144 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `low``medium``xhigh` (default) |
| Vision | Yes |
| Zero data retention | Yes |
| Batch | Yes |
| Unit Pricing | $0.45 per M input tokens, $3.20 per M output tokens, $0.05 per M cached input tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/qwen/qwen3.8-27b)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/qwen/qwen3.8-27b", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/qwen/qwen3.8-27b", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/qwen/qwen3.8-27b",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/qwen/qwen3.8-27b \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: low, medium, xhighReasoning effort. Supported levels: low, medium, xhigh.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: low, medium, xhighReasoning effort. Supported levels: low, medium, xhigh.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/#page","headline":"qwen3.8-27b","description":"Qwen 3.8 27B is a 27-billion-parameter instruction-tuned language model from Alibaba's Qwen family, designed for vision, efficient general-purpose text generation and agentic workloads.","url":"https://developers.cloudflare.com/workers-ai/models/qwen3.8-27b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: QwQ is the reasoning model of the Qwen series. Compared with conventional instruction-tuned models, QwQ, which is capable of thinking and reasoning, can achieve significantly enhanced performance in downstream tasks, especially hard problems. QwQ-32B is the medium-sized reasoning model, which is capable of achieving competitive performance against state-of-the-art reasoning models, e.g., DeepSeek-R1, o1-mini.
title: qwq-32b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Qwen logo](https://developers.cloudflare.com/_astro/qwen.ByCZjtXU.svg)

# qwq-32b

Text Generation • Qwen

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/qwq-32b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/qwen/qwq-32b` Copy

- Cloudflare-hosted
- LoRA
- Reasoning
- Planned deprecation
- Zero data retention

QwQ is the reasoning model of the Qwen series. Compared with conventional instruction-tuned models, QwQ, which is capable of thinking and reasoning, can achieve significantly enhanced performance in downstream tasks, especially hard problems. QwQ-32B is the medium-sized reasoning model, which is capable of achieving competitive performance against state-of-the-art reasoning models, e.g., DeepSeek-R1, o1-mini.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 24,000 tokens |
| Reasoning | Yes |
| Zero data retention | Yes |
| LoRA | Yes |
| Unit Pricing | $0.66 per M input tokens, $1.00 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/qwen/qwq-32b)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/qwen/qwq-32b", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/qwen/qwq-32b", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/qwen/qwq-32b",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/qwen/qwq-32b \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

guided\_json{}

`object`JSON schema that should be fulfilled for the response.

raw

`boolean`default: falseIf true, a chat template is not applied and you must adhere to the specific model's expected formatting.

stream

`boolean`default: falseIf true, the response will be streamed back incrementally using SSE, Server Sent Events.

max\_tokens

`integer`default: 256The maximum number of tokens to generate in the response.

temperature

`number`default: 0.15minimum: 0maximum: 5Controls the randomness of the output; higher values produce more random results.

top\_p

`number`minimum: 0maximum: 2Adjusts the creativity of the AI's responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

top\_k

`integer`minimum: 1maximum: 50Limits the AI to choose from the top 'k' most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

seed

`integer`minimum: 1maximum: 9999999999Random seed for reproducibility of the generation.

repetition\_penalty

`number`minimum: 0maximum: 2Penalty for repeated tokens; higher values discourage repetition.

frequency\_penalty

`number`minimum: 0maximum: 2Decreases the likelihood of the model repeating the same lines verbatim.

presence\_penalty

`number`minimum: 0maximum: 2Increases the likelihood of the model introducing new topics.

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



response

<code>string</code>The generated text response from the model

▶usage{}

<code>object</code>Usage statistics for the inference request

▶tool\_calls\[]

<code>array</code>An array of tool calls requests made during the response generation

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/qwq-32b/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwq-32b/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwq-32b/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwq-32b/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/qwq-32b/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwq-32b/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/qwq-32b/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/qwq-32b/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/qwq-32b/#page","headline":"qwq-32b","description":"QwQ is the reasoning model of the Qwen series. Compared with conventional instruction-tuned models, QwQ, which is capable of thinking and reasoning, can achieve significantly enhanced performance in downstream tasks, especially hard problems. QwQ-32B is the medium-sized reasoning model, which is capable of achieving competitive performance against state-of-the-art reasoning models, e.g., DeepSeek-R1, o1-mini.","url":"https://developers.cloudflare.com/workers-ai/models/qwq-32b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Stable Diffusion Inpainting is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input, with the extra capability of inpainting the pictures by using a mask.
title: stable-diffusion-v1-5-inpainting
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![RunwayML logo](https://developers.cloudflare.com/_astro/runway.Cq8Cjov4.svg)

# stable-diffusion-v1-5-inpainting

Beta

Text-to-Image • RunwayML

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-inpainting/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/runwayml/stable-diffusion-v1-5-inpainting` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

Stable Diffusion Inpainting is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input, with the extra capability of inpainting the pictures by using a mask.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Terms and License | [link ↗](https://github.com/runwayml/stable-diffusion/blob/main/LICENSE) |
| More information | [link ↗](https://huggingface.co/runwayml/stable-diffusion-inpainting) |
| Zero data retention | Yes |
| Beta | Yes |
| Unit Pricing | $0.00 per step |

## Parameters

prompt

`string`requiredminLength: 1A text description of the image you want to generate

negative\_prompt

`string`Text describing elements to avoid in the generated image

height

`integer`minimum: 256maximum: 2048The height of the generated image in pixels

width

`integer`minimum: 256maximum: 2048The width of the generated image in pixels

▶image\[]

`array`For use with img2img tasks. An array of integers that represent the image data constrained to 8-bit unsigned integer values

image\_b64

`string`For use with img2img tasks. A base64-encoded string of the input image

▶mask\[]

`array`An array representing An array of integers that represent mask image data for inpainting constrained to 8-bit unsigned integer values

num\_steps

`integer`default: 20maximum: 20The number of diffusion steps; higher values can improve quality but take longer

strength

`number`default: 1A value between 0 and 1 indicating how strongly to apply the transformation during img2img tasks; lower values make the output closer to the input image

guidance

`number`default: 7.5Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt

seed

`integer`Random seed for reproducibility of the image generation

The binding returns a `ReadableStream` with the output (check the model's output schema).

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-inpainting/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-inpainting/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-inpainting/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-inpainting/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-inpainting/#page","headline":"stable-diffusion-v1-5-inpainting","description":"Stable Diffusion Inpainting is a latent text-to-image diffusion model capable of generating photo-realistic images given any text input, with the extra capability of inpainting the pictures by using a mask.","url":"https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-inpainting/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Diffusion-based text-to-image generative model by Stability AI. Generates and modify images based on text prompts.
title: stable-diffusion-xl-base-1.0
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Stability.ai logo](https://developers.cloudflare.com/_astro/stabilityai.VsBx3CKv.svg)

# stable-diffusion-xl-base-1.0

Beta

Text-to-Image • Stability.ai

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-base-1.0/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/stabilityai/stable-diffusion-xl-base-1.0` Copy

- Cloudflare-hosted
- Planned deprecation
- Zero data retention

Diffusion-based text-to-image generative model by Stability AI. Generates and modify images based on text prompts.

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Terms and License | [link ↗](https://huggingface.co/stabilityai/stable-diffusion-xl-base-1.0/blob/main/LICENSE.md) |
| More information | [link ↗](https://stability.ai/stable-diffusion) |
| Zero data retention | Yes |
| Beta | Yes |
| Unit Pricing | $0.00 per step |

## Parameters

prompt

`string`requiredminLength: 1A text description of the image you want to generate

negative\_prompt

`string`Text describing elements to avoid in the generated image

height

`integer`minimum: 256maximum: 2048The height of the generated image in pixels

width

`integer`minimum: 256maximum: 2048The width of the generated image in pixels

▶image\[]

`array`For use with img2img tasks. An array of integers that represent the image data constrained to 8-bit unsigned integer values

image\_b64

`string`For use with img2img tasks. A base64-encoded string of the input image

▶mask\[]

`array`An array representing An array of integers that represent mask image data for inpainting constrained to 8-bit unsigned integer values

num\_steps

`integer`default: 20maximum: 20The number of diffusion steps; higher values can improve quality but take longer

strength

`number`default: 1A value between 0 and 1 indicating how strongly to apply the transformation during img2img tasks; lower values make the output closer to the input image

guidance

`number`default: 7.5Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt

seed

`integer`Random seed for reproducibility of the image generation

The binding returns a `ReadableStream` with the output (check the model's output schema).

## API Schemas (Raw)

Input [Open](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-base-1.0/schema-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-base-1.0/schema-input.json)

Output [Open](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-base-1.0/schema-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-base-1.0/schema-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-base-1.0/#page","headline":"stable-diffusion-xl-base-1.0","description":"Diffusion-based text-to-image generative model by Stability AI. Generates and modify images based on text prompts.","url":"https://developers.cloudflare.com/workers-ai/models/stable-diffusion-xl-base-1.0/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "Apertus 1.5 is an 8B parameter language model designed to advance the state of multilingual, multimodal, fully open, and transparent AI. The models support a wide range of languages, handle contexts of up to 262,144 tokens, and it uses only fully open training data whilst delivering performance comparable to other models of similar size. For access, please fill out this form: https://forms.gle/kgvmkr6ucHN3xNuH6"
title: apertus-v1.5-8b
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

s

# apertus-v1.5-8b

Text Generation • swiss-ai

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/apertus-v1.5-8b/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/swiss-ai/apertus-v1.5-8b` Copy

- Cloudflare-hosted
- Function calling
- Vision
- Zero data retention

Apertus 1.5 is an 8B parameter language model designed to advance the state of multilingual, multimodal, fully open, and transparent AI. The models support a wide range of languages, handle contexts of up to 262,144 tokens, and it uses only fully open training data whilst delivering performance comparable to other models of similar size. For access, please fill out this form: https://forms.gle/kgvmkr6ucHN3xNuH6

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 262,144 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Vision | Yes |
| Zero data retention | Yes |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/swiss-ai/apertus-v1.5-8b)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/swiss-ai/apertus-v1.5-8b", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/swiss-ai/apertus-v1.5-8b", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/swiss-ai/apertus-v1.5-8b",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/swiss-ai/apertus-v1.5-8b \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/apertus-v1.5-8b/#page","headline":"apertus-v1.5-8b","description":"Apertus 1.5 is an 8B parameter language model designed to advance the state of multilingual, multimodal, fully open, and transparent AI. The models support a wide range of languages, handle contexts of up to 262,144 tokens, and it uses only fully open training data whilst delivering performance comparable to other models of similar size. For access, please fill out this form: https://forms.gle/kgvmkr6ucHN3xNuH6","url":"https://developers.cloudflare.com/workers-ai/models/apertus-v1.5-8b/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: "EuroLLM-9B is a 9B parameter model trained on 4 trillion tokens divided across the considered languages and several data sources: Web data, parallel data (en-xx and xx-en), and high-quality datasets. For access, please fill out this form: https://forms.gle/kgvmkr6ucHN3xNuH6"
title: eurollm-9b-it
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

u

# eurollm-9b-it

Text Generation • utter-project

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/eurollm-9b-it/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/utter-project/eurollm-9b-it` Copy

- Cloudflare-hosted
- Function calling
- Zero data retention

EuroLLM-9B is a 9B parameter model trained on 4 trillion tokens divided across the considered languages and several data sources: Web data, parallel data (en-xx and xx-en), and high-quality datasets. For access, please fill out this form: https://forms.gle/kgvmkr6ucHN3xNuH6

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 32,000 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Zero data retention | Yes |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/utter-project/eurollm-9b-it)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/utter-project/eurollm-9b-it", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/utter-project/eurollm-9b-it", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/utter-project/eurollm-9b-it",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/utter-project/eurollm-9b-it \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/eurollm-9b-it/#page","headline":"eurollm-9b-it","description":"EuroLLM-9B is a 9B parameter model trained on 4 trillion tokens divided across the considered languages and several data sources: Web data, parallel data (en-xx and xx-en), and high-quality datasets. For access, please fill out this form: https://forms.gle/kgvmkr6ucHN3xNuH6","url":"https://developers.cloudflare.com/workers-ai/models/eurollm-9b-it/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: GLM-4.7-Flash is a fast and efficient multilingual text generation model with a 131,072 token context window. Optimized for dialogue, instruction-following, and multi-turn tool calling across 100+ languages.
title: glm-4.7-flash
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Zhipu AI logo](https://developers.cloudflare.com/_astro/zai-org.Dj2vcayE.svg)

# glm-4.7-flash

Text Generation • Zhipu AI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/zai-org/glm-4.7-flash` Copy

- Cloudflare-hosted
- Function calling
- Reasoning
- Zero data retention

GLM-4.7-Flash is a fast and efficient multilingual text generation model with a 131,072 token context window. Optimized for dialogue, instruction-following, and multi-turn tool calling across 100+ languages.

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 131,072 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.0605 per M input tokens, $0.40 per M output tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/zai-org/glm-4.7-flash)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/zai-org/glm-4.7-flash", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/zai-org/glm-4.7-flash", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/zai-org/glm-4.7-flash",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/zai-org/glm-4.7-flash \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

### Input

prompt

`string`requiredminLength: 1The input text prompt for the model to generate a response.

model

`string`ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

`object`Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

`number | null`Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

`object | null`Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

`boolean | null`Whether to return log probabilities of the output tokens.

top\_logprobs

`integer | null`How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

`integer | null`Deprecated in favor of max\_completion\_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

`integer | null`An upper bound for the number of tokens that can be generated for a completion.

metadata

`object | null`Set of 16 key-value pairs that can be attached to the object.

modalities

`array | null`Output types requested from the model (e.g. \['text'] or \['text', 'audio']).

n

`integer | null`How many chat completion choices to generate for each input message.

parallel\_tool\_calls

`boolean`default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

`object`

presence\_penalty

`number | null`Penalizes new tokens based on whether they appear in the text so far.

▶chat\_template\_kwargs{}

`object`

▶response\_format

`one of`Specifies the format the model must output.

seed

`integer | null`If specified, the system will make a best effort to sample deterministically.

▶stop

`one of`

store

`boolean | null`Whether to store the output for model distillation / evals.

stream

`boolean | null`If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

`object`

temperature

`number | null`Sampling temperature between 0 and 2.

▶tool\_choice

`one of`Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

`array`A list of tools the model may call.

top\_p

`number | null`Nucleus sampling: considers the results of the tokens with top\_p probability mass.

user

`string`A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

`object`Options for the web search tool (when using built-in web search).

▶function\_call

`one of`

▶functions\[]

`array`minItems: 1maxItems: 128

### Output

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/streaming-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/#page","headline":"glm-4.7-flash","description":"GLM-4.7-Flash is a fast and efficient multilingual text generation model with a 131,072 token context window. Optimized for dialogue, instruction-following, and multi-turn tool calling across 100+ languages.","url":"https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Z.ai's flagship agentic coding model
title: glm-5.2
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Zhipu AI logo](https://developers.cloudflare.com/_astro/zai-org.Dj2vcayE.svg)

# glm-5.2

Text Generation • Zhipu AI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/glm-5.2/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/zai-org/glm-5.2` Copy

- Cloudflare-hosted
- Function calling
- Reasoning
- Planned deprecation
- Zero data retention

Z.ai's flagship agentic coding model

Paid access required

This model is not available through standard Workers Free billing. To use it, upgrade to the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) or use prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/).

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 262,144 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `none``high``max` (default) |
| Zero data retention | Yes |
| Unit Pricing | $1.40 per M input tokens, $4.40 per M output tokens, $0.26 per M cached input tokens |

## Reasoning effort

GLM-5.2 supports `high` and `max` reasoning effort, or you can turn reasoning off. For compatibility with Chat Completions and other protocols in the ecosystem, other reasoning efforts will be mapped to these modes:

- `none` and `minimal` turn reasoning off.
- `low` and `medium` map to `high`.
- `xhigh` maps to `max`.

This is the same mapping used by Z.ai's API, and [in their `reasoning_effort` documentation](https://docs.z.ai/api-reference/llm/chat-completion#body-one-of-0-reasoning-effort).

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/zai-org/glm-5.2)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/zai-org/glm-5.2", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/zai-org/glm-5.2", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/zai-org/glm-5.2",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/zai-org/glm-5.2 \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, noneReasoning effort. Supported levels: max, high, none. Compatibility aliases: low maps to high; medium maps to high; xhigh maps to max; minimal maps to none.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, noneReasoning effort. Supported levels: max, high, none. Compatibility aliases: low maps to high; medium maps to high; xhigh maps to max; minimal maps to none.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.2/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.2/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.2/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.2/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.2/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.2/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.2/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.2/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.2/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.2/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.2/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.2/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/glm-5.2/#page","headline":"glm-5.2","description":"Z.ai's flagship agentic coding model","url":"https://developers.cloudflare.com/workers-ai/models/glm-5.2/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: GLM-5.3 is Z.ai's flagship agentic coding model, pairing a 1M-token context window with reasoning, function calling, and structured outputs to power multi-step, tool-driven development workflows.
title: glm-5.3
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Zhipu AI logo](https://developers.cloudflare.com/_astro/zai-org.Dj2vcayE.svg)

# glm-5.3

Text Generation • Zhipu AI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/glm-5.3/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/zai-org/glm-5.3` Copy

- Cloudflare-hosted
- Function calling
- Reasoning
- Zero data retention

GLM-5.3 is Z.ai's flagship agentic coding model, pairing a 1M-token context window with reasoning, function calling, and structured outputs to power multi-step, tool-driven development workflows.

Paid access required

This model is not available through standard Workers Free billing. To use it, upgrade to the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) or use prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/).

| Model Info | |
| --- | --- |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 1,048,576 tokens |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `low``high``max` (default) |
| Zero data retention | Yes |
| Unit Pricing | $1.40 per M input tokens, $4.40 per M output tokens, $0.26 per M cached input tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/zai-org/glm-5.3)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/zai-org/glm-5.3", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/zai-org/glm-5.3", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/zai-org/glm-5.3",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/zai-org/glm-5.3 \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, lowReasoning effort. Supported levels: max, high, low. Reasoning cannot be disabled. Compatibility aliases: none maps to max; minimal maps to max; medium maps to max; xhigh maps to max.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, lowReasoning effort. Supported levels: max, high, low. Reasoning cannot be disabled. Compatibility aliases: none maps to max; minimal maps to max; medium maps to max; xhigh maps to max.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/glm-5.3/#page","headline":"glm-5.3","description":"GLM-5.3 is Z.ai's flagship agentic coding model, pairing a 1M-token context window with reasoning, function calling, and structured outputs to power multi-step, tool-driven development workflows.","url":"https://developers.cloudflare.com/workers-ai/models/glm-5.3/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: The first natively multimodal model in the GLM-5 series. With 320B total parameters and just 18B active parameters, it outperforms GLM-5.2 across benchmarks and real-world workloads at one-tenth the price, while approaching Claude Opus 4.8 on coding and agentic benchmarks.
title: glm-5.3-flash
image: https://developers.cloudflare.com/og-docs.png
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/llms.txt  
> Use this file to discover all available pages before exploring further.

![Zhipu AI logo](https://developers.cloudflare.com/_astro/zai-org.Dj2vcayE.svg)

# glm-5.3-flash

Text Generation • Zhipu AI

Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Model ID

`@cf/zai-org/glm-5.3-flash` Copy

- Cloudflare-hosted
- Function calling
- Reasoning
- Vision
- Planned deprecation
- Zero data retention

The first natively multimodal model in the GLM-5 series. With 320B total parameters and just 18B active parameters, it outperforms GLM-5.2 across benchmarks and real-world workloads at one-tenth the price, while approaching Claude Opus 4.8 on coding and agentic benchmarks.

Paid access required

This model is not available through standard Workers Free billing. To use it, upgrade to the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) or use prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/).

| Model Info | |
| --- | --- |
| Planned Deprecation | 11/20/2026 |
| Context Window [ ↗](https://developers.cloudflare.com/workers-ai/platform/glossary/) | 1,048,576 tokens |
| Terms and License | [link ↗](https://huggingface.co/zai-org/GLM-5.3-Flash/blob/main/LICENSE) |
| Function calling [↗](https://developers.cloudflare.com/workers-ai/function-calling/) | Yes |
| Reasoning | `low``high``max` (default) |
| Vision | Yes |
| Zero data retention | Yes |
| Unit Pricing | $0.15 per M input tokens, $0.50 per M output tokens, $0.03 per M cached input tokens |

## Playground

Try out this model with Workers AI LLM Playground. It does not require any setup or authentication and is an instant way to preview and test a model directly in the browser.

[Launch the LLM Playground](https://playground.ai.cloudflare.com/?model=@cf/zai-org/glm-5.3-flash)

## Usage

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];

    const stream = await env.AI.run("@cf/zai-org/glm-5.3-flash", {
      messages,
      stream: true,
    });

    return new Response(stream, {
      headers: { "content-type": "text/event-stream" },
    });
  },
} satisfies ExportedHandler<Env>;
```

```ts
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {

    const messages = [
      { role: "system", content: "You are a friendly assistant" },
      {
        role: "user",
        content: "What is the origin of the phrase Hello, World",
      },
    ];
    const response = await env.AI.run("@cf/zai-org/glm-5.3-flash", { messages });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

```py
import os
import requests

ACCOUNT_ID = "your-account-id"
AUTH_TOKEN = os.environ.get("CLOUDFLARE_AUTH_TOKEN")

prompt = "Tell me all about PEP-8"
response = requests.post(
  f"https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/zai-org/glm-5.3-flash",
    headers={"Authorization": f"Bearer {AUTH_TOKEN}"},
    json={
      "messages": [
        {"role": "system", "content": "You are a friendly assistant"},
        {"role": "user", "content": prompt}
      ]
    }
)
result = response.json()
print(result)
```

```sh
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/zai-org/glm-5.3-flash \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "messages": [{ "role": "system", "content": "You are a friendly assistant" }, { "role": "user", "content": "Why is pizza so good" }]}'
```

OpenAI compatible endpoints

Workers AI also supports OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/) .

## Parameters

<details>

<summary>Synchronous — Send a request and receive a complete response</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, lowReasoning effort. Supported levels: max, high, low. Reasoning cannot be disabled. Compatibility aliases: none maps to max; minimal maps to max; medium maps to max; xhigh maps to max.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

<details>

<summary>Streaming — Send a request with `stream: true` and receive server-sent events</summary>



Input format

Prompt Simple text input for single-turn interactionsMessages Structured conversation format with roles (user, assistant, system)

prompt

<code>string</code>requiredminLength: 1The input text prompt for the model to generate a response.

model

<code>string</code>ID of the model to use (e.g. '@cf/zai-org/glm-4.7-flash, etc').

▶audio{}

<code>object</code>Parameters for audio output. Required when modalities includes 'audio'.

frequency\_penalty

<code>number | null</code>Penalizes new tokens based on their existing frequency in the text so far.

logit\_bias

<code>object | null</code>Modify the likelihood of specified tokens appearing in the completion. Maps token IDs to bias values from -100 to 100.

logprobs

<code>boolean | null</code>Whether to return log probabilities of the output tokens.

top\_logprobs

<code>integer | null</code>How many top log probabilities to return at each token position (0-20). Requires logprobs=true.

max\_tokens

<code>integer | null</code>Deprecated in favor of max_completion_tokens. The maximum number of tokens to generate.

max\_completion\_tokens

<code>integer | null</code>An upper bound for the number of tokens that can be generated for a completion.

metadata

<code>object | null</code>Set of 16 key-value pairs that can be attached to the object.

modalities

<code>array | null</code>Output types requested from the model (e.g. ['text'] or ['text', 'audio']).

n

<code>integer | null</code>How many chat completion choices to generate for each input message.

parallel\_tool\_calls

<code>boolean</code>default: trueWhether to enable parallel function calling during tool use.

▶prediction{}

<code>object</code>

presence\_penalty

<code>number | null</code>Penalizes new tokens based on whether they appear in the text so far.

reasoning\_effort

<code>string | null</code>enum: max, high, lowReasoning effort. Supported levels: max, high, low. Reasoning cannot be disabled. Compatibility aliases: none maps to max; minimal maps to max; medium maps to max; xhigh maps to max.

▶chat\_template\_kwargs{}

<code>object</code>

▶response\_format

<code>one of</code>Specifies the format the model must output.

seed

<code>integer | null</code>If specified, the system will make a best effort to sample deterministically.

▶stop

<code>one of</code>

store

<code>boolean | null</code>Whether to store the output for model distillation / evals.

stream

<code>boolean | null</code>If true, partial message deltas will be sent as server-sent events.

▶stream\_options{}

<code>object</code>

temperature

<code>number | null</code>Sampling temperature between 0 and 2.

▶tool\_choice

<code>one of</code>Controls which (if any) tool is called by the model. 'none' = no tools, 'auto' = model decides, 'required' = must call a tool.

▶tools\[]

<code>array</code>A list of tools the model may call.

top\_p

<code>number | null</code>Nucleus sampling: considers the results of the tokens with top_p probability mass.

user

<code>string</code>A unique identifier representing your end-user, for abuse monitoring.

▶web\_search\_options{}

<code>object</code>Options for the web search tool (when using built-in web search).

▶function\_call

<code>one of</code>

▶functions\[]

<code>array</code>minItems: 1maxItems: 128

type

<code>string</code>

contentType

<code>text/event-stream</code>

format

<code>binary</code>

</details>

<details>

<summary>Batch — Send multiple requests in a single API call</summary>



▶requests\[]

<code>array</code>

id

<code>string</code>A unique identifier for the chat completion.

object

<code>string</code>

created

<code>integer</code>Unix timestamp (seconds) of when the completion was created.

model

<code>string</code>The model used for the chat completion.

▶choices\[]

<code>array</code>minItems: 1

▶usage{}

<code>object</code>

system\_fingerprint

<code>string | null</code>

</details>

## API Schemas (Raw)

SynchronousInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/sync-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/sync-input.json)

SynchronousOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/sync-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/sync-output.json)

StreamingInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/streaming-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/streaming-input.json)

StreamingOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/streaming-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/streaming-output.json)

BatchInput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/batch-input.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/batch-input.json)

BatchOutput [Open](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/batch-output.json) [Download](https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/batch-output.json)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/#page","headline":"glm-5.3-flash","description":"The first natively multimodal model in the GLM-5 series. With 320B total parameters and just 18B active parameters, it outperforms GLM-5.2 across benchmarks and real-world workloads at one-tenth the price, while approaching Claude Opus 4.8 on coding and agentic benchmarks.","url":"https://developers.cloudflare.com/workers-ai/models/glm-5.3-flash/","inLanguage":"en","image":"https://developers.cloudflare.com/og-docs.png","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Use Workers AI models with the AI SDK through createAI from agents/models/ai-sdk.
title: Vercel AI SDK
image: https://developers.cloudflare.com/workers-ai/configuration/ai-sdk/og.png?v=6e60b4e5c89fbf07
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Vercel AI SDK

Last updated Oct 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/configuration/ai-sdk/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

To use Workers AI with the [AI SDK ↗︎](https://ai-sdk.dev/), use `createAI` from `agents/models/ai-sdk`. This page covers Workers AI models. For AI Gateway catalog models, fallback, gateway options, and the full option reference, refer to [AI SDK](https://developers.cloudflare.com/agents/models/ai-sdk/).

The `workers-ai-provider` package is deprecated. Use `createAI` instead.

## Setup

Install the Agents SDK and the AI SDK. `createAI` needs `ai@^7` and `@ai-sdk/provider@^4`:

npmyarnpnpmbun

```
npm i agents ai @ai-sdk/provider
```

```
yarn add agents ai @ai-sdk/provider
```

```
pnpm add agents ai @ai-sdk/provider
```

```
bun add agents ai @ai-sdk/provider
```

Add the `AI` binding to your Wrangler configuration:

```jsonc
{
	"ai": {
		"binding": "AI",
	},
}
```

```toml
[ai]
binding = "AI"
```

## Choose a model

Pass the id of any [Workers AI model](https://developers.cloudflare.com/workers-ai/models/). Model ids start with `@cf/` and autocomplete from `@cloudflare/workers-types`:

```ts
import { createAI } from "agents/models/ai-sdk";

const ai = createAI({ binding: env.AI });

const model = ai("@cf/zai-org/glm-4.7-flash");
```

## Generate text

```js
import { createAI } from "agents/models/ai-sdk";
import { generateText } from "ai";

export default {
	async fetch(request, env) {
		const ai = createAI({ binding: env.AI });

		const { text } = await generateText({
			model: ai("@cf/zai-org/glm-4.7-flash"),
			prompt: "Write a 50-word essay about hello world.",
		});

		return new Response(text);
	},
};
```

```ts
import { createAI } from "agents/models/ai-sdk";
import { generateText } from "ai";

export default {
	async fetch(request: Request, env: Env) {
		const ai = createAI({ binding: env.AI });

		const { text } = await generateText({
			model: ai("@cf/zai-org/glm-4.7-flash"),
			prompt: "Write a 50-word essay about hello world.",
		});

		return new Response(text);
	},
};
```

## Stream text

For longer responses, stream the output as the model generates it:

```js
import { createAI } from "agents/models/ai-sdk";
import { streamText } from "ai";

export default {
	async fetch(request, env) {
		const ai = createAI({ binding: env.AI });

		const result = streamText({
			model: ai("@cf/zai-org/glm-4.7-flash"),
			prompt: "Write a 50-word essay about hello world.",
		});

		return result.toTextStreamResponse();
	},
};
```

```ts
import { createAI } from "agents/models/ai-sdk";
import { streamText } from "ai";

export default {
	async fetch(request: Request, env: Env) {
		const ai = createAI({ binding: env.AI });

		const result = streamText({
			model: ai("@cf/zai-org/glm-4.7-flash"),
			prompt: "Write a 50-word essay about hello world.",
		});

		return result.toTextStreamResponse();
	},
};
```

## Generate structured output

Pass a Zod schema to get a typed JSON response:

```js
import { createAI } from "agents/models/ai-sdk";
import { generateText, Output } from "ai";
import { z } from "zod";

export default {
	async fetch(request, env) {
		const ai = createAI({ binding: env.AI });

		const { output } = await generateText({
			model: ai("@cf/zai-org/glm-4.7-flash"),
			prompt: "Generate a lasagna recipe.",
			output: Output.object({
				schema: z.object({
					recipe: z.object({
						ingredients: z.array(z.string()),
						description: z.string(),
					}),
				}),
			}),
		});

		return Response.json(output);
	},
};
```

```ts
import { createAI } from "agents/models/ai-sdk";
import { generateText, Output } from "ai";
import { z } from "zod";

export default {
	async fetch(request: Request, env: Env) {
		const ai = createAI({ binding: env.AI });

		const { output } = await generateText({
			model: ai("@cf/zai-org/glm-4.7-flash"),
			prompt: "Generate a lasagna recipe.",
			output: Output.object({
				schema: z.object({
					recipe: z.object({
						ingredients: z.array(z.string()),
						description: z.string(),
					}),
				}),
			}),
		});

		return Response.json(output);
	},
};
```

## Use other model types

Embeddings, images, speech, transcription, and reranking come from the same provider:

```ts
import {
	embedMany,
	generateImage,
	generateSpeech,
	rerank,
	transcribe,
} from "ai";

const { embeddings } = await embedMany({
	model: ai.embedding("@cf/baai/bge-base-en-v1.5"),
	values: ["hello", "world"],
});

const { image } = await generateImage({
	model: ai.image("@cf/black-forest-labs/flux-1-schnell"),
	prompt: "A cyberpunk lizard",
});

const { audio } = await generateSpeech({
	model: ai.speech("@cf/deepgram/aura-1"),
	text: "Hello from Cloudflare.",
});

const { text } = await transcribe({
	model: ai.transcription("@cf/openai/whisper-large-v3-turbo"),
	audio: audio.uint8Array,
});

const { rerankedDocuments } = await rerank({
	model: ai.reranking("@cf/baai/bge-reranker-base"),
	documents: ["a cyberpunk lizard", "a rainy Tuesday"],
	query: "Which one is cooler?",
});
```

For model-specific settings, refer to [Use other modalities](https://developers.cloudflare.com/agents/models/ai-sdk/#use-other-modalities).

## Use AI Gateway

Requests go through [AI Gateway](https://developers.cloudflare.com/ai-gateway/). The gateway defaults to `default`. To use another gateway, set its `id`:

```ts
const ai = createAI({ binding: env.AI, id: "my-gateway" });
```

The same provider also calls models from the [AI Gateway catalog](https://developers.cloudflare.com/ai/models/), such as `anthropic/claude-opus-5.5`. Refer to [AI SDK](https://developers.cloudflare.com/agents/models/ai-sdk/) for catalog models, caching, fallback, and the other gateway options.

## Related resources

- [AI SDK provider reference](https://developers.cloudflare.com/agents/models/ai-sdk/)
- [Workers AI models](https://developers.cloudflare.com/workers-ai/models/)
- [AI SDK documentation ↗︎](https://ai-sdk.dev/docs/introduction)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/configuration/ai-sdk/#page","headline":"Vercel AI SDK","description":"Use Workers AI models with the AI SDK through createAI from agents/models/ai-sdk.","url":"https://developers.cloudflare.com/workers-ai/configuration/ai-sdk/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/configuration/ai-sdk/og.png?v=6e60b4e5c89fbf07","dateModified":"2026-10-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Create an AI binding to connect your Cloudflare Worker to Workers AI.
title: Workers Bindings
image: https://developers.cloudflare.com/workers-ai/configuration/bindings/og.png?v=afa2e8cca2301ad1
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Workers Bindings

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/configuration/bindings/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

## Workers

[Workers](https://developers.cloudflare.com/workers/) provides a serverless execution environment that allows you to create new applications or augment existing ones.

To use Workers AI with Workers, you must create a Workers AI [binding](https://developers.cloudflare.com/workers/runtime-apis/bindings/). Bindings allow your Workers to interact with resources, like Workers AI, on the Cloudflare Developer Platform. You create bindings on the Cloudflare dashboard or by updating your [Wrangler file](https://developers.cloudflare.com/workers/wrangler/configuration/).

To bind Workers AI to your Worker, add the following to the end of your Wrangler file:

```jsonc
{
	"ai": {
		"binding": "AI" // i.e. available in your Worker on env.AI
	}
}
```

```toml
[ai]
binding = "AI"
```

## Pages Functions

[Pages Functions](https://developers.cloudflare.com/pages/functions/) allow you to build full-stack applications with Cloudflare Pages by executing code on the Cloudflare network. Functions are Workers under the hood.

To configure a Workers AI binding in your Pages Function, you must use the Cloudflare dashboard. Refer to [Workers AI bindings](https://developers.cloudflare.com/pages/functions/bindings/#workers-ai) for instructions.

## Methods

### async env.AI.run()

`async env.AI.run()` runs a model. Takes a model as the first parameter, and an object as the second parameter.

```javascript
const answer = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
    prompt: "What is the origin of the phrase 'Hello, World'"
});
```

**Parameters**

- `model` `string` required
  - The model to run.

  **Supported options**
  - `stream` `boolean` optional
    - Returns a stream of results as they are available.

```javascript
const answer = await env.AI.run('@cf/meta/llama-3.1-8b-instruct', {
    prompt: "What is the origin of the phrase 'Hello, World'",
    stream: true
});

return new Response(answer, {
    headers: { "content-type": "text/event-stream" }
});
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/configuration/bindings/#page","headline":"Workers Bindings","description":"Create an AI binding to connect your Cloudflare Worker to Workers AI.","url":"https://developers.cloudflare.com/workers-ai/configuration/bindings/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/configuration/bindings/og.png?v=afa2e8cca2301ad1","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Connect Workers AI models to Hugging Face's open-source Chat UI interface.
title: Hugging Face Chat UI
image: https://developers.cloudflare.com/workers-ai/configuration/hugging-face-chat-ui/og.png?v=e9b5c6da7ed0c500
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Hugging Face Chat UI

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/configuration/hugging-face-chat-ui/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Use Workers AI with [Chat UI ↗︎](https://github.com/huggingface/chat-ui?tab=readme-ov-file#text-embedding-models), an open-source chat interface offered by Hugging Face.

## Prerequisites

You will need the following:

- A [Cloudflare account ↗︎](https://dash.cloudflare.com)
- Your [Account ID](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/)
- An [API token](https://developers.cloudflare.com/workers-ai/get-started/rest-api/#1-get-api-token-and-account-id) for Workers AI

## Setup

First, decide how to reference your Account ID and API token (either directly in your `.env.local` using the `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_API_TOKEN` variables or in the endpoint configuration).

Then, follow the rest of the setup instructions in the [Chat UI GitHub repository ↗︎](https://github.com/huggingface/chat-ui?tab=readme-ov-file#text-embedding-models).

When setting up your models, specify the `cloudflare` endpoint.

```json
{
  "name" : "nousresearch/hermes-2-pro-mistral-7b",
  "tokenizer": "nousresearch/hermes-2-pro-mistral-7b",
  "parameters": {
    "stop": ["<|im_end|>"]
  },
  "endpoints" : [
    {
      "type": "cloudflare",
      // optionally specify these if not included in .env.local
      "accountId": "your-account-id",
      "apiToken": "your-api-token"
      //
    }
  ]
}
```

## Supported models

This template works with any [text generation models](https://developers.cloudflare.com/workers-ai/models/) that begin with the `@hf` parameter.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/configuration/hugging-face-chat-ui/#page","headline":"Hugging Face Chat UI","description":"Connect Workers AI models to Hugging Face's open-source Chat UI interface.","url":"https://developers.cloudflare.com/workers-ai/configuration/hugging-face-chat-ui/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/configuration/hugging-face-chat-ui/og.png?v=e9b5c6da7ed0c500","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Use the OpenAI SDK with Workers AI Chat Completions, embeddings, and supported GPT-OSS Responses requests.
title: OpenAI compatible API endpoints
image: https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/og.png?v=43d7808c7c4959b5
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# OpenAI compatible API endpoints

Last updated Sep 18, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Workers AI provides OpenAI-compatible endpoints for [text generation](https://developers.cloudflare.com/workers-ai/models/) through Chat Completions (`/v1/chat/completions`) and for [text embedding models](https://developers.cloudflare.com/workers-ai/models/) (`/v1/embeddings`). The Responses API (`/v1/responses`) is available only for GPT-OSS models. Easily call Workers AI by swapping the `baseURL` in the standard OpenAI SDK.

  

## Usage

### Chat Completions and embeddings

Most Workers AI text generation models support the OpenAI Chat Completions API. Embedding models support the OpenAI Embeddings API.

Use the [OpenAI JavaScript SDK ↗︎](https://github.com/openai/openai-node) by setting the Workers AI base URL, API token, and model name.

*OpenAI SDK examplejs*

```js
import OpenAI from "openai";

const openai = new OpenAI({
	apiKey: env.CLOUDFLARE_API_KEY,
	baseURL: `https://api.cloudflare.com/client/v4/accounts/${env.CLOUDFLARE_ACCOUNT_ID}/ai/v1`,
});

const chatCompletion = await openai.chat.completions.create({
	messages: [{ role: "user", content: "Make some robot noises" }],
	model: "@cf/meta/llama-3.1-8b-instruct",
});

const embeddings = await openai.embeddings.create({
	model: "@cf/baai/bge-large-en-v1.5",
	input: "I love matcha",
});
```

*cURL examplebash*

```bash
curl --request POST \
  --url https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/v1/chat/completions \
  --header "Authorization: Bearer {api_token}" \
  --header "Content-Type: application/json" \
  --data '
    {
      "model": "@cf/meta/llama-3.1-8b-instruct",
      "messages": [
        {
          "role": "user",
          "content": "how to build a wooden spoon in 3 short steps? give as short as answer as possible"
        }
      ]
    }
'
```

### Fail fast when capacity is unavailable

For synchronous Chat Completions, set `options.rejectIfBusy` in the top-level request body. This makes the request fail instead of waiting in a capacity queue.

OpenAI clients that preserve custom fields can send this option. Clients that remove unknown fields do not apply it, so requests proceed normally.

Refer to [Reject busy requests](https://developers.cloudflare.com/workers-ai/features/reject-if-busy/) for examples and error behavior.

### Responses API for GPT-OSS

The Responses API is supported only by the [`@cf/openai/gpt-oss-120b`](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/) and [`@cf/openai/gpt-oss-20b`](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/) models. Responses requests must be non-streaming, only `stream: false` is supported.

*GPT-OSS Responses API examplejs*

```js
import OpenAI from "openai";

const openai = new OpenAI({
	apiKey: env.CLOUDFLARE_API_KEY,
	baseURL: `https://api.cloudflare.com/client/v4/accounts/${env.CLOUDFLARE_ACCOUNT_ID}/ai/v1`,
});

const response = await openai.responses.create({
	model: "@cf/openai/gpt-oss-120b",
	input: "Talk to me about open source",
});
```

### AI Gateway

These endpoints are also compatible with [AI Gateway](https://developers.cloudflare.com/ai-gateway/usage/providers/workersai/#openai-compatible-endpoints).

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/#page","headline":"OpenAI compatible API endpoints","description":"Use the OpenAI SDK with Workers AI Chat Completions, embeddings, and supported GPT-OSS Responses requests.","url":"https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/og.png?v=43d7808c7c4959b5","dateModified":"2026-09-18","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Use Workers AI models with Pi AI through createAI from agents/models/pi-ai.
title: Pi AI
image: https://developers.cloudflare.com/workers-ai/configuration/pi-ai/og.png?v=927ed23e0b5e5a1a
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Pi AI

Last updated Nov 3, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/configuration/pi-ai/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

To use Workers AI with [Pi AI ↗︎](https://github.com/earendil-works/pi/tree/main/packages/ai), use `createAI` from `agents/models/pi-ai`. It returns Pi AI `Model` objects, so Workers AI models work with Pi AI's `stream` and `complete`, with [Pi Durable ↗︎](https://github.com/earendil-works/pi/tree/main/packages/durable), and with the [Pi harness](https://developers.cloudflare.com/agents/harnesses/pi/). This page covers Workers AI models. For AI Gateway catalog models, fallback, gateway options, and the full reference, refer to [Pi AI](https://developers.cloudflare.com/agents/models/pi-ai/).

## Setup

Install the Agents SDK and Pi AI. `createAI` needs `@earendil-works/pi-ai@~1.5.0`:

npmyarnpnpmbun

```
npm i agents @earendil-works/pi-ai
```

```
yarn add agents @earendil-works/pi-ai
```

```
pnpm add agents @earendil-works/pi-ai
```

```
bun add agents @earendil-works/pi-ai
```

Add the `AI` binding to your Wrangler configuration:

```jsonc
{
	"ai": {
		"binding": "AI",
	},
}
```

```toml
[ai]
binding = "AI"
```

## Generate text

Name a Workers AI model by its `@cf/` id. The provider carries Pi AI's entry points, so nothing is registered globally:

```js
import { createAI } from "agents/models/pi-ai";

export default {
	async fetch(request, env) {
		const ai = createAI({ binding: env.AI });

		const reply = await ai.complete(ai("@cf/zai-org/glm-4.7-flash"), {
			messages: [
				{ role: "user", content: "What is Cloudflare?", timestamp: Date.now() },
			],
		});

		// `content` holds text, thinking, and tool call parts.
		const text = reply.content
			.filter((part) => part.type === "text")
			.map((part) => part.text)
			.join("");

		return Response.json({ text });
	},
};
```

```ts
import { createAI } from "agents/models/pi-ai";

export default {
	async fetch(request: Request, env: Env) {
		const ai = createAI({ binding: env.AI });

		const reply = await ai.complete(ai("@cf/zai-org/glm-4.7-flash"), {
			messages: [
				{ role: "user", content: "What is Cloudflare?", timestamp: Date.now() },
			],
		});

		// `content` holds text, thinking, and tool call parts.
		const text = reply.content
			.filter((part) => part.type === "text")
			.map((part) => part.text)
			.join("");

		return Response.json({ text });
	},
};
```

## Stream text

`ai.stream()` returns Pi AI's event stream. `ai.streamSimple()` and `ai.completeSimple()` take Pi AI's simple options, such as a `reasoning` level and `maxTokens`:

```ts
const model = ai("@cf/zai-org/glm-4.7-flash");
const context = {
	messages: [{ role: "user", content: "Hi", timestamp: Date.now() }],
};

for await (const event of ai.stream(model, context)) {
	// text_delta, thinking_delta, toolcall_*, done, error
}
```

A compatibility layer turns each Workers AI model's response into the shape Pi AI's parsers read, so tool calls and reasoning work the same across model families.

## Set model details

A Workers AI id that Pi AI does not list resolves with a 128,000 token context window, 8,192 output tokens, and zero cost. Pass the real values when you know them:

```ts
const model = ai("@cf/zai-org/glm-4.7-flash", {
	contextWindow: 131_072,
	maxTokens: 16_384,
});
```

## Generate images

```ts
const images = ai.images("@cf/black-forest-labs/flux-1-schnell", { steps: 8 });
const result = await ai.generateImages(images, {
	input: [{ type: "text", text: "A red bicycle" }],
});
```

## Use AI Gateway

Every request goes through AI Gateway. Set the gateway with `id`, which defaults to `default`:

```ts
const ai = createAI({ binding: env.AI, id: "my-gateway" });
```

To call from outside a Worker, pass `accountId` and `apiToken` instead of `binding`. For gateway options, catalog models, and fallback, refer to [Pi AI](https://developers.cloudflare.com/agents/models/pi-ai/).

## Related resources

- [Pi AI provider reference](https://developers.cloudflare.com/agents/models/pi-ai/)
- [Pi harness](https://developers.cloudflare.com/agents/harnesses/pi/)
- [Workers AI models](https://developers.cloudflare.com/workers-ai/models/)
- [Vercel AI SDK](https://developers.cloudflare.com/workers-ai/configuration/ai-sdk/)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/configuration/pi-ai/#page","headline":"Pi AI","description":"Use Workers AI models with Pi AI through createAI from agents/models/pi-ai.","url":"https://developers.cloudflare.com/workers-ai/configuration/pi-ai/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/configuration/pi-ai/og.png?v=927ed23e0b5e5a1a","dateModified":"2026-11-03","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Queue large inference workloads for asynchronous processing with the Workers AI Batch API.
title: Asynchronous Batch API
image: https://developers.cloudflare.com/workers-ai/features/batch-api/og.png?v=77cfb4ef80ef74d9
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Asynchronous Batch API

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/batch-api/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Asynchronous batch processing lets you send a collection (batch) of inference requests in a single call. Instead of expecting immediate responses for every request, the system queues them for processing and returns the results later.

Batch processing is useful for large workloads such as summarization or embeddings when there is no human interaction. Using the batch API will guarantee that your requests are fulfilled eventually, rather than erroring out if Cloudflare does not have enough capacity at a given time.

When you send a batch request, the API immediately acknowledges receipt with a status like `queued` and provides a unique `request_id`. This ID is later used to poll for the final responses once the processing is complete.

You can use the Batch API by either creating and deploying a Cloudflare Worker that leverages the [Batch API with the AI binding](https://developers.cloudflare.com/workers-ai/features/batch-api/workers-binding/), using the [REST API](https://developers.cloudflare.com/workers-ai/features/batch-api/rest-api/) directly or by starting from a [template ↗︎](https://github.com/craigsdennis/batch-please-workers-ai).

Note

Ensure that the total payload is under 10 MB.

## Demo application

If you want to get started quickly, click the button below:

[![Deploy to Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/craigsdennis/batch-please-workers-ai)

This will create a repository in your GitHub account and deploy a ready-to-use Worker that demonstrates how to use Cloudflare's Asynchronous Batch API. The template includes preconfigured AI bindings, and examples for sending and retrieving batch requests with and without external references. Once deployed, you can visit the live Worker and start experimenting with the Batch API immediately.

## Supported Models

Refer to our [model catalog](https://developers.cloudflare.com/workers-ai/models/?capabilities=Batch) for supported models.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/batch-api/#page","headline":"Asynchronous Batch API","description":"Queue large inference workloads for asynchronous processing with the Workers AI Batch API.","url":"https://developers.cloudflare.com/workers-ai/features/batch-api/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/batch-api/og.png?v=77cfb4ef80ef74d9","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Send and retrieve batch inference requests using the Workers AI REST API.
title: REST API
image: https://developers.cloudflare.com/workers-ai/features/batch-api/rest-api/og.png?v=5b1fb19ca805e26f
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# REST API

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/batch-api/rest-api/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

If you prefer to work directly with the REST API instead of a [Cloudflare Worker](https://developers.cloudflare.com/workers-ai/features/batch-api/workers-binding/), below are the steps on how to do it:

## 1. Sending a Batch Request

Make a POST request using the following pattern. You can pass `external_reference` as a unique ID per-request that will be returned in the response.

*Sending a batch requestbash*

```bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/run/@cf/baai/bge-m3?queueRequest=true" \
 --header "Authorization: Bearer $API_TOKEN" \
 --header 'Content-Type: application/json' \
 --json '{
    "requests": [
        {
            "query": "This is a story about Cloudflare",
            "contexts": [
                {
                    "text": "This is a story about an orange cloud"
                },
                {
                    "text": "This is a story about a llama"
                },
                {
                    "text": "This is a story about a hugging emoji"
                }
            ],
            "external_reference": "reference-1"
        }
    ]
  }'
```

```json
{
	"result": {
		"status": "queued",
		"request_id": "768f15b7-4fd6-4498-906e-ad94ffc7f8d2",
		"model": "@cf/baai/bge-m3"
	},
	"success": true,
	"errors": [],
	"messages": []
}
```

## 2. Retrieving the Batch Response

After receiving a `request_id` from your initial POST, you can poll for or retrieve the results with another POST request:

*Retrieving a responsebash*

```bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/run/@cf/baai/bge-m3?queueRequest=true" \
 --header "Authorization: Bearer $API_TOKEN" \
 --header 'Content-Type: application/json' \
 --json '{
    "request_id": "<uuid>"
  }'
```

```json
{
	"result": {
		"responses": [
			{
				"id": 0,
				"result": {
					"response": [
						{ "id": 0, "score": 0.73974609375 },
						{ "id": 1, "score": 0.642578125 },
						{ "id": 2, "score": 0.6220703125 }
					]
				},
				"success": true,
				"external_reference": "reference-1"
			}
		],
		"usage": { "prompt_tokens": 12, "completion_tokens": 0, "total_tokens": 12 }
	},
	"success": true,
	"errors": [],
	"messages": []
}
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/batch-api/rest-api/#page","headline":"REST API","description":"Send and retrieve batch inference requests using the Workers AI REST API.","url":"https://developers.cloudflare.com/workers-ai/features/batch-api/rest-api/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/batch-api/rest-api/og.png?v=5b1fb19ca805e26f","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Send and retrieve batch inference requests using a Workers AI binding.
title: Workers Binding
image: https://developers.cloudflare.com/workers-ai/features/batch-api/workers-binding/og.png?v=4c5daf24a38904a5
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Workers Binding

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/batch-api/workers-binding/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

You can use Workers Bindings to interact with the Batch API.

## Send a Batch request

Send your initial batch inference request by composing a JSON payload containing an array of individual inference requests and the `queueRequest: true` property (which is what controls queueing behavior).

Note

Ensure that the total payload is under 10 MB.

*src/index.tsts*

```ts
export interface Env {
	AI: Ai;
}
export default {
	async fetch(request, env): Promise<Response> {
		const embeddings = await env.AI.run(
			"@cf/baai/bge-m3",
			{
				requests: [
					{
						query: "This is a story about Cloudflare",
						contexts: [
							{
								text: "This is a story about an orange cloud",
							},
							{
								text: "This is a story about a llama",
							},
							{
								text: "This is a story about a hugging emoji",
							},
						],
					},
				],
			},
			{ queueRequest: true },
		);

		return Response.json(embeddings);
	},
} satisfies ExportedHandler<Env>;
```

```json
{
	"status": "queued",
	"model": "@cf/baai/bge-m3",
	"request_id": "000-000-000"
}
```

You will get a response with the following values:

- **`status`**: Indicates that your request is queued.
- **`request_id`**: A unique identifier for the batch request.
- **`model`**: The model used for the batch inference.

Of these, the `request_id` is important for when you need to [poll the batch status](#poll-batch-status).

### Poll batch status

Once your batch request is queued, use the `request_id` to poll for its status. During processing, the API returns a status `queued` or `running` indicating that the request is still in the queue or being processed.

```typescript
export interface Env {
	AI: Ai;
}

export default {
	async fetch(request, env): Promise<Response> {
		const status = await env.AI.run("@cf/baai/bge-m3", {
			request_id: "000-000-000",
		});

		return Response.json(status);
	},
} satisfies ExportedHandler<Env>;
```

```json
{
	"responses": [
		{
			"id": 0,
			"result": {
				"response": [
					{ "id": 0, "score": 0.73974609375 },
					{ "id": 1, "score": 0.642578125 },
					{ "id": 2, "score": 0.6220703125 }
				]
			},
			"success": true,
			"external_reference": "reference-1"
		}
	],
	"usage": { "prompt_tokens": 12, "completion_tokens": 0, "total_tokens": 12 }
}
```

When the inference is complete, the API returns a final HTTP status code of `200` along with an array of responses. Each response object corresponds to an individual input prompt, identified by an `id` that maps to the index of the prompt in your original request.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/batch-api/workers-binding/#page","headline":"Workers Binding","description":"Send and retrieve batch inference requests using a Workers AI binding.","url":"https://developers.cloudflare.com/workers-ai/features/batch-api/workers-binding/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/batch-api/workers-binding/og.png?v=4c5daf24a38904a5","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Run fine-tuned inference on Workers AI using LoRA adapters.
title: Fine-tunes
image: https://developers.cloudflare.com/workers-ai/features/fine-tunes/og.png?v=4894bcc654d8841f
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Fine-tunes

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/fine-tunes/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Learn how to use Workers AI to get fine-tuned inference.

[Fine-tuned inference with LoRAs](https://developers.cloudflare.com/workers-ai/features/fine-tunes/loras/)

Upload a LoRA adapter and run fine-tuned inference with one of our base models.

Run inference with LoRAs

---

## What is fine-tuning?

Fine-tuning is a general term for modifying an AI model by continuing to train it with additional data. The goal of fine-tuning is to increase the probability that a generation is similar to your dataset. Training a model from scratch is not practical for many use cases given how expensive and time consuming they can be to train. By fine-tuning an existing pre-trained model, you benefit from its capabilities while also accomplishing your desired task.

[Low-Rank Adaptation ↗︎](https://arxiv.org/abs/2106.09685) (LoRA) is a specific fine-tuning method that can be applied to various model architectures, not just LLMs. It is common that the pre-trained model weights are directly modified or fused with additional fine-tune weights in traditional fine-tuning methods. LoRA, on the other hand, allows for the fine-tune weights and pre-trained model to remain separate, and for the pre-trained model to remain unchanged. The end result is that you can train models to be more accurate at specific tasks, such as generating code, having a specific personality, or generating images in a specific style.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/features/fine-tunes/#page","headline":"Fine-tunes","description":"Run fine-tuned inference on Workers AI using LoRA adapters.","url":"https://developers.cloudflare.com/workers-ai/features/fine-tunes/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/fine-tunes/og.png?v=4894bcc654d8841f","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Upload and use LoRA adapters to get fine-tuned inference on Workers AI.
title: Using LoRA adapters
image: https://developers.cloudflare.com/workers-ai/features/fine-tunes/loras/og.png?v=5ab5aeb1f6d4d456
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Using LoRA adapters

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/fine-tunes/loras/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Workers AI supports fine-tuned inference with adapters trained with [Low-Rank Adaptation ↗︎](https://blog.cloudflare.com/fine-tuned-inference-with-loras). This feature is in open beta and free during this period.

## Limitations

- We only support LoRAs for a [variety of models](https://developers.cloudflare.com/workers-ai/models/?capabilities=LoRA) (must not be quantized)
- Adapter must be trained with rank `r <=8` as well as larger ranks if up to 32. You can check the rank of a pre-trained LoRA adapter through the adapter's `config.json` file
- LoRA adapter file must be < 300MB
- LoRA adapter files must be named `adapter_config.json` and `adapter_model.safetensors` exactly
- You can test up to 100 LoRA adapters per account

---

## Choosing compatible LoRA adapters

### Finding open-source LoRA adapters

We have started a [Hugging Face Collection ↗︎](https://huggingface.co/collections/Cloudflare/workers-ai-compatible-loras-6608dd9f8d305a46e355746e) that lists a few LoRA adapters that are compatible with Workers AI. Generally, any LoRA adapter that fits our limitations above should work.

### Training your own LoRA adapters

To train your own LoRA adapter, follow the [tutorial](https://developers.cloudflare.com/workers-ai/guides/tutorials/fine-tune-models-with-autotrain/).

---

## Uploading LoRA adapters

In order to run inference with LoRAs on Workers AI, you'll need to create a new fine tune on your account and upload your adapter files. You should have a `adapter_model.safetensors` file with model weights and `adapter_config.json` with your config information. *Note that we only accept adapter files in these types.*

Right now, you can't edit a fine tune's asset files after you upload it. We will support this soon, but for now you will need to create a new fine tune and upload files again if you would like to use a new LoRA.

Before you upload your LoRA adapter, you'll need to edit your `adapter_config.json` file to include `model_type` as one of `mistral`, `gemma` or `llama` like below.

```json
{
  "alpha_pattern": {},
  "auto_mapping": null,
  ...
  "target_modules": [
    "q_proj",
    "v_proj"
  ],
  "task_type": "CAUSAL_LM",
  "model_type": "mistral",
}
```

### Wrangler

You can create a finetune and upload your LoRA adapter via wrangler with the following commands:

*wrangler CLIbash*

```bash
npx wrangler ai finetune create <model_name> <finetune_name> <folder_path>
#🌀 Creating new finetune "test-lora" for model "@cf/mistral/mistral-7b-instruct-v0.2-lora"...
#🌀 Uploading file "/Users/abcd/Downloads/adapter_config.json" to "test-lora"...
#🌀 Uploading file "/Users/abcd/Downloads/adapter_model.safetensors" to "test-lora"...
#✅ Assets uploaded, finetune "test-lora" is ready to use.

npx wrangler ai finetune list
┌──────────────────────────────────────┬─────────────────┬─────────────┐
│ finetune_id                          │ name            │ description │
├──────────────────────────────────────┼─────────────────┼─────────────┤
│ 00000000-0000-0000-0000-000000000000 │ test-lora       │             │
└──────────────────────────────────────┴─────────────────┴─────────────┘
```

### REST API

Alternatively, you can use our REST API to create a finetune and upload your adapter files. You will need a Cloudflare API Token with `Workers AI: Edit` permissions to make calls to our REST API, which you can generate via the Cloudflare Dashboard.

#### Creating a fine-tune on your account

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

- <code>Workers AI Write</code>

</details>

*Create a new Finetunebash*

```bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/finetunes" \
	--request POST \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
	--json '{
		"model": "SUPPORTED_MODEL_NAME",
		"name": "FINETUNE_NAME",
		"description": "OPTIONAL_DESCRIPTION"
	}'
```

#### Uploading your adapter weights and config

You have to call the upload endpoint each time you want to upload a new file, so you usually run this once for `adapter_model.safetensors` and once for `adapter_config.json`. Make sure you include the `@` before your path to files.

You can either use the finetune `name` or `id` that you used when you created the fine tune.

*cURLbash*

```bash
## Input: finetune_id, adapter_model.safetensors, then adapter_config.json
## Output: success true/false

curl -X POST https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/finetunes/{FINETUNE_ID}/finetune-assets/ \
    -H 'Authorization: Bearer {API_TOKEN}' \
    -H 'Content-Type: multipart/form-data' \
    -F 'file_name=adapter_model.safetensors' \
    -F 'file=@{PATH/TO/adapter_model.safetensors}'
```

#### List fine-tunes in your account

You can call this method to confirm what fine-tunes you have created in your account

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

- <code>Workers AI Write</code>
- <code>Workers AI Read</code>

</details>

*List Finetunesbash*

```bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/finetunes" \
	--request GET \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
```

```json
{
	"success": true,
	"result": [
		[
			{
				"id": "00000000-0000-0000-0000-000000000",
				"model": "@cf/meta-llama/llama-2-7b-chat-hf-lora",
				"name": "llama2-finetune",
				"description": "test"
			},
			{
				"id": "00000000-0000-0000-0000-000000000",
				"model": "@cf/mistralai/mistral-7b-instruct-v0.2-lora",
				"name": "mistral-finetune",
				"description": "test"
			}
		]
	]
}
```

---

## Running inference with LoRAs

To make inference requests and apply the LoRA adapter, you will need your model and finetune `name` or `id`. You should use the chat template that your LoRA was trained on, but you can try running it with `raw: true` and the messages template like below.

```javascript
const response = await env.AI.run(
	"@cf/mistralai/mistral-7b-instruct-v0.2-lora", //the model supporting LoRAs
	{
		messages: [{ role: "user", content: "Hello world" }],
		raw: true, //skip applying the default chat template
		lora: "00000000-0000-0000-0000-000000000", //the finetune id OR name
	},
);
```

```bash
curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/run/@cf/mistral/mistral-7b-instruct-v0.2-lora \
  -H 'Authorization: Bearer {API_TOKEN}' \
  -d '{
    "messages": [{"role": "user", "content": "Hello world"}],
    "raw": "true",
    "lora": "00000000-0000-0000-0000-000000000"
  }'
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/fine-tunes/loras/#page","headline":"Using LoRA adapters","description":"Upload and use LoRA adapters to get fine-tuned inference on Workers AI.","url":"https://developers.cloudflare.com/workers-ai/features/fine-tunes/loras/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/fine-tunes/loras/og.png?v=5ab5aeb1f6d4d456","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Cloudflare offers a few public LoRA adapters that are immediately ready for use.
title: Public LoRA adapters
image: https://developers.cloudflare.com/workers-ai/features/fine-tunes/public-loras/og.png?v=814cbee783f5a721
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Public LoRA adapters

Last updated Jun 5, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/fine-tunes/public-loras/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Cloudflare offers a few public LoRA adapters that can immediately be used for fine-tuned inference. You can try them out immediately via our [playground ↗︎](https://playground.ai.cloudflare.com).

Public LoRAs will have the name `cf-public-x`, and the prefix will be reserved for Cloudflare.

Note

Have more LoRAs you would like to see? Let us know on [Discord ↗︎](https://discord.cloudflare.com).

| Name | Description | Compatible with |
| --- | --- | --- |
| [cf-public-magicoder ↗︎](https://huggingface.co/predibase/magicoder) | Coding tasks in multiple languages | `@cf/mistral/mistral-7b-instruct-v0.1` <br> `@hf/mistral/mistral-7b-instruct-v0.2` |
| [cf-public-jigsaw-classification ↗︎](https://huggingface.co/predibase/jigsaw) | Toxic comment classification | `@cf/mistral/mistral-7b-instruct-v0.1` <br> `@hf/mistral/mistral-7b-instruct-v0.2` |
| [cf-public-cnn-summarization ↗︎](https://huggingface.co/predibase/cnn) | Article summarization | `@cf/mistral/mistral-7b-instruct-v0.1` <br> `@hf/mistral/mistral-7b-instruct-v0.2` |

You can also list these public LoRAs with an API call:

<details>

<summary>

Required API token permissions

</summary>

At least one of the following <a href="https://developers.cloudflare.com/fundamentals/api/reference/permissions/">token permissions</a> is required:

- <code>Workers AI Write</code>
- <code>Workers AI Read</code>

</details>

*List Public Finetunesbash*

```bash
curl "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/finetunes/public" \
	--request GET \
	--header "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
```

## Running inference with public LoRAs

To run inference with public LoRAs, you just need to define the LoRA name in the request.

We recommend that you use the prompt template that the LoRA was trained on. You can find this in the HuggingFace repos linked above for each adapter.

### cURL

```bash
curl https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/mistral/mistral-7b-instruct-v0.1 \
  --header 'Authorization: Bearer {cf_token}' \
  --data '{
    "messages": [
      {
        "role": "user",
        "content": "Write a python program to check if a number is even or odd."
      }
    ],
    "lora": "cf-public-magicoder"
  }'
```

### JavaScript

```js
const answer = await env.AI.run("@cf/mistral/mistral-7b-instruct-v0.1", {
	stream: true,
	raw: true,
	messages: [
		{
			role: "user",
			content:
				"Summarize the following: Some newspapers, TV channels and well-known companies publish false news stories to fool people on 1 April. One of the earliest examples of this was in 1957 when a programme on the BBC, the UKs national TV channel, broadcast a report on how spaghetti grew on trees. The film showed a family in Switzerland collecting spaghetti from trees and many people were fooled into believing it, as in the 1950s British people didn't eat much pasta and many didn't know how it was made! Most British people wouldnt fall for the spaghetti trick today, but in 2008 the BBC managed to fool their audience again with their Miracles of Evolution trailer, which appeared to show some special penguins that had regained the ability to fly. Two major UK newspapers, The Daily Telegraph and the Daily Mirror, published the important story on their front pages.",
		},
	],
	lora: "cf-public-cnn-summarization",
});
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/fine-tunes/public-loras/#page","headline":"Public LoRA adapters","description":"Cloudflare offers a few public LoRA adapters that are immediately ready for use.","url":"https://developers.cloudflare.com/workers-ai/features/fine-tunes/public-loras/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/fine-tunes/public-loras/og.png?v=814cbee783f5a721","dateModified":"2026-06-05","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Enable Workers AI models to execute functions and interact with external APIs.
title: Function calling
image: https://developers.cloudflare.com/workers-ai/features/function-calling/og.png?v=2747bbb068ab45ae
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Function calling

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/function-calling/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Function calling enables people to take Large Language Models (LLMs) and use the model response to execute functions or interact with external APIs. The developer usually defines a set of functions and the required input schema for each function, which we call `tools`. The model then intelligently understands when it needs to do a tool call, and it returns a JSON output which the user needs to feed to another function or API.

In essence, function calling allows you to perform actions with LLMs by executing code or making additional API calls.

## How can I use function calling?

Workers AI has [embedded function calling](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/) which allows you to execute function code alongside your inference calls. We have a package called [`@cloudflare/ai-utils` ↗︎](https://www.npmjs.com/package/@cloudflare/ai-utils) to help facilitate this, which we have open-sourced on [Github ↗︎](https://github.com/cloudflare/ai-utils).

For industry-standard function calling, take a look at the documentation on [Traditional Function Calling](https://developers.cloudflare.com/workers-ai/features/function-calling/traditional/).

To show you the value of embedded function calling, take a look at the example below that compares traditional function calling with embedded function calling. Embedded function calling allowed us to cut down the lines of code from 77 to 31.

```sh
# The ai-utils package enables embedded function calling
npm i @cloudflare/ai-utils
```

*Embedded function calling examplejs*

```js
import {
	createToolsFromOpenAPISpec,
	runWithTools,
	autoTrimTools,
} from "@cloudflare/ai-utils";

export default {
	async fetch(request, env, ctx) {
		const response = await runWithTools(
			env.AI,
			"@hf/nousresearch/hermes-2-pro-mistral-7b",
			{
				messages: [{ role: "user", content: "Who is Cloudflare on github?" }],
				tools: [
					// You can pass the OpenAPI spec link or contents directly
					...(await createToolsFromOpenAPISpec(
						"https://gist.githubusercontent.com/mchenco/fd8f20c8f06d50af40b94b0671273dc1/raw/f9d4b5cd5944cc32d6b34cad0406d96fd3acaca6/partial_api.github.com.json",
						{
							overrides: [
								{
									// for all requests on *.github.com, we'll need to add a User-Agent.
									matcher: ({ url, method }) => {
										return url.hostname === "api.github.com";
									},
									values: {
										headers: {
											"User-Agent":
												"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
										},
									},
								},
							],
						},
					)),
				],
			},
		).then((response) => {
			return response;
		});

		return new Response(JSON.stringify(response));
	},
};
```

*Traditional function calling examplejs*

```js
export default {
	async fetch(request, env, ctx) {
		const response = await env.AI.run(
			"@hf/nousresearch/hermes-2-pro-mistral-7b",
			{
				messages: [{ role: "user", content: "Who is Cloudflare on GitHub?" }],
				tools: [
					{
						name: "getGithubUser",
						description:
							"Provides publicly available information about someone with a GitHub account.",
						parameters: {
							type: "object",
							properties: {
								username: {
									type: "string",
									description: "The handle for the GitHub user account.",
								},
							},
							required: ["username"],
						},
					},
				],
			},
		);

		const selected_tool = response.tool_calls[0];
		let res;

		if (selected_tool.name == "getGithubUser") {
			try {
				const username = selected_tool.arguments.username;
				const url = `https://api.github.com/users/${username}`;
				res = await fetch(url, {
					headers: {
						// Github API requires a User-Agent header
						"User-Agent":
							"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/112.0.0.0 Safari/537.36",
					},
				}).then((res) => res.json());
			} catch (error) {
				return error;
			}
		}

		const finalResponse = await env.AI.run(
			"@hf/nousresearch/hermes-2-pro-mistral-7b",
			{
				messages: [
					{
						role: "user",
						content: "Who is Cloudflare on GitHub?",
					},
					{
						role: "assistant",
						content: JSON.stringify(selected_tool),
					},
					{
						role: "tool",
						content: JSON.stringify(res),
					},
				],
				tools: [
					{
						name: "getGithubUser",
						description:
							"Provides publicly available information about someone with a GitHub account.",
						parameters: {
							type: "object",
							properties: {
								username: {
									type: "string",
									description: "The handle for the GitHub user account.",
								},
							},
							required: ["username"],
						},
					},
				],
			},
		);
		return new Response(JSON.stringify(finalResponse));
	},
};
```

## What models support function calling?

There are open-source models which have been fine-tuned to do function calling. When browsing our [model catalog](https://developers.cloudflare.com/workers-ai/models/), look for models with the function calling property beside it. For example, [@hf/nousresearch/hermes-2-pro-mistral-7b](https://developers.cloudflare.com/workers-ai/models/hermes-2-pro-mistral-7b/) is a fine-tuned variant of Mistral 7B that you can use for function calling.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/features/function-calling/#page","headline":"Function calling","description":"Enable Workers AI models to execute functions and interact with external APIs.","url":"https://developers.cloudflare.com/workers-ai/features/function-calling/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/function-calling/og.png?v=2747bbb068ab45ae","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["LLM"]}
```

---

---
description: Execute function code alongside inference calls using Workers AI embedded function calling.
title: Embedded
image: https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/og.png?v=8834403aa34ffd28
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Embedded

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Cloudflare has a unique [embedded function calling ↗︎](https://blog.cloudflare.com/embedded-function-calling) feature that allows you to execute function code alongside your tool call inference. Our npm package [`@cloudflare/ai-utils` ↗︎](https://www.npmjs.com/package/@cloudflare/ai-utils) is the developer toolkit to get started.

Embedded function calling can be used to easily make complex agents that interact with websites and APIs, like using natural language to create meetings on Google Calendar, saving data to Notion, automatically routing requests to other APIs, saving data to an R2 bucket - or all of this at the same time. All you need is a prompt and an OpenAPI spec to get started.

REST API support

Embedded function calling depends on features native to the Workers platform. This means that embedded function calling is only supported via [Cloudflare Workers](https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/), not via the [REST API](https://developers.cloudflare.com/workers-ai/get-started/rest-api/).

## Resources

- [Get Started](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/get-started/)
- [Examples](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/)
- [API Reference](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/api-reference/)
- [Troubleshooting](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/troubleshooting/)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/#page","headline":"Embedded","description":"Execute function code alongside inference calls using Workers AI embedded function calling.","url":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/og.png?v=8834403aa34ffd28","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Reference for the runWithTools and autoTrimTools methods in embedded function calling.
title: API Reference
image: https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/api-reference/og.png?v=b717d7f8d4ddf28e
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# API Reference

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/api-reference/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Learn more about the API reference for [embedded function calling](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded).

## runWithTools

This wrapper method enables you to do embedded function calling. You pass it the AI binding, model, inputs (`messages` array and `tools` array), and optional configurations.

- `AI Binding`Ai
  - The AI binding, such as `env.AI`.
- `model`BaseAiTextGenerationModels
  - The ID of the model that supports function calling. For example, `@hf/nousresearch/hermes-2-pro-mistral-7b`.
- `input`Object
  - `messages`RoleScopedChatInput\[]
  - `tools`AiTextGenerationToolInputWithFunction\[]
- `config`Object
  - `streamFinalResponse`boolean optional
  - `maxRecursiveToolRuns`number optional
  - `strictValidation`boolean optional
  - `verbose`boolean optional
  - `trimFunction`boolean optional - For the `trimFunction`, you can pass it `autoTrimTools`, which is another helper method we've devised to automatically choose the correct tools (using an LLM) before sending it off for inference. This means that your final inference call will have fewer input tokens.

## createToolsFromOpenAPISpec

This method lets you automatically create tool schemas based on OpenAPI specs, so you don't have to manually write or hardcode the tool schemas. You can pass the OpenAPI spec for any API in JSON or YAML format.

`createToolsFromOpenAPISpec` has a config input that allows you to perform overrides if you need to provide headers like Authentication or User-Agent.

- `spec`string
  - The OpenAPI specification in either JSON or YAML format, or a URL to a remote OpenAPI specification.
- `config`Config optional - Configuration options for the createToolsFromOpenAPISpec function
  - `overrides`ConfigRule\[] optional
  - `matchPatterns`RegExp\[] optional
  - `options` Object optional { `verbose` boolean optional }

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/api-reference/#page","headline":"API Reference","description":"Reference for the runWithTools and autoTrimTools methods in embedded function calling.","url":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/api-reference/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/api-reference/og.png?v=b717d7f8d4ddf28e","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Learn how to use the fetch() handler in Cloudflare Workers AI to enable LLMs to perform API calls, like retrieving a 5-day weather forecast using function calling.
title: Use fetch() handler
image: https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/fetch/og.png?v=840b375b65ba0cf7
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Use fetch() handler

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/fetch/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

A very common use case is to provide the LLM with the ability to perform API calls via function calling.

In this example the LLM will retrieve the weather forecast for the next 5 days. To do so a `getWeather` function is defined that is passed to the LLM as tool.

The `getWeather`function extracts the user's location from the request and calls the external weather API via the Workers' [`Fetch API`](https://developers.cloudflare.com/workers/runtime-apis/fetch/) and returns the result.

*Embedded function calling example with fetch()ts*

```ts
import { runWithTools } from '@cloudflare/ai-utils';

type Env = {
	AI: Ai;
};

export default {
	async fetch(request, env, ctx) {
		// Define function
		const getWeather = async (args: { numDays: number }) => {
			const { numDays } = args;
      // Location is extracted from request based on
      // https://developers.cloudflare.com/workers/runtime-apis/request/#incomingrequestcfproperties
      const lat = request.cf?.latitude
      const long = request.cf?.longitude

      // Interpolate values for external API call
			const response = await fetch(
				`https://api.open-meteo.com/v1/forecast?latitude=${lat}&longitude=${long}&daily=temperature_2m_max,precipitation_sum&timezone=GMT&forecast_days=${numDays}`
			);
			return response.text();
		};
		// Run AI inference with function calling
		const response = await runWithTools(
			env.AI,
			// Model with function calling support
			'@hf/nousresearch/hermes-2-pro-mistral-7b',
			{
				// Messages
				messages: [
					{
						role: 'user',
						content: 'What the weather like the next 5 days? Respond as text',
					},
				],
				// Definition of available tools the AI model can leverage
				tools: [
					{
						name: 'getWeather',
						description: 'Get the weather for the next [numDays] days',
						parameters: {
							type: 'object',
							properties: {
								numDays: { type: 'numDays', description: 'number of days for the weather forecast' },
							},
							required: ['numDays'],
						},
						// reference to previously defined function
						function: getWeather,
					},
				],
			}
		);
		return new Response(JSON.stringify(response));
	},
} satisfies ExportedHandler<Env>;
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/fetch/#page","headline":"Use fetch() handler","description":"Learn how to use the fetch() handler in Cloudflare Workers AI to enable LLMs to perform API calls, like retrieving a 5-day weather forecast using function calling.","url":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/fetch/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/fetch/og.png?v=840b375b65ba0cf7","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: Learn how to use Cloudflare Workers AI to interact with KV storage, enabling persistent data handling with embedded function calling in a few lines of code.
title: Use KV API
image: https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/kv/og.png?v=39ed64a561ba3ea0
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Use KV API

Last updated Oct 13, 2025|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/kv/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Interact with persistent storage to retrieve or store information enables for powerful use cases.

In this example we show how embedded function calling can interact with other resources on the Cloudflare Developer Platform with a few lines of code.

## Pre-Requisites

For this example to work, you need to provision a [KV](https://developers.cloudflare.com/kv/) namespace first. To do so, follow the [KV - Get started](https://developers.cloudflare.com/kv/get-started/) guide.

Importantly, your Wrangler file must be updated to include the `KV` binding definition to your respective namespace.

## Worker code

*Embedded function calling example with KV APIts*

```ts
import { runWithTools } from "@cloudflare/ai-utils";

type Env = {
	AI: Ai;
	KV: KVNamespace;
};

export default {
	async fetch(request, env, ctx) {
		// Define function
		const updateKvValue = async ({
			key,
			value,
		}: {
			key: string;
			value: string;
		}) => {
			const response = await env.KV.put(key, value);
			return `Successfully updated key-value pair in database: ${response}`;
		};

		// Run AI inference with function calling
		const response = await runWithTools(
			env.AI,
			"@hf/nousresearch/hermes-2-pro-mistral-7b",
			{
				messages: [
					{ role: "system", content: "Put user given values in KV" },
					{ role: "user", content: "Set the value of banana to yellow." },
				],
				tools: [
					{
						name: "KV update",
						description: "Update a key-value pair in the database",
						parameters: {
							type: "object",
							properties: {
								key: {
									type: "string",
									description: "The key to update",
								},
								value: {
									type: "string",
									description: "The value to update",
								},
							},
							required: ["key", "value"],
						},
						function: updateKvValue,
					},
				],
			},
		);
		return new Response(JSON.stringify(response));
	},
} satisfies ExportedHandler<Env>;
```

## Verify results

To verify the results, run the following command

```sh
npx wrangler kv key get banana --binding KV --local
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/kv/#page","headline":"Use KV API","description":"Learn how to use Cloudflare Workers AI to interact with KV storage, enabling persistent data handling with embedded function calling in a few lines of code.","url":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/kv/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/kv/og.png?v=39ed64a561ba3ea0","dateModified":"2025-10-13","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: Generate Workers AI function calling tools from an OpenAPI specification using the ai-utils package.
title: Tools based on OpenAPI Spec
image: https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/openapi/og.png?v=d57cb6344a7eb170
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Tools based on OpenAPI Spec

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/openapi/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Oftentimes APIs are defined and documented via [OpenAPI specification ↗︎](https://swagger.io/specification/). The Cloudflare `ai-utils` package's `createToolsFromOpenAPISpec` function creates tools from the OpenAPI spec, which the LLM can then leverage to fulfill the prompt.

In this example the LLM will describe the a Github user, based Github's API and its OpenAPI spec.

*Embedded function calling example from OpenAPI Spects*

```ts
import { createToolsFromOpenAPISpec, runWithTools } from '@cloudflare/ai-utils';

type Env = {
	AI: Ai;
};

const APP_NAME = 'cf-fn-calling-example-app';

export default {
	async fetch(request, env, ctx) {
		const toolsFromOpenAPISpec = [
			// You can pass the OpenAPI spec link or contents directly
			...(await createToolsFromOpenAPISpec(
				'https://gist.githubusercontent.com/mchenco/fd8f20c8f06d50af40b94b0671273dc1/raw/f9d4b5cd5944cc32d6b34cad0406d96fd3acaca6/partial_api.github.com.json',
				{
					overrides: [
						{
							matcher: ({ url }) => {
								return url.hostname === 'api.github.com';
							},
							// for all requests on *.github.com, we'll need to add a User-Agent.
							values: {
								headers: {
									'User-Agent': APP_NAME,
								},
							},
						},
					],
				}
			)),
		];

		const response = await runWithTools(
			env.AI,
			'@hf/nousresearch/hermes-2-pro-mistral-7b',
			{
				messages: [
					{
						role: 'user',
						content: 'Who is cloudflare on Github and how many repos does the organization have?',
					},
				],
				tools: toolsFromOpenAPISpec,
			}
		);

		return new Response(JSON.stringify(response));
	},
} satisfies ExportedHandler<Env>;
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/openapi/#page","headline":"Tools based on OpenAPI Spec","description":"Generate Workers AI function calling tools from an OpenAPI specification using the ai-utils package.","url":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/openapi/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/examples/openapi/og.png?v=d57cb6344a7eb170","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: Set up and deploy your first Workers AI project with embedded function calling.
title: Get Started
image: https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/get-started/og.png?v=8085b109897093fc
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Get Started

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/get-started/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

This guide will instruct you through setting up and deploying your first Workers AI project with embedded function calling. You will use Workers, a Workers AI binding, the [`ai-utils package` ↗︎](https://github.com/cloudflare/ai-utils), and a large language model (LLM) to deploy your first AI-powered application on the Cloudflare global network with embedded function calling.

## 1. Create a Worker project with Workers AI

Follow the [Workers AI Get Started Guide](https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/) until step 2.

## 2. Install additional npm package

Next, run the following command in your project repository to install the Worker AI utilities package.

npmyarnpnpmbun

```
npm i @cloudflare/ai-utils
```

```
yarn add @cloudflare/ai-utils
```

```
pnpm add @cloudflare/ai-utils
```

```
bun add @cloudflare/ai-utils
```

## 3. Add Workers AI Embedded function calling

Update the `index.ts` file in your application directory with the following code:

*index.jsjs*

```js
import { runWithTools } from "@cloudflare/ai-utils";

export default {
	async fetch(request, env, ctx) {
		// Define function
		const sum = (args) => {
			const { a, b } = args;
			return Promise.resolve((a + b).toString());
		};
		// Run AI inference with function calling
		const response = await runWithTools(
			env.AI,
			// Model with function calling support
			"@hf/nousresearch/hermes-2-pro-mistral-7b",
			{
				// Messages
				messages: [
					{
						role: "user",
						content: "What the result of 123123123 + 10343030?",
					},
				],
				// Definition of available tools the AI model can leverage
				tools: [
					{
						name: "sum",
						description: "Sum up two numbers and returns the result",
						parameters: {
							type: "object",
							properties: {
								a: { type: "number", description: "the first number" },
								b: { type: "number", description: "the second number" },
							},
							required: ["a", "b"],
						},
						// reference to previously defined function
						function: sum,
					},
				],
			},
		);
		return new Response(JSON.stringify(response));
	},
};
```

*index.tsts*

```ts
import { runWithTools } from "@cloudflare/ai-utils";

type Env = {
	AI: Ai;
};

export default {
	async fetch(request, env, ctx) {
		// Define function
		const sum = (args: { a: number; b: number }): Promise<string> => {
			const { a, b } = args;
			return Promise.resolve((a + b).toString());
		};
		// Run AI inference with function calling
		const response = await runWithTools(
			env.AI,
			// Model with function calling support
			"@hf/nousresearch/hermes-2-pro-mistral-7b",
			{
				// Messages
				messages: [
					{
						role: "user",
						content: "What the result of 123123123 + 10343030?",
					},
				],
				// Definition of available tools the AI model can leverage
				tools: [
					{
						name: "sum",
						description: "Sum up two numbers and returns the result",
						parameters: {
							type: "object",
							properties: {
								a: { type: "number", description: "the first number" },
								b: { type: "number", description: "the second number" },
							},
							required: ["a", "b"],
						},
						// reference to previously defined function
						function: sum,
					},
				],
			},
		);
		return new Response(JSON.stringify(response));
	},
} satisfies ExportedHandler<Env>;
```

This example imports the utils with `import { runWithTools} from "@cloudflare/ai-utils"` and follows the API reference below.

Moreover, in this example we define and describe a list of tools that the LLM can leverage to respond to the user query. Here, the list contains of only one tool, the `sum` function.

Abstracted by the `runWithTools` function, the following steps occur:

```
sequenceDiagram
    participant Worker as Worker
    participant WorkersAI as Workers AI

    Worker->>+WorkersAI: Send messages, function calling prompt, and available tools
    WorkersAI->>+Worker: Select tools and arguments for function calling
    Worker-->>-Worker: Execute function
    Worker-->>+WorkersAI: Send messages, function calling prompt and function result
    WorkersAI-->>-Worker: Send response incorporating function output

```

The `ai-utils package` is also open-sourced on [Github ↗︎](https://github.com/cloudflare/ai-utils).

## 4. Local development & deployment

Follow steps 4 and 5 of the [Workers AI Get Started Guide](https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/) for local development and deployment.

Workers AI Embedded Function Calling charges

Embedded function calling runs Workers AI inference requests. Standard charges for inference (e.g. tokens) usage will be charged. Resources consumed (e.g. CPU time) during embedded functions' code execution will be charged just as any other Worker's code execution.

## API reference

For more details, refer to [API reference](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/api-reference/).

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/get-started/#page","headline":"Get Started","description":"Set up and deploy your first Workers AI project with embedded function calling.","url":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/get-started/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/get-started/og.png?v=8085b109897093fc","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Debug and resolve common issues with Workers AI embedded function calling.
title: Troubleshooting
image: https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/troubleshooting/og.png?v=e7f024c00e0086e0
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Troubleshooting

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/troubleshooting/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

This section will describe tools for troubleshooting and address common errors.

## Logging

General [logging](https://developers.cloudflare.com/workers/observability/logs/) capabilities for Workers also apply to embedded function calling.

### Function invocations

The invocations of tools can be logged as in any Worker using `console.log()`:

*Logging tool invocationsts*

```ts
export default {
	async fetch(request, env, ctx) {
		const sum = (args: { a: number; b: number }): Promise<string> => {
			const { a, b } = args;
      // Logging from within embedded function invocations
      console.log(`The sum function has been invoked with the arguments a: ${a} and b: ${b}`)
			return Promise.resolve((a + b).toString());
		};
    ...
  }
}
```

### Logging within `runWithTools`

The `runWithTools` function has a `verbose` mode that emits helpful logs for debugging of function calls as well input and output statistics.

*Enabled verbose modets*

```ts
const response = await runWithTools(
  env.AI,
  '@hf/nousresearch/hermes-2-pro-mistral-7b',
  {
    messages: [
      ...
    ],
    tools: [
      ...
    ],
  },
  // Enable verbose mode
  { verbose: true }
);
```

## Performance

To respond to a LLM prompt with embedded function, potentially multiple AI inference requests and function invocations are needed, which can have an impact on user experience.

Consider the following to improve performance:

- Shorten prompts (to reduce time for input processing)
- Reduce number of tools provided
- Stream the final response to the end user (to minimize the time to interaction). See example below:

*Streamed response examplets*

```ts
async fetch(request, env, ctx) {
  const response = (await runWithTools(
    env.AI,
    '@hf/nousresearch/hermes-2-pro-mistral-7b',
    {
      messages: [
        ...
      ],
      tools: [
        ...
      ],
    },
    {
      // Enable response streaming
      streamFinalResponse: true,
    }
  )) as ReadableStream;

  // Set response headers for streaming
  return new Response(response, {
    headers: {
      'content-type': 'text/event-stream',
    },
  });
}
```

## Common Errors

If you are getting a `BadInput` error, your inputs may exceed our current context window for our models. Try reducing input tokens to resolve this error.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/troubleshooting/#page","headline":"Troubleshooting","description":"Debug and resolve common issues with Workers AI embedded function calling.","url":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/troubleshooting/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/troubleshooting/og.png?v=e7f024c00e0086e0","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Define tools and schemas for industry-standard function calling with Workers AI models.
title: Traditional
image: https://developers.cloudflare.com/workers-ai/features/function-calling/traditional/og.png?v=a7f9d52f0e6e4365
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Traditional

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/function-calling/traditional/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

This page shows how you can do traditional function calling, as defined by industry standards. Workers AI also offers [embedded function calling](https://developers.cloudflare.com/workers-ai/features/function-calling/embedded/), which is drastically easier than traditional function calling.

With traditional function calling, you define an array of tools with the name, description, and tool arguments. The example below shows how you would pass a tool called `getWeather` in an inference request to a model.

*Traditional function calling examplejs*

```js
const response = await env.AI.run("@hf/nousresearch/hermes-2-pro-mistral-7b", {
	messages: [
		{
			role: "user",
			content: "what is the weather in london?",
		},
	],
	tools: [
		{
			name: "getWeather",
			description: "Return the weather for a latitude and longitude",
			parameters: {
				type: "object",
				properties: {
					latitude: {
						type: "string",
						description: "The latitude for the given location",
					},
					longitude: {
						type: "string",
						description: "The longitude for the given location",
					},
				},
				required: ["latitude", "longitude"],
			},
		},
	],
});

return new Response(JSON.stringify(response.tool_calls));
```

The LLM will then return a JSON object with the required arguments and the name of the tool that was called. You can then pass this JSON object to make an API call.

```json
[
	{
		"arguments": { "latitude": "51.5074", "longitude": "-0.1278" },
		"name": "getWeather"
	}
]
```

For a working example on how to do function calling, take a look at our [demo app ↗︎](https://github.com/craigsdennis/lightbulb-moment-tool-calling/blob/main/src/index.ts).

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/function-calling/traditional/#page","headline":"Traditional","description":"Define tools and schemas for industry-standard function calling with Workers AI models.","url":"https://developers.cloudflare.com/workers-ai/features/function-calling/traditional/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/function-calling/traditional/og.png?v=a7f9d52f0e6e4365","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Force Workers AI text generation models to return valid JSON output using response_format or JSON schemas.
title: JSON Mode
image: https://developers.cloudflare.com/workers-ai/features/json-mode/og.png?v=7526f0fdc7cd915d
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# JSON Mode

Last updated Sep 14, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/json-mode/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

When we want text-generation AI models to interact with databases, services, and external systems programmatically, typically when using tool calling or building AI agents, we must have structured response formats rather than natural language.

Workers AI supports JSON Mode, enabling applications to request a structured output response when interacting with AI models.

## Schema

JSON Mode is compatible with OpenAI’s implementation; to enable add the `response_format` property to the request object using the following convention:

```json
{
  response_format: {
    title: "JSON Mode",
    type: "object",
    properties: {
      type: {
        type: "string",
        enum: ["json_object", "json_schema"],
      },
      json_schema: {},
    }
  }
}
```

Where `json_schema` must be a valid [JSON Schema ↗︎](https://json-schema.org/) declaration.

## JSON Mode example

When using JSON Format, pass the schema as in the example below as part of the request you send to the LLM.

```json
{
  "messages": [
    {
      "role": "system",
      "content": "Extract data about a country."
    },
    {
      "role": "user",
      "content": "Tell me about India."
    }
  ],
  "response_format": {
    "type": "json_schema",
    "json_schema": {
      "type": "object",
      "properties": {
        "name": {
          "type": "string"
        },
        "capital": {
          "type": "string"
        },
        "languages": {
          "type": "array",
          "items": {
            "type": "string"
          }
        }
      },
      "required": [
        "name",
        "capital",
        "languages"
      ]
    }
  }
}
```

The LLM will follow the schema, and return a response such as below:

```json
{
  "response": {
    "name": "India",
    "capital": "New Delhi",
    "languages": [
      "Hindi",
      "English",
      "Bengali",
      "Telugu",
      "Marathi",
      "Tamil",
      "Gujarati",
      "Urdu",
      "Kannada",
      "Odia",
      "Malayalam",
      "Punjabi",
      "Sanskrit"
    ]
  }
}
```

As you can see, the model is complying with the JSON schema definition in the request and responding with a validated JSON object.

## Supported Models

This is the list of models that now support JSON Mode:

- [@cf/meta/llama-3.3-70b-instruct-fp8-fast](https://developers.cloudflare.com/workers-ai/models/llama-3.3-70b-instruct-fp8-fast/)
- [@cf/meta/llama-3-8b-instruct](https://developers.cloudflare.com/workers-ai/models/llama-3-8b-instruct/)
- [@cf/meta/llama-3.1-8b-instruct](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct/)
- [@hf/nousresearch/hermes-2-pro-mistral-7b](https://developers.cloudflare.com/workers-ai/models/hermes-2-pro-mistral-7b/)
- [@hf/thebloke/deepseek-coder-6.7b-instruct-awq](https://developers.cloudflare.com/workers-ai/models/deepseek-coder-6.7b-instruct-awq/)
- [@cf/deepseek-ai/deepseek-r1-distill-qwen-32b](https://developers.cloudflare.com/workers-ai/models/deepseek-r1-distill-qwen-32b/)

We will continue extending this list to keep up with new, and requested models.

Note that Workers AI can't guarantee that the model responds according to the requested JSON Schema. Depending on the complexity of the task and adequacy of the JSON Schema, the model may not be able to satisfy the request in extreme situations. If that's the case, then an error `JSON Mode couldn't be met` is returned and must be handled.

JSON Mode currently doesn't support streaming.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/features/json-mode/#page","headline":"JSON Mode","description":"Force Workers AI text generation models to return valid JSON output using response_format or JSON schemas.","url":"https://developers.cloudflare.com/workers-ai/features/json-mode/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/json-mode/og.png?v=7526f0fdc7cd915d","dateModified":"2026-09-14","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["JSON"]}
```

---

---
description: Convert documents in multiple formats to Markdown using the Workers AI toMarkdown method.
title: Markdown Conversion
image: https://developers.cloudflare.com/workers-ai/features/markdown-conversion/og.png?v=c777cc4964f21363
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Markdown Conversion

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

[Markdown ↗︎](https://en.wikipedia.org/wiki/Markdown) is essential for text generation and large language models (LLMs) in training and inference because it can provide structured, semantic, human, and machine-readable input. Likewise, Markdown facilitates chunking and structuring input data for better retrieval and synthesis in the context of RAGs, and its simplicity and ease of parsing and rendering make it ideal for AI Agents.

For these reasons, document conversion plays an important role when designing and developing AI applications. Workers AI provides the `toMarkdown` utility method that developers can use from the [`env.AI`](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/binding/) binding or the [REST APIs](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/rest-api/) for quick, easy, and convenient conversion and summary of documents in multiple formats to Markdown language.

## Pricing

`toMarkdown` is free for most format conversions. In some cases, like image conversion, it can use Workers AI models for object detection and summarization, which may incur additional costs if it exceeds the Workers AI free allocation limits. Refer to [what models we use](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/how-it-works/) and the [Workers AI pricing page](https://developers.cloudflare.com/workers-ai/platform/pricing/) for more details.

## Other Markdown conversion features

- The Browser Run [/markdown](https://developers.cloudflare.com/browser-run/quick-actions/markdown-endpoint/) endpoint supports markdown conversion if you need to render a dynamic page or application in a real browser before converting it.
- [Markdown for Agents](https://developers.cloudflare.com/fundamentals/reference/markdown-for-agents/) allows real-time document conversion for Cloudflare zones using content negotiation headers.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/#page","headline":"Markdown Conversion","description":"Convert documents in multiple formats to Markdown using the Workers AI toMarkdown method.","url":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/og.png?v=c777cc4964f21363","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Configure per-format options for Workers AI Markdown Conversion, including HTML and image settings.
title: Conversion Options
image: https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/og.png?v=3a136bcaa6901b43
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Conversion Options

Last updated Oct 15, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

By default, the `toMarkdown` service extracts text content from your files. To further extend the capabilities of the conversion process, you can pass options to the service to control how specific file types are converted.

Options are organized by file type and are all optional.

## Available options

### Output

```typescript
{
  output?: {
    format?: 'markdown' | 'text';
  }
}
```

- `format`: controls the format of the converted content. Defaults to `markdown`. Set to `text` to receive plain text with Markdown syntax removed.

When `format` is `text`, the `format` field of the [`ConversionResult`](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/binding/#conversionresult-definition) is also set to `text`.

### Images

```typescript
{
  image?: {
    descriptionLanguage?: 'en' | 'it' | 'de' | 'es' | 'fr' | 'pt';
  }
}
```

- `descriptionLanguage`: controls the language of the AI-generated image descriptions.

Caution

This option works on a *best-effort* basis: it is not guaranteed that the resulting text will be in the desired language.

### HTML

```typescript
{
  html?: {
    hostname?: string;
    cssSelector?: string;
  }
}
```

- `hostname`: absolute base URL used to resolve relative links in the HTML. Include the scheme and, when applicable, the page path — for example, `https://example.com/docs/page`. A bare hostname such as `example.com` is not sufficient.
- `cssSelector`: string containing a CSS selector pattern to pick specific elements from your HTML. Refer to [how HTML is processed](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/how-it-works/#html) for more details.

### PDF

```typescript
{
  pdf?: {
    metadata?: boolean;
  }
}
```

- `metadata`: Previously, all converted PDF files always included metadata information when converted. This option allows you to opt-out of this behavior.

## Examples

### Binding

To configure custom options, pass a `conversionOptions` object inside the second argument of the binding call, like this:

```typescript
await env.AI.toMarkdown(..., {
  conversionOptions: {
    html: { ... },
    pdf: { ... },
    ...
   }
})
```

### REST API

Since the REST API uses file uploads, the request's `Content-Type` will be `multipart/form-data`. As such, include a new form field with your stringified object as a value:

```bash
curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/tomarkdown \
  -X POST \
  -H 'Authorization: Bearer {API_TOKEN}' \
  ...
  -F 'conversionOptions={ "html": { ... }, ... }'
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/#page","headline":"Conversion Options","description":"Configure per-format options for Workers AI Markdown Conversion, including HTML and image settings.","url":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/og.png?v=3a136bcaa6901b43","dateModified":"2026-10-15","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Learn how Workers AI pre-processes and converts HTML, images, and other files to Markdown.
title: How it works
image: https://developers.cloudflare.com/workers-ai/features/markdown-conversion/how-it-works/og.png?v=54dd4472fb6acd18
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# How it works

Last updated Oct 15, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/how-it-works/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

## Pre-processing

When parsing files before converting them to Markdown, there are some cleanup tasks we do depending on the type of file you are trying to convert.

### HTML

When we detect an HTML file, a series of things happen to the HTML content before it is converted:

- Some elements are ignored, including `script` and `style` tags.
- Meta tags are extracted. These include `title`, `description`, `og:title`, `og:description` and `og:image`.
- [JSON-LD ↗︎](https://json-ld.org/) content is extracted, if it exists. This will be appended at the end of the converted markdown.
- The base URL to use for resolving relative links is extracted from the `<base>` element<sup>1</sup>, if it exists, according to the spec (that is, only the first instance of the base URL is counted).
- If the `cssSelector` option is:
  - present, then only those elements that match the selector are kept for further processing;
  - missing, then elements such as `<header>`, `<footer>` and `<head>` are removed from the text.
- If a base URL was obtained previously, relative links in the remaining HTML are resolved to fully qualified URLs.

<sup>1</sup> You can also set the base URL for each request with the HTML conversion options. Refer to [Conversion Options](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/#html) for more details.

### Images

Images take a bit more work to prepare for conversion.

For animated GIF files, only the first frame is extracted and analyzed. The remaining frames are discarded.

As a first step, we detect what type the image is. If it is an SVG (Scalable Vector Graphics) file, we need to convert it into a raster format so that using the necessary Workers AI models does not fail. In this case, SVGs are converted into PNGs internally.

Afterwards:

- We try to determine the image's dimensions. If successful, we determine if the image is considered "too big" or not. An image is "too big" if its width is bigger than 1280px or its height is bigger than 720px.
- If the image is too big, we try to resize it to conform with those dimensions. If resizing fails, we simply try to use the original image data
- The image is sent to an **object-detection model**. Specifically, we use the [`@cf/facebook/detr-resnet-50`](https://developers.cloudflare.com/workers-ai/models/detr-resnet-50/) from Workers AI.
- If any objects were detected in the previous step, they are appended to a prompt that is used to instruct an **image-to-text model** on how to describe the image.
- If a preferred conversion language is specified in the request's conversion options, the previous prompt is enriched with a directive for the model to output the content in the desired language. Refer to [Conversion Options](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/#images) for more details.
- The final prompt is sent, along with the image data, to the [`@cf/google/gemma-4-26b-a4b-it`](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/) model, also from Workers AI.

### PDFs

- Metadata is extracted. This can be removed from the final result. Refer to [Conversion Options](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/#pdf) for more details.
- Each page is parsed in sequence.
- We try to obtain a `StructTree` object from the PDF file. This data structure is a tree of tagged elements that make up the PDF contents, as specified by [ISO 14289 (PDF/UA) ↗︎](https://www.iso.org/standard/64599.html).
- If none is obtained, we extract the text of the page *as-is* and return it.
- If we manage to obtain a `StructTree`, we traverse its nodes to build a semantic Markdown representation of its contents.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/how-it-works/#page","headline":"How it works","description":"Learn how Workers AI pre-processes and converts HTML, images, and other files to Markdown.","url":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/how-it-works/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/how-it-works/og.png?v=54dd4472fb6acd18","dateModified":"2026-10-15","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: View the list of file formats supported by Workers AI Markdown Conversion.
title: Supported Formats
image: https://developers.cloudflare.com/workers-ai/features/markdown-conversion/supported-formats/og.png?v=d32b965c8f4bc10e
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Supported Formats

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/supported-formats/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

This list shows all rich-content formats that are currently supported for Markdown conversion and is updated frequently:

Format | | | | | File extensions | | | | | Mime Types | | | |

| PDF Documents | | | | | `.pdf` | | | | | `application/pdf` | | | | |
| --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- | --- |
| Images <sup>1</sup> | | | | | `.jpeg`, `.jpg`, `.png`, `.webp`, `.svg`, `.gif`, `.bmp` | | | | | `image/jpeg`, `image/png`, `image/webp`, `image/svg+xml`, `image/gif`, `image/bmp` | | | | |
| HTML Documents | | | | | `.html`, `.htm` | | | | | `text/html` | | | | |
| XML Documents | | | | | `.xml` | | | | | `application/xml` | | | | |
| Microsoft Office Documents | | | | | `.xlsx`, `.xlsm`, `.xlsb`, `.xls`, `.et`, `.docx` | | | | | `application/vnd.openxmlformats-officedocument.spreadsheetml.sheet`, `application/vnd.ms-excel.sheet.macroenabled.12`, `application/vnd.ms-excel.sheet.binary.macroenabled.12`, `application/vnd.ms-excel`, `application/vnd.openxmlformats-officedocument.wordprocessingml.document` | | | | |
| Open Document Format | | | | | `.ods`, `.odt` | | | | | `application/vnd.oasis.opendocument.spreadsheet`, `application/vnd.oasis.opendocument.text` | | | | |
| CSV | | | | | `.csv` | | | | | `text/csv` | | | | |
| Apple Documents | | | | | `.numbers` | | | | | `application/vnd.apple.numbers` | | | | |

<sup>1</sup> Image conversion uses two Workers AI models for object detection and summarization. See [Workers AI pricing](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/#pricing) for more details.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/supported-formats/#page","headline":"Supported Formats","description":"View the list of file formats supported by Workers AI Markdown Conversion.","url":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/supported-formats/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/supported-formats/og.png?v=d32b965c8f4bc10e","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Convert documents to Markdown using the Workers AI binding and toMarkdown method.
title: Workers Binding
image: https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/binding/og.png?v=4c5daf24a38904a5
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Workers Binding

Last updated Jul 13, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/binding/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Cloudflare’s serverless platform allows you to run code at the edge to build full-stack applications with [Workers](https://developers.cloudflare.com/workers/). A [binding](https://developers.cloudflare.com/workers/runtime-apis/bindings/) enables your Worker or Pages Function to interact with resources on the Cloudflare Developer Platform.

To use our Markdown Conversion service directly from your Workers, create an AI binding either in the Cloudflare dashboard (refer to [AI bindings](https://developers.cloudflare.com/pages/functions/bindings/#workers-ai) for instructions), or you can update your [Wrangler file](https://developers.cloudflare.com/workers/wrangler/configuration/). Add the following to your Wrangler file:

```jsonc
{
  "$schema": "./node_modules/wrangler/config-schema.json",
  "ai": {
    "binding": "AI"
  }
}
```

```toml
[ai]
binding = "AI" # i.e. available in your Worker on env.AI
```

## Examples

### Converting files

In this example, we fetch a PDF document and an image from R2 and feed them both to `env.AI.toMarkdown`. The result is a list of converted documents. Workers AI models are used automatically to detect and summarize the image.

```js
import { Env } from "./env";

export default {
	async fetch(request, env, ctx) {
		// https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/somatosensory.pdf
		const pdf = await env.R2.get("somatosensory.pdf");

		// https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/cat.jpeg
		const cat = await env.R2.get("cat.jpeg");

		return Response.json(
			await env.AI.toMarkdown([
				{
					name: "somatosensory.pdf",
					blob: new Blob([await pdf.arrayBuffer()], {
						type: "application/pdf",
					}),
				},
				{
					name: "cat.jpeg",
					blob: new Blob([await cat.arrayBuffer()], {
						type: "image/jpeg",
					}),
				},
			]),
		);
	},
};
```

```typescript
import { Env } from "./env";

export default {
	async fetch(request: Request, env: Env, ctx: ExecutionContext) {
		// https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/somatosensory.pdf
		const pdf = await env.R2.get("somatosensory.pdf");

		// https://pub-979cb28270cc461d94bc8a169d8f389d.r2.dev/cat.jpeg
		const cat = await env.R2.get("cat.jpeg");

		return Response.json(
			await env.AI.toMarkdown([
				{
					name: "somatosensory.pdf",
					blob: new Blob([await pdf.arrayBuffer()], {
						type: "application/pdf",
					}),
				},
				{
					name: "cat.jpeg",
					blob: new Blob([await cat.arrayBuffer()], {
						type: "image/jpeg",
					}),
				},
			]),
		);
	},
};
```

### Getting supported file formats

```js
import { Env } from "./env";

export default {
	async fetch(request, env, ctx) {
		return Response.json(await env.AI.toMarkdown().supported());
	},
};
```

```typescript
import { Env } from "./env";

export default {
	async fetch(request: Request, env: Env, ctx: ExecutionContext) {
		return Response.json(await env.AI.toMarkdown().supported());
	},
};
```

## Methods

### async env.AI.toMarkdown()

Takes a document or list of documents in different formats and converts them to Markdown.

```js
const result = await env.AI.toMarkdown({
	name: "document.pdf",
	blob: new Blob([documentBuffer]),
});
```

```typescript
const result = await env.AI.toMarkdown({
	name: "document.pdf",
	blob: new Blob([documentBuffer]),
});
```

#### Parameter

- `files`: `MarkdownDocument | MarkdownDocument[]`- an instance of or an array of `MarkdownDocument`s.
- `conversionOptions`: `ConversionOptions`- options that control how conversion happens. See [Conversion Options](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/) for further details.

#### Return values

- `results`: `Promise<ConversionResult | ConversionResult[]>`- An instance of or an array of `ConversionResult`s.

#### `MarkdownDocument` definition

- `name` `string`
  - Name of the document to convert.
- `blob` `Blob`
  - A new [Blob ↗︎](https://developer.mozilla.org/en-US/docs/Web/API/Blob/Blob) object with the document content.

#### `ConversionResult` definition

- `id` `string`
  - ID associated to this object.
- `name` `string`
  - Name of the converted document. Matches the input name.
- `format` `'markdown' | 'text' | 'error'`
  - The format of this `ConversionResult` object. Equals `text` when you set the [`output.format`](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/#output) option to `text`.
- `mimetype` `string`
  - The detected [mime type ↗︎](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types) of the document.
- `tokens` `number`
  - The estimated number of tokens of the converted document. Not present if `format` is equal to `error`.
- `data` `string`
  - The content of the converted document. Not present if `format` is equal to `error`.
- `error` `string`
  - The error message explaining why this conversion failed. Only present if `format` is equal to `error`.

### async env.AI.toMarkdown().transform()

This method is similar to `env.AI.toMarkdown` except that it is exposed through a new handle. It takes the same arguments and returns the same values.

```js
const result = await env.AI.toMarkdown().transform({
	name: "document.pdf",
	blob: new Blob([documentBuffer]),
});
```

```typescript
const result = await env.AI.toMarkdown().transform({
	name: "document.pdf",
	blob: new Blob([documentBuffer]),
});
```

### async env.AI.toMarkdown().supported()

Returns a list of file formats that are currently supported for markdown conversion. See [Supported formats](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/supported-formats/) for the full list of file formats that can be converted into Markdown.

```js
const formats = await env.AI.toMarkdown().supported();
```

```typescript
const formats = await env.AI.toMarkdown().supported();
```

#### Return values

- `results`: `SupportedFormat[]`- An array of all formats supported for markdown conversion.

#### `SupportedFormat` definition

- `extension` `string`
  - Extension of files in this format.
- `mimeType` `string`
  - The [mime type ↗︎](https://developer.mozilla.org/en-US/docs/Web/HTTP/Guides/MIME_types/Common_types) of files of this format

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/binding/#page","headline":"Workers Binding","description":"Convert documents to Markdown using the Workers AI binding and toMarkdown method.","url":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/binding/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/binding/og.png?v=4c5daf24a38904a5","dateModified":"2026-07-13","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Convert documents to Markdown using the Workers AI REST API endpoint.
title: REST API
image: https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/rest-api/og.png?v=5b1fb19ca805e26f
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# REST API

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/rest-api/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

You can also use the Markdown Conversion REST API to convert your documents into Markdown.

## Prerequisite: Get Workers AI API token

To use the Markdown Conversion service via the REST API, you need an API token with permissions for the [Workers AI](https://developers.cloudflare.com/workers-ai/) REST API. Refer to [Get started with the Workers AI REST API](https://developers.cloudflare.com/workers-ai/get-started/rest-api/) for instructions on obtaining an API token with the correct permissions.

## Transform

This endpoint lets you convert any file given to us into markdown.

```bash
curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/tomarkdown \
  -X POST \
  -H 'Authorization: Bearer {API_TOKEN}' \
  -F "files=@cat.jpeg" \
  -F "files=@somatosensory.pdf" \
  -F 'conversionOptions={ ... }'
```

Note

You can get your `ACCOUNT_ID` by going to [Workers & Pages on the dashboard](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/#find-account-id-workers-and-pages).

### Parameters

`files` `File[]` required

The files you want to convert.

`conversionOptions` `ConversionOptions` optional

Options that allow you to control how your files are converted. Refer to [Conversion Options](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/conversion-options/) for further details.

### Response

```json
{
	"success": true,
	"result": [
		{
			"id": "...",
			"name": "good.html",
			"mimeType": "text/html",
			"format": "markdown",
			"tokens": 49,
			"data": "# Image Embedded with a Data URI\n\nThis _image_ is directly encoded in the HTML:\n\n\n\nAn image description\n\n \n\nIt's a tiny 5x5 pixel PNG, scaled up to 50x50px.\n\n"
		},
		{
			"id": "...",
			"name": "bad.pdf",
			"mimeType": "application/pdf",
			"format": "error",
			"error": "Some error that prevented this image from being converted"
		}
	]
}
```

## Supported

This endpoint lets you programmatically retrieve the full set of rich formats that are supported for conversion.

```bash
curl https://api.cloudflare.com/client/v4/accounts/{ACCOUNT_ID}/ai/tomarkdown/supported \
  -H 'Authorization: Bearer {API_TOKEN}'
```

Note

You can get your `ACCOUNT_ID` by going to [Workers & Pages on the dashboard](https://developers.cloudflare.com/fundamentals/account/find-account-and-zone-ids/#find-account-id-workers-and-pages).

### Response

```json
{
  "success": true,
  "result": [
    {
      "extension": ".html",
      "mimeType": "text/html"
    },
    {
      "extension": ".pdf",
      "mimeType": "application/pdf"
    },
    ...
  ]
}
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/rest-api/#page","headline":"REST API","description":"Convert documents to Markdown using the Workers AI REST API endpoint.","url":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/rest-api/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/markdown-conversion/usage/rest-api/og.png?v=5b1fb19ca805e26f","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Use prefix caching and the x-session-affinity header to reduce latency and inference costs on Workers AI.
title: Prompt caching
image: https://developers.cloudflare.com/workers-ai/features/prompt-caching/og.png?v=98d693906575de63
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Prompt caching

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/prompt-caching/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Prompt caching (also called prefix caching) is a performance optimization that allows Workers AI to respond faster to requests with prompts that share common inputs. It reduces Time to First Token (TTFT) and increases Tokens Per Second (TPS) throughput by reusing previously computed input tensors instead of reprocessing them from scratch.

Cached input tokens are billed at a discounted rate compared to regular input tokens. Workers AI enables prefix caching by default for select models. Compatibility and pricing details are listed on each [model page](https://developers.cloudflare.com/workers-ai/models/).

## How it works

When an LLM processes a request, it goes through two stages:

1. **Prefill stage** — processes input tokens (system prompts, tool definitions, conversation history).
2. **Output stage** — generates output tokens.

With prefix caching, Workers AI stores the computed input tensors from the prefill stage. On subsequent requests that share the same prefix, the model skips prefill for the cached portion and only processes the new input tokens. This saves significant compute time, especially for agentic workloads where consecutive requests share large amounts of context.

For example, when a coding agent sends a new prompt, it typically resends all previous prompts, tool definitions, and conversation history. The delta between consecutive requests is often just a few new lines. Prefix caching avoids redundant prefill on all the shared context.

## Session affinity header

Prefix caching only works when a request routes to the same model instance that holds the cached tensors. To maximize cache hit rates, send the `x-session-affinity` header with a unique identifier for your session or agent. This routes requests with the same identifier to the same model instance, increasing the likelihood of a prefix cache hit.

### REST API

```bash
curl -X POST \
  "https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/@cf/moonshotai/kimi-k2.5" \
  -H "Authorization: Bearer {api_token}" \
  -H "Content-Type: application/json" \
  -H "x-session-affinity: ses_12345678" \
  -d '{
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant."
      },
      {
        "role": "user",
        "content": "What is prefix caching and why does it matter?"
      }
    ],
    "max_tokens": 2400,
    "stream": true
  }'
```

### Workers AI binding

```js
const response = await env.AI.run(
	"@cf/moonshotai/kimi-k2.5",
	{
		messages: [
			{ role: "system", content: "You are a helpful assistant." },
			{ role: "user", content: "Explain prefix caching." },
		],
	},
	{
		extraHeaders: {
			"x-session-affinity": "ses_12345678",
		},
	},
);
```

## Structuring prompts for caching

Prefix caching matches the exact token sequence from the start of the prompt. A single token difference invalidates the cache from that point onward.

To maximize cache hits:

- **Place static content first.** System prompts, tool definitions, and shared instructions should appear at the beginning of the prompt. Put user-specific or dynamic content (timestamps, user queries) at the end.
- **Avoid timestamps in system prompts.** Including a timestamp at the start of a system prompt changes the prefix on every request, defeating the cache entirely. If time context is required, add it to the user message instead.
- **Reuse tool definitions across requests.** For function-calling agents, tools are part of the prompt prefix. Keeping tool definitions consistent across requests in the same session increases cache reuse.

## Monitoring cached tokens

Workers AI surfaces cached token counts in the response `usage` object. Use this to verify that prefix caching is working and to track cost savings. The first request will usually be cold, so it is expected that cached tokens are not returned on the first hit. Inputs need to be sufficiently large enough in order to be cached due to block size. Cached tokens are billed at a lower rate than regular input tokens, which get totalled into your neuron count.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/prompt-caching/#page","headline":"Prompt caching","description":"Use prefix caching and the x-session-affinity header to reduce latency and inference costs on Workers AI.","url":"https://developers.cloudflare.com/workers-ai/features/prompt-caching/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/prompt-caching/og.png?v=98d693906575de63","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Structure prompts for Workers AI text generation models using system, user, and assistant message roles.
title: Prompting
image: https://developers.cloudflare.com/workers-ai/features/prompting/og.png?v=d4bc6c1370a5888c
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Prompting

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/prompting/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Part of getting good results from text generation models is asking questions correctly. LLMs are usually trained with specific predefined templates, which should then be used with the model's tokenizer for better results when doing inference tasks.

There are two ways to prompt text generation models with Workers AI:

Important

We recommend using unscoped prompts for inference with LoRA.

### Scoped Prompts

This is the **recommended** method. With scoped prompts, Workers AI takes the burden of knowing and using different chat templates for different models and provides a unified interface to developers when building prompts and creating text generation tasks.

Scoped prompts are a list of messages. Each message defines two keys: the role and the content.

Typically, the role can be one of three options:

- **system** - System messages define the AI's personality. You can use them to set rules and how you expect the AI to behave.
- **user** - User messages are where you actually query the AI by providing a question or a conversation.
- **assistant** - Assistant messages hint to the AI about the desired output format. Not all models support this role.

OpenAI has a [good explanation ↗︎](https://platform.openai.com/docs/guides/text-generation#messages-and-roles) of how they use these roles with their GPT models. Even though chat templates are flexible, other text generation models tend to follow the same conventions.

Here's an input example of a scoped prompt using system and user roles:

```js
{
  messages: [
    { role: "system", content: "you are a very funny comedian and you like emojis" },
    { role: "user", content: "tell me a joke about cloudflare" },
  ],
};
```

Here's a better example of a chat session using multiple iterations between the user and the assistant.

```js
{
  messages: [
    { role: "system", content: "you are a professional computer science assistant" },
    { role: "user", content: "what is WASM?" },
    { role: "assistant", content: "WASM (WebAssembly) is a binary instruction format that is designed to be a platform-agnostic" },
    { role: "user", content: "does Python compile to WASM?" },
    { role: "assistant", content: "No, Python does not directly compile to WebAssembly" },
    { role: "user", content: "what about Rust?" },
  ],
};
```

Note that different LLMs are trained with different templates for different use cases. While Workers AI tries its best to abstract the specifics of each LLM template from the developer through a unified API, you should always refer to the model documentation for details. For example, instruct models like Codellama are fine-tuned to respond to a user-provided instruction, while chat models expect fragments of dialogs as input.

### Unscoped Prompts

You can use unscoped prompts to send a single question to the model without worrying about providing any context. Workers AI will automatically convert your `prompt` input to a reasonable default scoped prompt internally so that you get the best possible prediction.

```js
{
  prompt: "tell me a joke about cloudflare";
}
```

You can also use unscoped prompts to construct the model chat template manually. In this case, you can use the raw parameter. Here's an input example of a [Mistral ↗︎](https://docs.mistral.ai/models/#chat-template) chat template prompt:

```js
{
  prompt: "<s>[INST]comedian[/INST]</s>
[INST]tell me a joke about cloudflare[/INST]",
  raw: true
};
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/prompting/#page","headline":"Prompting","description":"Structure prompts for Workers AI text generation models using system, user, and assistant message roles.","url":"https://developers.cloudflare.com/workers-ai/features/prompting/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/prompting/og.png?v=d4bc6c1370a5888c","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: Fail synchronous inference requests when capacity is unavailable.
title: Reject busy requests
image: https://developers.cloudflare.com/workers-ai/features/reject-if-busy/og.png?v=bb6cf5fefc74a740
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Reject busy requests

Last updated Sep 17, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/features/reject-if-busy/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Set `rejectIfBusy` when your application should not wait in a capacity queue. Workers AI rejects the synchronous inference request if capacity is unavailable.

## Send a REST request

For the native REST API, add `rejectIfBusy` to the request `options` object:

```bash
curl --request POST \
  --url "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/run/@cf/google/gemma-4-26b-a4b-it" \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "messages": [
      {
        "role": "user",
        "content": "Explain what a capacity queue is."
      }
    ],
    "options": {
      "rejectIfBusy": true
    }
  }'
```

## Use the Workers binding

For the Workers AI binding, pass `rejectIfBusy` in the third argument to `env.AI.run()`:

```js
const response = await env.AI.run(
	"@cf/google/gemma-4-26b-a4b-it",
	{
		messages: [
			{
				role: "user",
				content: "Explain what a capacity queue is.",
			},
		],
	},
	{ rejectIfBusy: true },
);
```

```ts
const response = await env.AI.run(
	"@cf/google/gemma-4-26b-a4b-it",
	{
		messages: [
			{
				role: "user",
				content: "Explain what a capacity queue is.",
			},
		],
	},
	{ rejectIfBusy: true },
);
```

Do not add `rejectIfBusy` to the model input object. The binding only applies this option from the third argument.

## Call Chat Completions

For OpenAI-compatible Chat Completions, add `options` at the top level of the request body:

```bash
curl --request POST \
  --url "https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/v1/chat/completions" \
  --header "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \
  --header "Content-Type: application/json" \
  --data '{
    "model": "@cf/google/gemma-4-26b-a4b-it",
    "messages": [
      {
        "role": "user",
        "content": "Explain what a capacity queue is."
      }
    ],
    "options": {
      "rejectIfBusy": true
    }
  }'
```

OpenAI clients that preserve custom fields can send this option. Clients that remove unknown fields do not apply it, so requests proceed normally.

## Handle capacity errors

Rejected requests return HTTP status `429` and internal error code `3040`. The error message is `Capacity temporarily exceeded, please try again.`

Refer to [Workers AI errors](https://developers.cloudflare.com/workers-ai/platform/errors/) for error details.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/features/reject-if-busy/#page","headline":"Reject busy requests","description":"Fail synchronous inference requests when capacity is unavailable.","url":"https://developers.cloudflare.com/workers-ai/features/reject-if-busy/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/features/reject-if-busy/og.png?v=bb6cf5fefc74a740","dateModified":"2026-09-17","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Build and host AI agents on Cloudflare. Run an agent harness in a Durable Object, add capabilities such as state, WebSockets, and scheduling with the Agents SDK Lifecycle, and give the agent tools.
title: Build Agents on Cloudflare
image: https://developers.cloudflare.com/agents/og.png?v=5f3790c1b824e669
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/agents/llms.txt  
> Use this file to discover all available pages before exploring further.

# Build Agents on Cloudflare

Last updated Oct 29, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/agents/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Build and host AI agents on Cloudflare. Connect chat, voice, email, Slack, and webhooks to a durable agent, and give it tools such as a workspace, a browser, web search, MCP servers, and payments.

When you host agents on Cloudflare, each agent has a durable identity, local SQL storage, real-time connections, scheduled work, and recoverable execution.

Deploy once and Cloudflare runs your agents across its global network, scaling to tens of millions of instances. No infrastructure to manage, no sessions to reconstruct, no state to externalize.

[Chat](https://developers.cloudflare.com/agents/agent-class/communication-channels/chat/) [Email](https://developers.cloudflare.com/agents/agent-class/communication-channels/email/) [Voice](https://developers.cloudflare.com/agents/agent-class/communication-channels/voice/) [Slack](https://developers.cloudflare.com/agents/agent-class/communication-channels/slack/) [Webhook](https://developers.cloudflare.com/agents/agent-class/communication-channels/webhooks/)

Runtime

The Lifecycle provides hooks for Capabilities to schedule durable work.

[Lifecycle](https://developers.cloudflare.com/agents/runtime/lifecycle/)

[State](https://developers.cloudflare.com/agents/runtime/capabilities/state/) [WebSockets](https://developers.cloudflare.com/agents/runtime/capabilities/websockets/) [Scheduler](https://developers.cloudflare.com/agents/runtime/capabilities/scheduler/) [MCP client](https://developers.cloudflare.com/agents/runtime/capabilities/mcp-client-manager/)

Harnesses

[Pi](https://developers.cloudflare.com/agents/harnesses/pi/) [OpenCode](https://developers.cloudflare.com/agents/harnesses/opencode/) [Think](https://developers.cloudflare.com/agents/harnesses/think/)

[Workspace](https://developers.cloudflare.com/agents/tools/filesystem/) [Sandbox](https://developers.cloudflare.com/agents/tools/sandbox/) [Browser](https://developers.cloudflare.com/agents/tools/browser/) [Web fetch](https://developers.cloudflare.com/agents/tools/web-fetch/) [Web search](https://developers.cloudflare.com/agents/tools/web-search/) [MCP servers](https://developers.cloudflare.com/agents/tools/mcp/) [AI Search](https://developers.cloudflare.com/agents/tools/ai-search/) [Payments](https://developers.cloudflare.com/agents/tools/payments/)

[ObservabilityLogs · metrics · traces](https://developers.cloudflare.com/agents/runtime/observability/)

Agents on Cloudflare are composed from four parts:

- **The runtime is a Durable Object, the Lifecycle, and capabilities.** Each agent is a [Durable Object](https://developers.cloudflare.com/durable-objects/), and [routing](https://developers.cloudflare.com/agents/runtime/routing/) sends each request to the right one. The Agents SDK [Lifecycle](https://developers.cloudflare.com/agents/runtime/lifecycle/) runs inside the Durable Object, handles its requests, alarms, and WebSocket events, and starts the [capabilities](https://developers.cloudflare.com/agents/runtime/capabilities/) you add to it with `.use()`. Capabilities include [`WebSockets`](https://developers.cloudflare.com/agents/runtime/capabilities/websockets/), [`State`](https://developers.cloudflare.com/agents/runtime/capabilities/state/), [`Scheduler`](https://developers.cloudflare.com/agents/runtime/capabilities/scheduler/), and [`MCPClientManager`](https://developers.cloudflare.com/agents/runtime/capabilities/mcp-client-manager/).
- **The harness is the capability that runs the agent loop.** A harness calls models, runs tools, handles tool results, streams responses, and decides whether to continue. It is the unit of compute for an agent, and the Agents SDK exists to make harnesses run well on Cloudflare. Use the [Pi harness](https://developers.cloudflare.com/agents/harnesses/pi/), which runs the [Pi ↗︎](https://pi.dev/) agent loop durably and keeps a run going after the object is evicted.
- **Tools** let the agent act. For a durable file system and code execution, give the agent a [workspace](https://developers.cloudflare.com/agents/tools/filesystem/) from Cloudflare Computer. The Agents SDK also includes [web fetch](https://developers.cloudflare.com/agents/tools/web-fetch/), [web search](https://developers.cloudflare.com/agents/tools/web-search/), [browser automation](https://developers.cloudflare.com/agents/tools/browser/), [sandboxed code execution](https://developers.cloudflare.com/agents/tools/sandbox/), [AI Search](https://developers.cloudflare.com/agents/tools/ai-search/), [MCP servers](https://developers.cloudflare.com/agents/tools/mcp/), [payments](https://developers.cloudflare.com/agents/tools/payments/), and [Code Mode](https://developers.cloudflare.com/agents/tools/codemode/).
- **Communication channels** define how users and systems reach your agent, such as [chat](https://developers.cloudflare.com/agents/agent-class/communication-channels/chat/), [voice](https://developers.cloudflare.com/agents/agent-class/communication-channels/voice/), [email](https://developers.cloudflare.com/agents/agent-class/communication-channels/email/), [Slack](https://developers.cloudflare.com/agents/agent-class/communication-channels/slack/), [webhooks](https://developers.cloudflare.com/agents/agent-class/communication-channels/webhooks/), and other event sources. These guides use the [`Agent` class](https://developers.cloudflare.com/agents/agent-class/), a preset Durable Object with the Lifecycle and a set of capabilities already installed.

Agents publish structured events, such as state changes, schedules, and MCP connections, that you can use for [observability](https://developers.cloudflare.com/agents/runtime/observability/).

### Get started

Build your first agent with the Pi harness. The [Pi harness](https://developers.cloudflare.com/agents/harnesses/pi/) runs the [Pi ↗︎](https://pi.dev/) agent loop durably in a Durable Object. It uses the Lifecycle's job queue to schedule future work, so a run continues after the object is evicted. No API keys are required. The examples use [Workers AI](https://developers.cloudflare.com/workers-ai/) through the `AI` binding.

npmyarnpnpmbun

```
npm i agents @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/pi-schema @earendil-works/chord
```

```
yarn add agents @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/pi-schema @earendil-works/chord
```

```
pnpm add agents @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/pi-schema @earendil-works/chord
```

```
bun add agents @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/pi-schema @earendil-works/chord
```

The Pi packages are optional peer dependencies of `agents`, at `~1.5.0`. Pi Durable is experimental and its API can change in minor releases, so each `agents` release supports one Pi minor version. Install the versions your package manager resolves for `agents`.

To start from a complete app with a browser UI, a Cloudflare Computer workspace, and code execution, deploy the Pi harness example:

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/agents/tree/main/examples/next/harnesses/pi)

To build it step by step, follow [Build your first Durable Agent](https://developers.cloudflare.com/agents/getting-started/quick-start/). To learn the Lifecycle, [`State`](https://developers.cloudflare.com/agents/runtime/capabilities/state/), and [`WebSockets`](https://developers.cloudflare.com/agents/runtime/capabilities/websockets/) without a model, refer to [Learn the runtime](https://developers.cloudflare.com/agents/getting-started/learn-the-runtime/). To add the Lifecycle to a Worker you already have, refer to [Add to an existing project](https://developers.cloudflare.com/agents/getting-started/add-to-existing-project/).

### Example agents

The Pi agent runs on the Pi harness. The other examples build on the [`Agent` class](https://developers.cloudflare.com/agents/agent-class/) preset.

[Pi agent](https://developers.cloudflare.com/agents/harnesses/pi/)

Build an agent on the Pi harness, with tools, sessions, and recovery after eviction.

[Chat agent](https://developers.cloudflare.com/agents/examples/chat-agent/)

Build a streaming AI chat agent with tools and human-in-the-loop approvals.

[Slack agent](https://developers.cloudflare.com/agents/examples/slack-agent/)

Build an agent that responds to Slack messages, mentions, and commands.

[Voice agent](https://developers.cloudflare.com/agents/examples/voice-agent/)

Build a real-time voice agent with speech-to-text and text-to-speech.

[Browser agent](https://developers.cloudflare.com/agents/examples/browser-agent/)

Build an agent that can inspect pages, capture screenshots, and use browser tools.

[Email agent](https://developers.cloudflare.com/agents/examples/email-agent/)

Build an agent that sends, receives, routes, and replies to email.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/agents/#page","headline":"Build Agents on Cloudflare","description":"Build and host AI agents on Cloudflare. Run an agent harness in a Durable Object, add capabilities such as state, WebSockets, and scheduling with the Agents SDK Lifecycle, and give the agent tools.","url":"https://developers.cloudflare.com/agents/","inLanguage":"en","image":"https://developers.cloudflare.com/agents/og.png?v=5f3790c1b824e669","dateModified":"2026-10-29","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: Explore demo applications and reference architectures built with Workers AI.
title: Demos and architectures
image: https://developers.cloudflare.com/workers-ai/guides/demos-architectures/og.png?v=55e90558513810b9
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Demos and architectures

Last updated May 19, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/demos-architectures/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Workers AI can be used to build dynamic and performant services. The following demo applications and reference architectures showcase how to use Workers AI optimally within your architecture.

## Reference architectures

Explore the following reference architectures that use Workers AI:

[**Fullstack applications** A practical example of how these services come together in a real fullstack application architecture.](https://developers.cloudflare.com/reference-architecture/diagrams/serverless/fullstack-application/)

[**Storing user generated content** Store user-generated content in R2 for fast, secure, and cost-effective architecture.](https://developers.cloudflare.com/reference-architecture/diagrams/storage/storing-user-generated-content/)

[**Optimizing and securing connected transportation systems** This diagram showcases Cloudflare components optimizing connected transportation systems. It illustrates how their technologies minimize latency, ensure reliability, and strengthen security for critical data flow.](https://developers.cloudflare.com/reference-architecture/diagrams/iot/optimizing-and-securing-connected-transportation-systems/)

[**Ingesting BigQuery Data into Workers AI** You can connect a Cloudflare Worker to get data from Google BigQuery and pass it to Workers AI, to run AI Models, powered by serverless GPUs.](https://developers.cloudflare.com/reference-architecture/diagrams/ai/bigquery-workers-ai/)

[**Multi-vendor AI observability and control** By shifting features such as rate limiting, caching, and error handling to the proxy layer, organizations can apply unified configurations across services and inference service providers.](https://developers.cloudflare.com/reference-architecture/diagrams/ai/ai-multivendor-observability-control/)

[**Composable AI architecture** The architecture diagram illustrates how AI applications can be built end-to-end on Cloudflare, or single services can be integrated with external infrastructure and services.](https://developers.cloudflare.com/reference-architecture/diagrams/ai/ai-composable/)

[**Content-based asset creation** AI systems combine text-generation and text-to-image models to create visual content from text. They generate prompts, moderate content, and produce images for various applications.](https://developers.cloudflare.com/reference-architecture/diagrams/ai/ai-asset-creation/)

[**Retrieval Augmented Generation (RAG)** RAG combines retrieval with generative models for better text. It uses external knowledge to create factual, relevant responses, improving coherence and accuracy in NLP tasks like chatbots.](https://developers.cloudflare.com/reference-architecture/diagrams/ai/ai-rag/)

[**Automatic captioning for video uploads** By integrating automatic speech recognition technology into video platforms, content creators, publishers, and distributors can reach a broader audience, including individuals with hearing impairments or those who prefer to consume content in different languages.](https://developers.cloudflare.com/reference-architecture/diagrams/ai/ai-video-caption/)

[**Serverless image content management** Leverage various components of Cloudflare's ecosystem to construct a scalable image management solution](https://developers.cloudflare.com/reference-architecture/diagrams/serverless/serverless-image-content-management/)

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/demos-architectures/#page","headline":"Demos and architectures","description":"Explore demo applications and reference architectures built with Workers AI.","url":"https://developers.cloudflare.com/workers-ai/guides/demos-architectures/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/demos-architectures/og.png?v=55e90558513810b9","dateModified":"2026-05-19","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Step-by-step Workers AI tutorials for building AI-powered applications on Cloudflare.
title: Tutorials
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/og.png?v=b1a5618c45b0b1d2
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Tutorials

Last updated May 19, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

View tutorials to help you get started with Workers AI.

| Name | Last Updated | Difficulty |
| --- | --- | --- |
| [Build an AI code interpreter](https://developers.cloudflare.com/sandbox/get-started/build-an-ai-code-interpreter/) | 2 months ago | Intermediate |
| [Code interpreter with Workers AI](https://developers.cloudflare.com/sandbox/sdk/tutorials/workers-ai-code-interpreter/) | 10 months ago | Intermediate |
| [Whisper-large-v3-turbo with Cloudflare Workers AI](https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-workers-ai-whisper-with-chunking/) | 2 years ago | Beginner |
| [Llama 3.2 11B Vision Instruct model on Cloudflare Workers AI](https://developers.cloudflare.com/workers-ai/guides/tutorials/llama-vision-tutorial/) | 2 years ago | Beginner |
| [Store and Catalog AI Generated Images with R2 (Part 3)](https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-store-and-catalog/) | 2 years ago | Beginner |
| [Build a Retrieval Augmented Generation (RAG) AI](https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/) | 2 years ago | Beginner |
| [Using BigQuery with Workers AI](https://developers.cloudflare.com/workers-ai/guides/tutorials/using-bigquery-with-workers-ai/) | 2 years ago | Beginner |
| [How to Build an Image Generator using Workers AI](https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/) | 2 years ago | Beginner |
| [Build an AI Image Generator Playground (Part 1)](https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux/) | 2 years ago | Beginner |
| [Add New AI Models to your Playground (Part 2)](https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux-newmodels/) | 2 years ago | Beginner |
| [Use event notification to summarize PDF files on upload](https://developers.cloudflare.com/r2/tutorials/summarize-pdf/) | 2 years ago | Intermediate |
| [Explore Workers AI Models Using a Jupyter Notebook](https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-workers-ai-models-using-a-jupyter-notebook/) | 2 years ago | Beginner |
| [Fine Tune Models With AutoTrain from HuggingFace](https://developers.cloudflare.com/workers-ai/guides/tutorials/fine-tune-models-with-autotrain/) | 3 years ago | Beginner |
| [Explore Code Generation Using DeepSeek Coder Models](https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-code-generation-using-deepseek-coder-models/) | 3 years ago | Beginner |
| [Choose the Right Text Generation Model](https://developers.cloudflare.com/workers-ai/guides/tutorials/how-to-choose-the-right-text-generation-model/) | 3 years ago | Beginner |

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/#page","headline":"Tutorials","description":"Step-by-step Workers AI tutorials for building AI-powered applications on Cloudflare.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/og.png?v=b1a5618c45b0b1d2","dateModified":"2026-05-19","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: Build your first AI app with Cloudflare AI. This guide uses Workers AI, Vectorize, D1, and Cloudflare Workers.
title: Build a Retrieval Augmented Generation (RAG) AI
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/og.png?v=d22edb3120c35b56
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Build a Retrieval Augmented Generation (RAG) AI

Last updated Aug 25, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

This guide will instruct you through setting up and deploying your first application with Cloudflare AI. You will build a fully-featured AI-powered application, using tools like Workers AI, Vectorize, D1, and Cloudflare Workers.

Looking for a managed option?

[AI Search](https://developers.cloudflare.com/ai-search/) offers a fully managed way to build RAG pipelines on Cloudflare, handling ingestion, indexing, and querying out of the box. [Get started](https://developers.cloudflare.com/ai-search/get-started/).

At the end of this tutorial, you will have built an AI tool that allows you to store information and query it using a Large Language Model. This pattern, known as Retrieval Augmented Generation, or RAG, is a useful project you can build by combining multiple aspects of Cloudflare's AI toolkit. You do not need to have experience working with AI tools to build this application.

1. Sign up for a [Cloudflare account ↗︎](https://dash.cloudflare.com/sign-up/workers-and-pages).
2. Install [`Node.js` ↗︎](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).

<details>

<summary>

Node.js version manager

</summary>

Use <a href="https://viteplus.dev/guide/env">Vite+ (<code>vp env</code>) ↗︎</a> to install and manage Node.js versions.

For supported Node.js versions, refer to the <a href="https://developers.cloudflare.com/workers/wrangler/install-and-update/#install-wrangler">Wrangler system requirements</a>.

</details>

You will also need access to [Vectorize](https://developers.cloudflare.com/vectorize/platform/pricing/). During this tutorial, we will show how you can optionally integrate with [Anthropic Claude ↗︎](http://anthropic.com) as well. You will need an [Anthropic API key ↗︎](https://docs.anthropic.com/en/api/getting-started) to do so.

## 1. Create a new Worker project

C3 (`create-cloudflare-cli`) is a command-line tool designed to help you setup and deploy Workers to Cloudflare as fast as possible.

Open a terminal window and run C3 to create your Worker project:

npmyarnpnpm

```
npm create cloudflare@latest -- rag-ai-tutorial
```

```
yarn create cloudflare rag-ai-tutorial
```

```
pnpm create cloudflare@latest rag-ai-tutorial
```

For setup, select the following options:

- For *What would you like to start with?*, choose `Hello World example`.
- For *Which template would you like to use?*, choose `Worker only`.
- For *Which language do you want to use?*, choose `JavaScript`.
- For *Do you want to use git for version control?*, choose `Yes`.
- For *Do you want to add an AGENTS.md file to help AI coding tools understand Cloudflare APIs?*, choose `Yes`.
- For *Do you want to deploy your application?*, choose `No` (we will be making some changes before deploying).

In your project directory, C3 has generated several files.

<details>

<summary>

What files did C3 create?

</summary>

1. <code>wrangler.jsonc</code>: Your <a href="https://developers.cloudflare.com/workers/wrangler/configuration/#sample-wrangler-configuration">Wrangler</a> configuration file.
2. <code>index.js</code> (in <code>/src</code>): A minimal <code>'Hello World!'</code> Worker written in <a href="https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/">ES module</a> syntax.
3. <code>package.json</code>: A minimal Node dependencies configuration file.
4. <code>package-lock.json</code>: Refer to <a href="https://docs.npmjs.com/cli/v9/configuring-npm/package-lock-json"><code>npm</code> documentation on <code>package-lock.json</code> ↗︎</a>.
5. <code>node_modules</code>: Refer to <a href="https://docs.npmjs.com/cli/v7/configuring-npm/folders#node-modules"><code>npm</code> documentation <code>node_modules</code> ↗︎</a>.

</details>

Now, move into your newly created directory:

```sh
cd rag-ai-tutorial
```

## 2. Develop with Wrangler CLI

The Workers command-line interface, [Wrangler](https://developers.cloudflare.com/workers/wrangler/install-and-update/), allows you to [create](https://developers.cloudflare.com/workers/wrangler/commands/general/#init), [test](https://developers.cloudflare.com/workers/wrangler/commands/general/#dev), and [deploy](https://developers.cloudflare.com/workers/wrangler/commands/general/#deploy) your Workers projects. C3 will install Wrangler in projects by default.

After you have created your first Worker, run the [`wrangler dev`](https://developers.cloudflare.com/workers/wrangler/commands/general/#dev) command in the project directory to start a local server for developing your Worker. This will allow you to test your Worker locally during development.

```sh
npx wrangler dev
```

You will now be able to go to [http://localhost:8787 ↗︎](http://localhost:8787) to see your Worker running. Any changes you make to your code will trigger a rebuild, and reloading the page will show you the up-to-date output of your Worker.

## 3. Adding the AI binding

To begin using Cloudflare's AI products, you can add the `ai` block to the [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/configuration/) as a [remote binding](https://developers.cloudflare.com/workers/local-development/#remote-bindings). This will set up a binding to Cloudflare's AI models in your code that you can use to interact with the available AI models on the platform.

Note

If you have not used Wrangler before, it will try to open your web browser to login with your Cloudflare account.

If you have issues with this step or you do not have access to a browser interface, refer to the [`wrangler login`](https://developers.cloudflare.com/workers/wrangler/commands/general/#login) documentation for more information.

This example features the [`@cf/meta/llama-3-8b-instruct` model](https://developers.cloudflare.com/workers-ai/models/llama-3-8b-instruct/), which generates text.

```jsonc
{
	"ai": {
		"binding": "AI",
		"remote": true
	}
}
```

```toml
[ai]
binding = "AI"
remote = true
```

Now, find the `src/index.js` file. Inside the `fetch` handler, you can query the `AI` binding:

```js
export default {
	async fetch(request, env, ctx) {
		const answer = await env.AI.run("@cf/meta/llama-3-8b-instruct", {
			messages: [{ role: "user", content: `What is the square root of 9?` }],
		});

		return new Response(JSON.stringify(answer));
	},
};
```

By querying the LLM through the `AI` binding, we can interact directly with Cloudflare AI's large language models directly in our code. In this example, we are using the [`@cf/meta/llama-3-8b-instruct` model](https://developers.cloudflare.com/workers-ai/models/llama-3-8b-instruct/), which generates text.

Deploy your Worker using `wrangler`:

```sh
npx wrangler deploy
```

Making a request to your Worker will now generate a text response from the LLM, and return it as a JSON object.

```sh
curl https://example.username.workers.dev
```

```sh
{"response":"Answer: The square root of 9 is 3."}
```

## 4. Adding embeddings using Cloudflare D1 and Vectorize

Embeddings allow you to add additional capabilities to the language models you can use in your Cloudflare AI projects. This is done via **Vectorize**, Cloudflare's vector database.

To begin using Vectorize, create a new embeddings index using `wrangler`. This index will store vectors with 768 dimensions, and will use cosine similarity to determine which vectors are most similar to each other:

```sh
npx wrangler vectorize create vector-index --dimensions=768 --metric=cosine
```

Then, add the configuration details for your new Vectorize index to the [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/configuration/):

```jsonc
{
	// ... existing wrangler configuration
	"vectorize": [
		{
			"binding": "VECTOR_INDEX",
			"index_name": "vector-index"
		}
	]
}
```

```toml
[[vectorize]]
binding = "VECTOR_INDEX"
index_name = "vector-index"
```

A vector index allows you to store a collection of dimensions, which are floating point numbers used to represent your data. When you want to query the vector database, you can also convert your query into dimensions. **Vectorize** is designed to efficiently determine which stored vectors are most similar to your query.

To implement the searching feature, you must set up a D1 database from Cloudflare. In D1, you can store your app's data. Then, you change this data into a vector format. When someone searches and it matches the vector, you can show them the matching data.

Create a new D1 database using `wrangler`:

```sh
npx wrangler d1 create database
```

Then, paste the configuration details output from the previous command into the [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/configuration/):

```jsonc
{
	// ... existing wrangler configuration
	"d1_databases": [
		{
			"binding": "DB", // available in your Worker on env.DB
			"database_name": "database",
			"database_id": "abc-def-geh" // replace this with a real database_id (UUID)
		}
	]
}
```

```toml
[[d1_databases]]
binding = "DB"
database_name = "database"
database_id = "abc-def-geh"
```

In this application, we'll create a `notes` table in D1, which will allow us to store notes and later retrieve them in Vectorize. To create this table, run a SQL command using `wrangler d1 execute`:

```sh
npx wrangler d1 execute database --remote --command "CREATE TABLE IF NOT EXISTS notes (id INTEGER PRIMARY KEY, text TEXT NOT NULL)"
```

Now, we can add a new note to our database using `wrangler d1 execute`:

```sh
npx wrangler d1 execute database --remote --command "INSERT INTO notes (text) VALUES ('The best pizza topping is pepperoni')"
```

## 5. Creating a workflow

Before we begin creating notes, we will introduce a [Cloudflare Workflow](https://developers.cloudflare.com/workflows). This will allow us to define a durable workflow that can safely and robustly execute all the steps of the RAG process.

To begin, add a new `[[workflows]]` block to your [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/configuration/):

```jsonc
{
	// ... existing wrangler configuration
	"workflows": [
		{
			"name": "rag",
			"binding": "RAG_WORKFLOW",
			"class_name": "RAGWorkflow"
		}
	]
}
```

```toml
[[workflows]]
name = "rag"
binding = "RAG_WORKFLOW"
class_name = "RAGWorkflow"
```

In `src/index.js`, add a new class called `RAGWorkflow` that extends `WorkflowEntrypoint`:

```js
import { WorkflowEntrypoint } from "cloudflare:workers";

export class RAGWorkflow extends WorkflowEntrypoint {
	async run(event, step) {
		await step.do("example step", async () => {
			console.log("Hello World!");
		});
	}
}
```

This class will define a single workflow step that will log "Hello World!" to the console. You can add as many steps as you need to your workflow.

On its own, this workflow will not do anything. To execute the workflow, we will call the `RAG_WORKFLOW` binding, passing in any parameters that the workflow needs to properly complete. Here is an example of how we can call the workflow:

```js
env.RAG_WORKFLOW.create({ params: { text } });
```

## 6. Creating notes and adding them to Vectorize

To expand on your Workers function in order to handle multiple routes, we will add `hono`, a routing library for Workers. This will allow us to create a new route for adding notes to our database. Install `hono` using `npm`:

npmyarnpnpmbun

```
npm i hono
```

```
yarn add hono
```

```
pnpm add hono
```

```
bun add hono
```

Then, import `hono` into your `src/index.js` file. You should also update the `fetch` handler to use `hono`:

```js
import { Hono } from "hono";
const app = new Hono();

app.get("/", async (c) => {
	const answer = await c.env.AI.run("@cf/meta/llama-3-8b-instruct", {
		messages: [{ role: "user", content: `What is the square root of 9?` }],
	});

	return c.json(answer);
});

export default app;
```

This will establish a route at the root path `/` that is functionally equivalent to the previous version of your application.

Now, we can update our workflow to begin adding notes to our database, and generating the related embeddings for them.

This example features the [`@cf/baai/bge-base-en-v1.5` model](https://developers.cloudflare.com/workers-ai/models/bge-base-en-v1.5/), which can be used to create an embedding. Embeddings are stored and retrieved inside [Vectorize](https://developers.cloudflare.com/vectorize/), Cloudflare's vector database. The user query is also turned into an embedding so that it can be used for searching within Vectorize.

```js
import { WorkflowEntrypoint } from "cloudflare:workers";

export class RAGWorkflow extends WorkflowEntrypoint {
	async run(event, step) {
		const env = this.env;
		const { text } = event.payload;

		const record = await step.do(`create database record`, async () => {
			const query = "INSERT INTO notes (text) VALUES (?) RETURNING *";

			const { results } = await env.DB.prepare(query).bind(text).run();

			const record = results[0];
			if (!record) throw new Error("Failed to create note");
			return record;
		});

		const embedding = await step.do(`generate embedding`, async () => {
			const embeddings = await env.AI.run("@cf/baai/bge-base-en-v1.5", {
				text: text,
			});
			const values = embeddings.data[0];
			if (!values) throw new Error("Failed to generate vector embedding");
			return values;
		});

		await step.do(`insert vector`, async () => {
			return env.VECTOR_INDEX.upsert([
				{
					id: record.id.toString(),
					values: embedding,
				},
			]);
		});
	}
}
```

The workflow does the following things:

1. Accepts a `text` parameter.
2. Insert a new row into the `notes` table in D1, and retrieve the `id` of the new row.
3. Convert the `text` into a vector using the `embeddings` model of the LLM binding.
4. Upsert the `id` and `vectors` into the `vector-index` index in Vectorize.

By doing this, you will create a new vector representation of the note, which can be used to retrieve the note later.

To complete the code, we will add a route that allows users to submit notes to the database. This route will parse the JSON request body, get the `note` parameter, and create a new instance of the workflow, passing the parameter:

```js
app.post("/notes", async (c) => {
	const { text } = await c.req.json();
	if (!text) return c.text("Missing text", 400);
	await c.env.RAG_WORKFLOW.create({ params: { text } });
	return c.text("Created note", 201);
});
```

## 7. Querying Vectorize to retrieve notes

To complete your code, you can update the root path (`/`) to query Vectorize. You will convert the query into a vector, and then use the `vector-index` index to find the most similar vectors.

The `topK` parameter limits the number of vectors returned by the function. For instance, providing a `topK` of 1 will only return the *most similar* vector based on the query. Setting `topK` to 5 will return the 5 most similar vectors.

Given a list of similar vectors, you can retrieve the notes that match the record IDs stored alongside those vectors. In this case, we are only retrieving a single note - but you may customize this as needed.

You can insert the text of those notes as context into the prompt for the LLM binding. This is the basis of Retrieval-Augmented Generation, or RAG: providing additional context from data outside of the LLM to enhance the text generated by the LLM.

We'll update the prompt to include the context, and to ask the LLM to use the context when responding:

```js
import { Hono } from "hono";
const app = new Hono();

// Existing post route...
// app.post('/notes', async (c) => { ... })

app.get("/", async (c) => {
	const question = c.req.query("text") || "What is the square root of 9?";

	const embeddings = await c.env.AI.run("@cf/baai/bge-base-en-v1.5", {
		text: question,
	});
	const vectors = embeddings.data[0];

	const vectorQuery = await c.env.VECTOR_INDEX.query(vectors, { topK: 1 });
	let vecId;
	if (
		vectorQuery.matches &&
		vectorQuery.matches.length > 0 &&
		vectorQuery.matches[0]
	) {
		vecId = vectorQuery.matches[0].id;
	} else {
		console.log("No matching vector found or vectorQuery.matches is empty");
	}

	let notes = [];
	if (vecId) {
		const query = `SELECT * FROM notes WHERE id = ?`;
		const { results } = await c.env.DB.prepare(query).bind(vecId).run();
		if (results) notes = results.map((vec) => vec.text);
	}

	const contextMessage = notes.length
		? `Context:\n${notes.map((note) => `- ${note}`).join("\n")}`
		: "";

	const systemPrompt = `When answering the question or responding, use the context provided, if it is provided and relevant.`;

	const { response: answer } = await c.env.AI.run(
		"@cf/meta/llama-3-8b-instruct",
		{
			messages: [
				...(notes.length ? [{ role: "system", content: contextMessage }] : []),
				{ role: "system", content: systemPrompt },
				{ role: "user", content: question },
			],
		},
	);

	return c.text(answer);
});

app.onError((err, c) => {
	return c.text(err);
});

export default app;
```

## 8. Adding Anthropic Claude model (optional)

If you are working with larger documents, you have the option to use Anthropic's [Claude models ↗︎](https://claude.ai/), which have large context windows and are well-suited to RAG workflows.

To begin, install the `@anthropic-ai/sdk` package:

npmyarnpnpmbun

```
npm i @anthropic-ai/sdk
```

```
yarn add @anthropic-ai/sdk
```

```
pnpm add @anthropic-ai/sdk
```

```
bun add @anthropic-ai/sdk
```

In `src/index.js`, you can update the `GET /` route to check for the `ANTHROPIC_API_KEY` environment variable. If it is set, we can generate text using the Anthropic SDK. If it is not set, we'll fall back to the existing Workers AI code:

```js
import Anthropic from '@anthropic-ai/sdk';

app.get('/', async (c) => {
  // ... Existing code
	const systemPrompt = `When answering the question or responding, use the context provided, if it is provided and relevant.`

	let modelUsed = ""
	let response = null

	if (c.env.ANTHROPIC_API_KEY) {
		const anthropic = new Anthropic({
			apiKey: c.env.ANTHROPIC_API_KEY
		})

		const model = "claude-3-5-sonnet-latest"
		modelUsed = model

		const message = await anthropic.messages.create({
			max_tokens: 1024,
			model,
			messages: [
				{ role: 'user', content: question }
			],
			system: [systemPrompt, notes ? contextMessage : ''].join(" ")
		})

		response = {
			response: message.content.map(content => content.text).join("\n")
		}
	} else {
		const model = "@cf/meta/llama-3.1-8b-instruct"
		modelUsed = model

		response = await c.env.AI.run(
			model,
			{
				messages: [
					...(notes.length ? [{ role: 'system', content: contextMessage }] : []),
					{ role: 'system', content: systemPrompt },
					{ role: 'user', content: question }
				]
			}
		)
	}

	if (response) {
		c.header('x-model-used', modelUsed)
		return c.text(response.response)
	} else {
		return c.text("We were unable to generate output", 500)
	}
})
```

Finally, you'll need to set the `ANTHROPIC_API_KEY` environment variable in your Workers application. You can do this by using `wrangler secret put`:

```sh
$ npx wrangler secret put ANTHROPIC_API_KEY
```

## 9. Deleting notes and vectors

If you no longer need a note, you can delete it from the database. Any time that you delete a note, you will also need to delete the corresponding vector from Vectorize. You can implement this by building a `DELETE /notes/:id` route in your `src/index.js` file:

```js
app.delete("/notes/:id", async (c) => {
	const { id } = c.req.param();

	const query = `DELETE FROM notes WHERE id = ?`;
	await c.env.DB.prepare(query).bind(id).run();

	await c.env.VECTOR_INDEX.deleteByIds([id]);

	return c.status(204);
});
```

## 10. Text splitting (optional)

For large pieces of text, it is recommended to split the text into smaller chunks. This allows LLMs to more effectively gather relevant context, without needing to retrieve large pieces of text.

To implement this, we'll add a new NPM package to our project, \`@langchain/textsplitters':

npmyarnpnpmbun

```
npm i @langchain/textsplitters
```

```
yarn add @langchain/textsplitters
```

```
pnpm add @langchain/textsplitters
```

```
bun add @langchain/textsplitters
```

The `RecursiveCharacterTextSplitter` class provided by this package will split the text into smaller chunks. It can be customized to your liking, but the default config works in most cases:

```js
import { RecursiveCharacterTextSplitter } from "@langchain/textsplitters";

const text = "Some long piece of text...";

const splitter = new RecursiveCharacterTextSplitter({
	// These can be customized to change the chunking size
	// chunkSize: 1000,
	// chunkOverlap: 200,
});

const output = await splitter.createDocuments([text]);
console.log(output); // [{ pageContent: 'Some long piece of text...' }]
```

To use this splitter, we'll update the workflow to split the text into smaller chunks. We'll then iterate over the chunks and run the rest of the workflow for each chunk of text:

```js
export class RAGWorkflow extends WorkflowEntrypoint {
	async run(event, step) {
		const env = this.env;
		const { text } = event.payload;
		let texts = await step.do("split text", async () => {
			const splitter = new RecursiveCharacterTextSplitter();
			const output = await splitter.createDocuments([text]);
			return output.map((doc) => doc.pageContent);
		});

		console.log(
			"RecursiveCharacterTextSplitter generated ${texts.length} chunks",
		);

		for (const index in texts) {
			const text = texts[index];
			const record = await step.do(
				`create database record: ${index}/${texts.length}`,
				async () => {
					const query = "INSERT INTO notes (text) VALUES (?) RETURNING *";

					const { results } = await env.DB.prepare(query).bind(text).run();

					const record = results[0];
					if (!record) throw new Error("Failed to create note");
					return record;
				},
			);

			const embedding = await step.do(
				`generate embedding: ${index}/${texts.length}`,
				async () => {
					const embeddings = await env.AI.run("@cf/baai/bge-base-en-v1.5", {
						text: text,
					});
					const values = embeddings.data[0];
					if (!values) throw new Error("Failed to generate vector embedding");
					return values;
				},
			);

			await step.do(`insert vector: ${index}/${texts.length}`, async () => {
				return env.VECTOR_INDEX.upsert([
					{
						id: record.id.toString(),
						values: embedding,
					},
				]);
			});
		}
	}
}
```

Now, when large pieces of text are submitted to the `/notes` endpoint, they will be split into smaller chunks, and each chunk will be processed by the workflow.

## 11. Deploy your project

If you did not deploy your Worker during [step 1](https://developers.cloudflare.com/workers/get-started/guide/#1-create-a-new-worker-project), deploy your Worker via Wrangler, to a `*.workers.dev` subdomain, or a [Custom Domain](https://developers.cloudflare.com/workers/configuration/routing/custom-domains/), if you have one configured. If you have not configured any subdomain or domain, Wrangler will prompt you during the publish process to set one up.

```sh
npx wrangler deploy
```

Preview your Worker at `<YOUR_WORKER>.<YOUR_SUBDOMAIN>.workers.dev`.

Note

When pushing to your `*.workers.dev` subdomain for the first time, you may see [`523` errors](https://developers.cloudflare.com/support/troubleshooting/http-status-codes/cloudflare-5xx-errors/error-523/) while DNS is propagating. These errors should resolve themselves after a minute or so.

## Related resources

A full version of this codebase is available on GitHub. It includes a frontend UI for querying, adding, and deleting notes, as well as a backend API for interacting with the database and vector index. You can find it here: [github.com/kristianfreeman/cloudflare-retrieval-augmented-generation-example ↗︎](https://github.com/kristianfreeman/cloudflare-retrieval-augmented-generation-example/).

To do more:

- Explore the reference diagram for a [Retrieval Augmented Generation (RAG) Architecture](https://developers.cloudflare.com/reference-architecture/diagrams/ai/ai-rag/).
- Review Cloudflare's [AI documentation](https://developers.cloudflare.com/workers-ai).
- Review [Tutorials](https://developers.cloudflare.com/workers/tutorials/) to build projects on Workers.
- Explore [Examples](https://developers.cloudflare.com/workers/examples/) to experiment with copy and paste Worker code.
- Understand how Workers works in [Reference](https://developers.cloudflare.com/workers/reference/).
- Learn about Workers features and functionality in [Platform](https://developers.cloudflare.com/workers/platform/).
- Set up [Wrangler](https://developers.cloudflare.com/workers/wrangler/install-and-update/) to programmatically create, test, and deploy your Worker projects.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/#page","headline":"Build a Retrieval Augmented Generation (RAG) AI","description":"Build your first AI app with Cloudflare AI. This guide uses Workers AI, Vectorize, D1, and Cloudflare Workers.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/og.png?v=d22edb3120c35b56","dateModified":"2026-08-25","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI","Hono","JavaScript"]}
```

---

---
description: Learn how to transcribe large audio files using Workers AI.
title: Whisper-large-v3-turbo with Cloudflare Workers AI
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-workers-ai-whisper-with-chunking/og.png?v=20179da55475897c
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Whisper-large-v3-turbo with Cloudflare Workers AI

Last updated Aug 25, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-workers-ai-whisper-with-chunking/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

In this tutorial you will learn how to:

- **Transcribe large audio files:** Use the [Whisper-large-v3-turbo](https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/) model from Cloudflare Workers AI to perform automatic speech recognition (ASR) or translation.
- **Handle large files:** Split large audio files into smaller chunks for processing, which helps overcome memory and execution time limitations.
- **Deploy using Cloudflare Workers:** Create a scalable, low‑latency transcription pipeline in a serverless environment.

## 1: Create a new Cloudflare Worker project

1. Sign up for a [Cloudflare account ↗︎](https://dash.cloudflare.com/sign-up/workers-and-pages).
2. Install [`Node.js` ↗︎](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm).

<details>

<summary>

Node.js version manager

</summary>

Use <a href="https://viteplus.dev/guide/env">Vite+ (<code>vp env</code>) ↗︎</a> to install and manage Node.js versions.

For supported Node.js versions, refer to the <a href="https://developers.cloudflare.com/workers/wrangler/install-and-update/#install-wrangler">Wrangler system requirements</a>.

</details>

You will create a new Worker project using the `create-cloudflare` CLI (C3). [C3 ↗︎](https://github.com/cloudflare/workers-sdk/tree/main/packages/create-cloudflare) is a command-line tool designed to help you set up and deploy new applications to Cloudflare.

Create a new project named `whisper-tutorial` by running:

npmyarnpnpm

```
npm create cloudflare@latest -- whisper-tutorial
```

```
yarn create cloudflare whisper-tutorial
```

```
pnpm create cloudflare@latest whisper-tutorial
```

Running `npm create cloudflare@latest` will prompt you to install the [`create-cloudflare` package ↗︎](https://www.npmjs.com/package/create-cloudflare), and lead you through setup. C3 will also install [Wrangler](https://developers.cloudflare.com/workers/wrangler/), the Cloudflare Developer Platform CLI.

For setup, select the following options:

- For *What would you like to start with?*, choose `Hello World example`.
- For *Which template would you like to use?*, choose `Worker only`.
- For *Which language do you want to use?*, choose `TypeScript`.
- For *Do you want to use git for version control?*, choose `Yes`.
- For *Do you want to add an AGENTS.md file to help AI coding tools understand Cloudflare APIs?*, choose `Yes`.
- For *Do you want to deploy your application?*, choose `No` (we will be making some changes before deploying).

This will create a new `whisper-tutorial` directory. Your new `whisper-tutorial` directory will include:

- A `"Hello World"` [Worker](https://developers.cloudflare.com/workers/get-started/guide/#3-write-code) at `src/index.ts`.
- A [`wrangler.jsonc`](https://developers.cloudflare.com/workers/wrangler/configuration/) configuration file.

Go to your application directory:

```sh
cd whisper-tutorial
```

## 2. Connect your Worker to Workers AI

You must create an AI binding for your Worker to connect to Workers AI. [Bindings](https://developers.cloudflare.com/workers/runtime-apis/bindings/) allow your Workers to interact with resources, like Workers AI, on the Cloudflare Developer Platform.

To bind Workers AI to your Worker, add the following to the end of your Wrangler configuration file:

```jsonc
{
	"ai": {
		"binding": "AI"
	}
}
```

```toml
[ai]
binding = "AI"
```

Your binding is [available in your Worker code](https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/#bindings-in-es-modules-format) on [`env.AI`](https://developers.cloudflare.com/workers/runtime-apis/handlers/fetch/).

## 3. Configure Wrangler

In your wrangler file, add or update the following settings to enable Node.js APIs and polyfills (with a compatibility date of 2024‑09‑23 or later):

```jsonc
{
	"compatibility_flags": [
		"nodejs_compat"
	],
	// Set this to today's date
	"compatibility_date": "2026-11-10"
}
```

```toml
compatibility_flags = [ "nodejs_compat" ]
# Set this to today's date
compatibility_date = "2026-11-10"
```

## 4. Handle large audio files with chunking

Replace the contents of your `src/index.ts` file with the following integrated code. This sample demonstrates how to:

(1) Extract an audio file URL from the query parameters.

(2) Fetch the audio file while explicitly following redirects.

(3) Split the audio file into smaller chunks (such as, 1 MB chunks).

(4) Transcribe each chunk using the Whisper-large-v3-turbo model via the Cloudflare AI binding.

(5) Return the aggregated transcription as plain text.

```ts
import { Buffer } from "node:buffer";
import type { Ai } from "workers-ai";

export interface Env {
	AI: Ai;
	// If needed, add your KV namespace for storing transcripts.
	// MY_KV_NAMESPACE: KVNamespace;
}

/**
 * Fetches the audio file from the provided URL and splits it into chunks.
 * This function explicitly follows redirects.
 *
 * @param audioUrl - The URL of the audio file.
 * @returns An array of ArrayBuffers, each representing a chunk of the audio.
 */
async function getAudioChunks(audioUrl: string): Promise<ArrayBuffer[]> {
	const response = await fetch(audioUrl, { redirect: "follow" });
	if (!response.ok) {
		throw new Error(`Failed to fetch audio: ${response.status}`);
	}
	const arrayBuffer = await response.arrayBuffer();

	// Example: Split the audio into 1MB chunks.
	const chunkSize = 1024 * 1024; // 1MB
	const chunks: ArrayBuffer[] = [];
	for (let i = 0; i < arrayBuffer.byteLength; i += chunkSize) {
		const chunk = arrayBuffer.slice(i, i + chunkSize);
		chunks.push(chunk);
	}
	return chunks;
}

/**
 * Transcribes a single audio chunk using the Whisper‑large‑v3‑turbo model.
 * The function converts the audio chunk to a Base64-encoded string and
 * sends it to the model via the AI binding.
 *
 * @param chunkBuffer - The audio chunk as an ArrayBuffer.
 * @param env - The Cloudflare Worker environment, including the AI binding.
 * @returns The transcription text from the model.
 */
async function transcribeChunk(
	chunkBuffer: ArrayBuffer,
	env: Env,
): Promise<string> {
	const base64 = Buffer.from(chunkBuffer, "binary").toString("base64");
	const res = await env.AI.run("@cf/openai/whisper-large-v3-turbo", {
		audio: base64,
		// Optional parameters (uncomment and set if needed):
		// task: "transcribe",   // or "translate"
		// language: "en",
		// vad_filter: "false",
		// initial_prompt: "Provide context if needed.",
		// prefix: "Transcription:",
	});
	return res.text; // Assumes the transcription result includes a "text" property.
}

/**
 * The main fetch handler. It extracts the 'url' query parameter, fetches the audio,
 * processes it in chunks, and returns the full transcription.
 */
export default {
	async fetch(
		request: Request,
		env: Env,
		ctx: ExecutionContext,
	): Promise<Response> {
		// Extract the audio URL from the query parameters.
		const { searchParams } = new URL(request.url);
		const audioUrl = searchParams.get("url");

		if (!audioUrl) {
			return new Response("Missing 'url' query parameter", { status: 400 });
		}

		// Get the audio chunks.
		const audioChunks: ArrayBuffer[] = await getAudioChunks(audioUrl);
		let fullTranscript = "";

		// Process each chunk and build the full transcript.
		for (const chunk of audioChunks) {
			try {
				const transcript = await transcribeChunk(chunk, env);
				fullTranscript += transcript + "\n";
			} catch (error) {
				fullTranscript += "[Error transcribing chunk]\n";
			}
		}

		return new Response(fullTranscript, {
			headers: { "Content-Type": "text/plain" },
		});
	},
} satisfies ExportedHandler<Env>;
```

## 5. Deploy your Worker

1. **Run the Worker locally:**

   Use wrangler's development mode to test your Worker locally:

```sh
npx wrangler dev
```

Open your browser and go to [http://localhost:8787 ↗︎](http://localhost:8787), or use curl:

```sh
curl "http://localhost:8787?url=https://raw.githubusercontent.com/your-username/your-repo/main/your-audio-file.mp3"
```

Replace the URL query parameter with the direct link to your audio file. (For GitHub-hosted files, ensure you use the raw file URL.)

2. **Deploy the Worker:**

   Once testing is complete, deploy your Worker with:

```sh
npx wrangler deploy
```

3. **Test the deployed Worker:**

   After deployment, test your Worker by passing the audio URL as a query parameter:

```sh
curl "https://<your-worker-subdomain>.workers.dev?url=https://raw.githubusercontent.com/your-username/your-repo/main/your-audio-file.mp3"
```

Make sure to replace `<your-worker-subdomain>`, `your-username`, `your-repo`, and `your-audio-file.mp3` with your actual details.

If successful, the Worker will return a transcript of the audio file:

```sh
This is the transcript of the audio...
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-workers-ai-whisper-with-chunking/#page","headline":"Whisper-large-v3-turbo with Cloudflare Workers AI","description":"Learn how to transcribe large audio files using Workers AI.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-workers-ai-whisper-with-chunking/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-workers-ai-whisper-with-chunking/og.png?v=20179da55475897c","dateModified":"2026-08-25","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: Explore how you can use AI models to generate code and work more efficiently.
title: Explore Code Generation Using DeepSeek Coder Models
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-code-generation-using-deepseek-coder-models/og.png?v=63e789d0c94c8113
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Explore Code Generation Using DeepSeek Coder Models

Last updated Apr 30, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-code-generation-using-deepseek-coder-models/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

A handy way to explore all of the models available on [Workers AI](https://developers.cloudflare.com/workers-ai) is to use a [Jupyter Notebook ↗︎](https://jupyter.org/).

You can [download the DeepSeek Coder notebook](https://developers.cloudflare.com/workers-ai/static/documentation/notebooks/deepseek-coder-exploration.ipynb) or view the embedded notebook below.

---

## Exploring Code Generation Using DeepSeek Coder

AI Models being able to generate code unlocks all sorts of use cases. The [DeepSeek Coder ↗︎](https://github.com/deepseek-ai/DeepSeek-Coder) models `@hf/thebloke/deepseek-coder-6.7b-base-awq` and `@hf/thebloke/deepseek-coder-6.7b-instruct-awq` are now available on [Workers AI](https://developers.cloudflare.com/workers-ai).

Let's explore them using the API!

```python
import sys
!{sys.executable} -m pip install requests python-dotenv
```

```plaintext
Requirement already satisfied: requests in ./venv/lib/python3.12/site-packages (2.31.0)
Requirement already satisfied: python-dotenv in ./venv/lib/python3.12/site-packages (1.0.1)
Requirement already satisfied: charset-normalizer<4,>=2 in ./venv/lib/python3.12/site-packages (from requests) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.12/site-packages (from requests) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./venv/lib/python3.12/site-packages (from requests) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.12/site-packages (from requests) (2023.11.17)
```

```python
import os
from getpass import getpass

from IPython.display import display, Image, Markdown, Audio

import requests
```

```python
%load_ext dotenv
%dotenv
```

### Configuring your environment

To use the API you'll need your [Cloudflare Account ID ↗︎](https://dash.cloudflare.com) (head to Workers & Pages > Overview > Account details > Account ID) and a [Workers AI enabled API Token ↗︎](https://dash.cloudflare.com/profile/api-tokens).

If you want to add these files to your environment, you can create a new file named `.env`

```bash
CLOUDFLARE_API_TOKEN="YOUR-TOKEN"
CLOUDFLARE_ACCOUNT_ID="YOUR-ACCOUNT-ID"
```

```python
if "CLOUDFLARE_API_TOKEN" in os.environ:
    api_token = os.environ["CLOUDFLARE_API_TOKEN"]
else:
    api_token = getpass("Enter you Cloudflare API Token")
```

```python
if "CLOUDFLARE_ACCOUNT_ID" in os.environ:
    account_id = os.environ["CLOUDFLARE_ACCOUNT_ID"]
else:
    account_id = getpass("Enter your account id")
```

### Generate code from a comment

A common use case is to complete the code for the user after they provide a descriptive comment.

```python
model = "@hf/thebloke/deepseek-coder-6.7b-base-awq"

prompt = "# A function that checks if a given word is a palindrome"

response = requests.post(
    f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{model}",
    headers={"Authorization": f"Bearer {api_token}"},
    json={"messages": [
        {"role": "user", "content": prompt}
    ]}
)
inference = response.json()
code = inference["result"]["response"]

display(Markdown(f"""
    ```python
    {prompt}
    {code.strip()}
    ```
"""))
```

```python
# A function that checks if a given word is a palindrome
def is_palindrome(word):
    # Convert the word to lowercase
    word = word.lower()

    # Reverse the word
    reversed_word = word[::-1]

    # Check if the reversed word is the same as the original word
    if word == reversed_word:
        return True
    else:
        return False

# Test the function
print(is_palindrome("racecar"))  # Output: True
print(is_palindrome("hello"))    # Output: False
```

### Assist in debugging

We've all been there, bugs happen. Sometimes those stacktraces can be very intimidating, and a great use case of using Code Generation is to assist in explaining the problem.

```python
model = "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"

system_message = "The user is going to give you code that isn't working. Explain to the user what might be wrong"

code = """# Welcomes our user
def hello_world(first_name="World"):
    print(f"Hello, {name}!")
"""

response = requests.post(
    f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{model}",
    headers={"Authorization": f"Bearer {api_token}"},
    json={"messages": [
        {"role": "system", "content": system_message},
        {"role": "user", "content": code},
    ]}
)
inference = response.json()
response = inference["result"]["response"]
display(Markdown(response))
```

The error in your code is that you are trying to use a variable `name` which is not defined anywhere in your function. The correct variable to use is `first_name`. So, you should change `f"Hello, {name}!"` to `f"Hello, {first_name}!"`.

Here is the corrected code:

```python
# Welcomes our user
def hello_world(first_name="World"):
    print(f"Hello, {first_name}")
```

Now, when you call `hello_world()`, it will print "Hello, World" by default. If you call `hello_world("John")`, it will print "Hello, John".

### Write tests!

Writing unit tests is a common best practice. With the enough context, it's possible to write unit tests.

```python
model = "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"

system_message = "The user is going to give you code and would like to have tests written in the Python unittest module."

code = """
class User:

    def __init__(self, first_name, last_name=None):
        self.first_name = first_name
        self.last_name = last_name
        if last_name is None:
            self.last_name = "Mc" + self.first_name

    def full_name(self):
        return self.first_name + " " + self.last_name
"""

response = requests.post(
    f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{model}",
    headers={"Authorization": f"Bearer {api_token}"},
    json={"messages": [
        {"role": "system", "content": system_message},
        {"role": "user", "content": code},
    ]}
)
inference = response.json()
response = inference["result"]["response"]
display(Markdown(response))
```

Here is a simple unittest test case for the User class:

```python
import unittest

class TestUser(unittest.TestCase):

    def test_full_name(self):
        user = User("John", "Doe")
        self.assertEqual(user.full_name(), "John Doe")

    def test_default_last_name(self):
        user = User("Jane")
        self.assertEqual(user.full_name(), "Jane McJane")

if __name__ == '__main__':
    unittest.main()
```

In this test case, we have two tests:

- `test_full_name` tests the `full_name` method when the user has both a first name and a last name.
- `test_default_last_name` tests the `full_name` method when the user only has a first name and the last name is set to "Mc" + first name.

If all these tests pass, it means that the `full_name` method is working as expected. If any of these tests fail, it

### Fill-in-the-middle Code Completion

A common use case in Developer Tools is to autocomplete based on context. DeepSeek Coder provides the ability to submit existing code with a placeholder, so that the model can complete in context.

Warning: The tokens are prefixed with `<｜` and suffixed with `｜>` make sure to copy and paste them.

```python
model = "@hf/thebloke/deepseek-coder-6.7b-base-awq"

code = """
<｜fim▁begin｜>import re

from jklol import email_service

def send_email(email_address, body):
    <｜fim▁hole｜>
    if not is_valid_email:
        raise InvalidEmailAddress(email_address)
    return email_service.send(email_address, body)<｜fim▁end｜>
"""

response = requests.post(
    f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{model}",
    headers={"Authorization": f"Bearer {api_token}"},
    json={"messages": [
        {"role": "user", "content": code}
    ]}
)
inference = response.json()
response = inference["result"]["response"]
display(Markdown(f"""
    ```python
    {response.strip()}
    ```
"""))
```

```python
is_valid_email = re.match(r"[^@]+@[^@]+\.[^@]+", email_address)
```

### Experimental: Extract data into JSON

No need to threaten the model or bring grandma into the prompt. Get back JSON in the format you want.

```python
model = "@hf/thebloke/deepseek-coder-6.7b-instruct-awq"

# Learn more at https://json-schema.org/
json_schema = """
{
  "title": "User",
  "description": "A user from our example app",
  "type": "object",
  "properties": {
    "firstName": {
      "description": "The user's first name",
      "type": "string"
    },
    "lastName": {
      "description": "The user's last name",
      "type": "string"
    },
    "numKids": {
      "description": "Amount of children the user has currently",
      "type": "integer"
    },
    "interests": {
      "description": "A list of what the user has shown interest in",
      "type": "array",
      "items": {
        "type": "string"
      }
    },
  },
  "required": [ "firstName" ]
}
"""

system_prompt = f"""
The user is going to discuss themselves and you should create a JSON object from their description to match the json schema below.

<BEGIN JSON SCHEMA>
{json_schema}
<END JSON SCHEMA>

Return JSON only. Do not explain or provide usage examples.
"""

prompt = """Hey there, I'm Craig Dennis and I'm a Developer Educator at Cloudflare. My email is craig@cloudflare.com.
            I am very interested in AI. I've got two kids. I love tacos, burritos, and all things Cloudflare"""

response = requests.post(
    f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{model}",
    headers={"Authorization": f"Bearer {api_token}"},
    json={"messages": [
        {"role": "system", "content": system_prompt},
        {"role": "user", "content": prompt}
    ]}
)
inference = response.json()
response = inference["result"]["response"]
display(Markdown(f"""
    ```json
    {response.strip()}
    ```
"""))
```

```json
{
  "firstName": "Craig",
  "lastName": "Dennis",
  "numKids": 2,
  "interests": ["AI", "Cloudflare", "Tacos", "Burritos"]
}
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-code-generation-using-deepseek-coder-models/#page","headline":"Explore Code Generation Using DeepSeek Coder Models","description":"Explore how you can use AI models to generate code and work more efficiently.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-code-generation-using-deepseek-coder-models/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-code-generation-using-deepseek-coder-models/og.png?v=63e789d0c94c8113","dateModified":"2026-04-30","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI","Python"]}
```

---

---
description: This Jupyter notebook explores various models (including Whisper, Distilled BERT, LLaVA, and Meta Llama 3) using Python and the requests library.
title: Explore Workers AI Models Using a Jupyter Notebook
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-workers-ai-models-using-a-jupyter-notebook/og.png?v=9be072d4de402fb3
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Explore Workers AI Models Using a Jupyter Notebook

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-workers-ai-models-using-a-jupyter-notebook/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

A handy way to explore all of the models available on [Workers AI](https://developers.cloudflare.com/workers-ai) is to use a [Jupyter Notebook ↗︎](https://jupyter.org/).

You can [download the Workers AI notebook](https://developers.cloudflare.com/workers-ai-notebooks/cloudflare-workers-ai.ipynb) or view the embedded notebook below.

Or you can run this on [Google Colab ↗︎](https://colab.research.google.com/github/craigsdennis/notebooks-cloudflare-workers-ai/blob/main/cloudflare-workers-ai.ipynb)

---

## Explore the Workers AI API using Python

[Workers AI](https://developers.cloudflare.com/workers-ai) allows you to run machine learning models, on the Cloudflare network, from your own code – whether that be from Workers, Pages, or anywhere via REST API.

This notebook will explore the Workers AI REST API using the [official Python SDK ↗︎](https://github.com/cloudflare/cloudflare-python).

```python
import os
from getpass import getpass

from cloudflare import Cloudflare
from IPython.display import display, Image, Markdown, Audio
import requests
```

```python
%load_ext dotenv
%dotenv
```

### Configuring your environment

To use the API you'll need your [Cloudflare Account ID ↗︎](https://dash.cloudflare.com). Head to AI > Workers AI page and press the "Use REST API". This page will let you create a new API Token and copy your Account ID.

If you want to add these values to your environment variables, you can **create a new file** named `.env` and this notebook will read those values.

```bash
CLOUDFLARE_API_TOKEN="YOUR-TOKEN"
CLOUDFLARE_ACCOUNT_ID="YOUR-ACCOUNT-ID"
```

Otherwise you can just enter the values securely when prompted below.

```python
if "CLOUDFLARE_API_TOKEN" in os.environ:
    api_token = os.environ["CLOUDFLARE_API_TOKEN"]
else:
    api_token = getpass("Enter your Cloudflare API Token")
```

```python
if "CLOUDFLARE_ACCOUNT_ID" in os.environ:
    account_id = os.environ["CLOUDFLARE_ACCOUNT_ID"]
else:
    account_id = getpass("Enter your account id")
```

```python
# Initialize client
client = Cloudflare(api_token=api_token)
```

## Explore tasks available on the Workers AI Platform

### Text Generation

Explore all [Text Generation Models](https://developers.cloudflare.com/workers-ai/models)

```python
result = client.workers.ai.run(
    "@cf/meta/llama-3-8b-instruct" ,
    account_id=account_id,
    messages=[
        {"role": "system", "content": """
            You are a productivity assistant for users of Jupyter notebooks for both Mac and Windows users.

            Respond in Markdown."""
        },
        {"role": "user", "content": "How do I use keyboard shortcuts to execute cells?"}
    ]
)

display(Markdown(result["response"]))
```

# **Using Keyboard Shortcuts to Execute Cells in Jupyter Notebooks**

Executing cells in Jupyter Notebooks can be done quickly and efficiently using various keyboard shortcuts, saving you time and effort. Here are the shortcuts you can use:

**Mac**

- **Shift + Enter**: Execute the current cell and insert a new cell below.
- **Ctrl + Enter**: Execute the current cell and insert a new cell below, without creating a new output display.

**Windows/Linux**

- **Shift + Enter**: Execute the current cell and insert a new cell below.
- **Ctrl + Enter**: Execute the current cell and move to the next cell.

**Additional Shortcuts**

- **Alt + Enter**: Execute the current cell and create a new output display below (Mac), or move to the next cell (Windows/Linux).
- **Ctrl + Shift + Enter**: Execute the current cell and create a new output display below (Mac), or create a new cell below (Windows/Linux).

**Tips and Tricks**

- You can also use the **Run Cell** button in the Jupyter Notebook toolbar, or the **Run** menu option (macOS) or **Run -> Run Cell** (Windows/Linux).
- To execute a selection of cells, use **Shift + Alt + Enter** (Mac) or **Shift + Ctrl + Enter** (Windows/Linux).
- To execute a cell and move to the next cell, use **Ctrl + Shift + Enter** (all platforms).

By using these keyboard shortcuts, you'll be able to work more efficiently and quickly in your Jupyter Notebooks. Happy coding!

### Text to Image

Explore all [Text to Image models](https://developers.cloudflare.com/workers-ai/models)

```python
data = client.workers.ai.with_raw_response.run(
    "@cf/lykon/dreamshaper-8-lcm",
    account_id=account_id,
    prompt="A software developer incredibly excited about AI, huge smile",
)

display(Image(data.read()))
```

![png](https://developers.cloudflare.com/workers-ai-notebooks/cloudflare-workers-ai/assets/output_13_0.png)

### Image to Text

Explore all [Image to Text](https://developers.cloudflare.com/workers-ai/models/) models

```python
url = "https://blog.cloudflare.com/content/images/2017/11/lava-lamps.jpg"

image_request = requests.get(url, allow_redirects=True)

display(Image(image_request.content, format="jpg"))

data = client.workers.ai.run(
    "@cf/llava-hf/llava-1.5-7b-hf",
    account_id=account_id,
    image=image_request.content,
    prompt="Describe this photo",
    max_tokens=2048
)

print(data["description"])
```

![lava lamps](https://blog.cloudflare.com/content/images/2017/11/lava-lamps.jpg)

The image features a display of various colored lava lamps. There are at least 14 lava lamps in the scene, each with a different color and design. The lamps are arranged in a visually appealing manner, with some placed closer to the foreground and others further back. The display creates an eye-catching and vibrant atmosphere, showcasing the diverse range of lava lamps available.

### Automatic Speech Recognition

Explore all [Speech Recognition models](https://developers.cloudflare.com/workers-ai/models)

```python
url = "https://raw.githubusercontent.com/craigsdennis/notebooks-cloudflare-workers-ai/main/assets/craig-rambling.mp3"
display(Audio(url))
audio = requests.get(url)

response = client.workers.ai.run(
    "@cf/openai/whisper",
    account_id=account_id,
    audio=audio.content
)

response
```

Your browser does not support the audio element.

```javascript
    {'text': "Hello there, I'm making a recording for a Jupiter notebook. That's a Python notebook, Jupiter, J-U-P-Y-T-E-R. Not to be confused with the planet. Anyways, let me hear, I'm gonna talk a little bit, I'm gonna make a little bit of noise, say some hard words, I'm gonna say Kubernetes, I'm not actually even talking about Kubernetes, I just wanna see if I can do Kubernetes. Anyway, this is a test of transcription and let's see how we're dead.",
     'word_count': 84,
     'vtt': "WEBVTT\n\n00.280 --> 01.840\nHello there, I'm making a\n\n01.840 --> 04.060\nrecording for a Jupiter notebook.\n\n04.060 --> 06.440\nThat's a Python notebook, Jupiter,\n\n06.440 --> 07.720\nJ -U -P -Y -T\n\n07.720 --> 09.420\n-E -R. Not to be\n\n09.420 --> 12.140\nconfused with the planet. Anyways,\n\n12.140 --> 12.940\nlet me hear, I'm gonna\n\n12.940 --> 13.660\ntalk a little bit, I'm\n\n13.660 --> 14.600\ngonna make a little bit\n\n14.600 --> 16.180\nof noise, say some hard\n\n16.180 --> 17.540\nwords, I'm gonna say Kubernetes,\n\n17.540 --> 18.420\nI'm not actually even talking\n\n18.420 --> 19.500\nabout Kubernetes, I just wanna\n\n19.500 --> 20.300\nsee if I can do\n\n20.300 --> 22.120\nKubernetes. Anyway, this is a\n\n22.120 --> 24.080\ntest of transcription and let's\n\n24.080 --> 26.280\nsee how we're dead.",
     'words': [{'word': 'Hello',
       'start': 0.2800000011920929,
       'end': 0.7400000095367432},
      {'word': 'there,', 'start': 0.7400000095367432, 'end': 1.2400000095367432},
      {'word': "I'm", 'start': 1.2400000095367432, 'end': 1.4800000190734863},
      {'word': 'making', 'start': 1.4800000190734863, 'end': 1.6799999475479126},
      {'word': 'a', 'start': 1.6799999475479126, 'end': 1.840000033378601},
      {'word': 'recording', 'start': 1.840000033378601, 'end': 2.2799999713897705},
      {'word': 'for', 'start': 2.2799999713897705, 'end': 2.6600000858306885},
      {'word': 'a', 'start': 2.6600000858306885, 'end': 2.799999952316284},
      {'word': 'Jupiter', 'start': 2.799999952316284, 'end': 3.2200000286102295},
      {'word': 'notebook.', 'start': 3.2200000286102295, 'end': 4.059999942779541},
      {'word': "That's", 'start': 4.059999942779541, 'end': 4.28000020980835},
      {'word': 'a', 'start': 4.28000020980835, 'end': 4.380000114440918},
      {'word': 'Python', 'start': 4.380000114440918, 'end': 4.679999828338623},
      {'word': 'notebook,', 'start': 4.679999828338623, 'end': 5.460000038146973},
      {'word': 'Jupiter,', 'start': 5.460000038146973, 'end': 6.440000057220459},
      {'word': 'J', 'start': 6.440000057220459, 'end': 6.579999923706055},
      {'word': '-U', 'start': 6.579999923706055, 'end': 6.920000076293945},
      {'word': '-P', 'start': 6.920000076293945, 'end': 7.139999866485596},
      {'word': '-Y', 'start': 7.139999866485596, 'end': 7.440000057220459},
      {'word': '-T', 'start': 7.440000057220459, 'end': 7.71999979019165},
      {'word': '-E', 'start': 7.71999979019165, 'end': 7.920000076293945},
      {'word': '-R.', 'start': 7.920000076293945, 'end': 8.539999961853027},
      {'word': 'Not', 'start': 8.539999961853027, 'end': 8.880000114440918},
      {'word': 'to', 'start': 8.880000114440918, 'end': 9.300000190734863},
      {'word': 'be', 'start': 9.300000190734863, 'end': 9.420000076293945},
      {'word': 'confused', 'start': 9.420000076293945, 'end': 9.739999771118164},
      {'word': 'with', 'start': 9.739999771118164, 'end': 9.9399995803833},
      {'word': 'the', 'start': 9.9399995803833, 'end': 10.039999961853027},
      {'word': 'planet.', 'start': 10.039999961853027, 'end': 11.380000114440918},
      {'word': 'Anyways,', 'start': 11.380000114440918, 'end': 12.140000343322754},
      {'word': 'let', 'start': 12.140000343322754, 'end': 12.420000076293945},
      {'word': 'me', 'start': 12.420000076293945, 'end': 12.520000457763672},
      {'word': 'hear,', 'start': 12.520000457763672, 'end': 12.800000190734863},
      {'word': "I'm", 'start': 12.800000190734863, 'end': 12.880000114440918},
      {'word': 'gonna', 'start': 12.880000114440918, 'end': 12.9399995803833},
      {'word': 'talk', 'start': 12.9399995803833, 'end': 13.100000381469727},
      {'word': 'a', 'start': 13.100000381469727, 'end': 13.260000228881836},
      {'word': 'little', 'start': 13.260000228881836, 'end': 13.380000114440918},
      {'word': 'bit,', 'start': 13.380000114440918, 'end': 13.5600004196167},
      {'word': "I'm", 'start': 13.5600004196167, 'end': 13.65999984741211},
      {'word': 'gonna', 'start': 13.65999984741211, 'end': 13.739999771118164},
      {'word': 'make', 'start': 13.739999771118164, 'end': 13.920000076293945},
      {'word': 'a', 'start': 13.920000076293945, 'end': 14.199999809265137},
      {'word': 'little', 'start': 14.199999809265137, 'end': 14.4399995803833},
      {'word': 'bit', 'start': 14.4399995803833, 'end': 14.600000381469727},
      {'word': 'of', 'start': 14.600000381469727, 'end': 14.699999809265137},
      {'word': 'noise,', 'start': 14.699999809265137, 'end': 15.460000038146973},
      {'word': 'say', 'start': 15.460000038146973, 'end': 15.859999656677246},
      {'word': 'some', 'start': 15.859999656677246, 'end': 16},
      {'word': 'hard', 'start': 16, 'end': 16.18000030517578},
      {'word': 'words,', 'start': 16.18000030517578, 'end': 16.540000915527344},
      {'word': "I'm", 'start': 16.540000915527344, 'end': 16.639999389648438},
      {'word': 'gonna', 'start': 16.639999389648438, 'end': 16.719999313354492},
      {'word': 'say', 'start': 16.719999313354492, 'end': 16.920000076293945},
      {'word': 'Kubernetes,',
       'start': 16.920000076293945,
       'end': 17.540000915527344},
      {'word': "I'm", 'start': 17.540000915527344, 'end': 17.65999984741211},
      {'word': 'not', 'start': 17.65999984741211, 'end': 17.719999313354492},
      {'word': 'actually', 'start': 17.719999313354492, 'end': 18},
      {'word': 'even', 'start': 18, 'end': 18.18000030517578},
      {'word': 'talking', 'start': 18.18000030517578, 'end': 18.420000076293945},
      {'word': 'about', 'start': 18.420000076293945, 'end': 18.6200008392334},
      {'word': 'Kubernetes,', 'start': 18.6200008392334, 'end': 19.1200008392334},
      {'word': 'I', 'start': 19.1200008392334, 'end': 19.239999771118164},
      {'word': 'just', 'start': 19.239999771118164, 'end': 19.360000610351562},
      {'word': 'wanna', 'start': 19.360000610351562, 'end': 19.5},
      {'word': 'see', 'start': 19.5, 'end': 19.719999313354492},
      {'word': 'if', 'start': 19.719999313354492, 'end': 19.8799991607666},
      {'word': 'I', 'start': 19.8799991607666, 'end': 19.940000534057617},
      {'word': 'can', 'start': 19.940000534057617, 'end': 20.079999923706055},
      {'word': 'do', 'start': 20.079999923706055, 'end': 20.299999237060547},
      {'word': 'Kubernetes.',
       'start': 20.299999237060547,
       'end': 21.440000534057617},
      {'word': 'Anyway,', 'start': 21.440000534057617, 'end': 21.799999237060547},
      {'word': 'this', 'start': 21.799999237060547, 'end': 21.920000076293945},
      {'word': 'is', 'start': 21.920000076293945, 'end': 22.020000457763672},
      {'word': 'a', 'start': 22.020000457763672, 'end': 22.1200008392334},
      {'word': 'test', 'start': 22.1200008392334, 'end': 22.299999237060547},
      {'word': 'of', 'start': 22.299999237060547, 'end': 22.639999389648438},
      {'word': 'transcription',
       'start': 22.639999389648438,
       'end': 23.139999389648438},
      {'word': 'and', 'start': 23.139999389648438, 'end': 23.6200008392334},
      {'word': "let's", 'start': 23.6200008392334, 'end': 24.079999923706055},
      {'word': 'see', 'start': 24.079999923706055, 'end': 24.299999237060547},
      {'word': 'how', 'start': 24.299999237060547, 'end': 24.559999465942383},
      {'word': "we're", 'start': 24.559999465942383, 'end': 24.799999237060547},
      {'word': 'dead.', 'start': 24.799999237060547, 'end': 26.280000686645508}]}
```

### Translations

Explore all [Translation models](https://developers.cloudflare.com/workers-ai/models)

```python
result = client.workers.ai.run(
    "@cf/meta/m2m100-1.2b",
    account_id=account_id,
    text="Artificial intelligence is pretty impressive these days. It is a bonkers time to be a builder",
    source_lang="english",
    target_lang="spanish"
)


print(result["translated_text"])
```

La inteligencia artificial es bastante impresionante en estos días.Es un buen momento para ser un constructor

### Text Classification

Explore all [Text Classification models](https://developers.cloudflare.com/workers-ai/models)

```python
result = client.workers.ai.run(
    "@cf/huggingface/distilbert-sst-2-int8",
    account_id=account_id,
    text="This taco is delicious"
)

result
```

\[TextClassification(label='NEGATIVE', score=0.00012679687642958015), TextClassification(label='POSITIVE', score=0.999873161315918)]

### Image Classification

Explore all [Image Classification models](https://developers.cloudflare.com/ai/models/#image-classification)

```python
url = "https://raw.githubusercontent.com/craigsdennis/notebooks-cloudflare-workers-ai/main/assets/craig-and-a-burrito.jpg"
image_request = requests.get(url, allow_redirects=True)

display(Image(image_request.content, format="jpg"))
response = client.workers.ai.run(
    "@cf/microsoft/resnet-50",
    account_id=account_id,
    image=image_request.content
)
response
```

![jpeg](https://developers.cloudflare.com/workers-ai-notebooks/cloudflare-workers-ai/assets/output_27_0.jpg)

\[TextClassification(label='BURRITO', score=0.9999679327011108), TextClassification(label='GUACAMOLE', score=8.516660273016896e-06), TextClassification(label='BAGEL', score=4.689153229264775e-06), TextClassification(label='SPATULA', score=4.075985089002643e-06), TextClassification(label='POTPIE', score=3.0849002996546915e-06)]

## Summarization

Explore all [Summarization](https://developers.cloudflare.com/ai/models/#summarization) based models

```python
declaration_of_independence = """In Congress, July 4, 1776. The unanimous Declaration of the thirteen united States of America, When in the Course of human events, it becomes necessary for one people to dissolve the political bands which have connected them with another, and to assume among the powers of the earth, the separate and equal station to which the Laws of Nature and of Nature's God entitle them, a decent respect to the opinions of mankind requires that they should declare the causes which impel them to the separation. We hold these truths to be self-evident, that all men are created equal, that they are endowed by their Creator with certain unalienable Rights, that among these are Life, Liberty and the pursuit of Happiness.--That to secure these rights, Governments are instituted among Men, deriving their just powers from the consent of the governed, --That whenever any Form of Government becomes destructive of these ends, it is the Right of the People to alter or to abolish it, and to institute new Government, laying its foundation on such principles and organizing its powers in such form, as to them shall seem most likely to effect their Safety and Happiness. Prudence, indeed, will dictate that Governments long established should not be changed for light and transient causes; and accordingly all experience hath shewn, that mankind are more disposed to suffer, while evils are sufferable, than to right themselves by abolishing the forms to which they are accustomed. But when a long train of abuses and usurpations, pursuing invariably the same Object evinces a design to reduce them under absolute Despotism, it is their right, it is their duty, to throw off such Government, and to provide new Guards for their future security.--Such has been the patient sufferance of these Colonies; and such is now the necessity which constrains them to alter their former Systems of Government. The history of the present King of Great Britain is a history of repeated injuries and usurpations, all having in direct object the establishment of an absolute Tyranny over these States. To prove this, let Facts be submitted to a candid world. He has refused his Assent to Laws, the most wholesome and necessary for the public good. He has forbidden his Governors to pass Laws of immediate and pressing importance, unless suspended in their operation till his Assent should be obtained; and when so suspended, he has utterly neglected to attend to them. He has refused to pass other Laws for the accommodation of large districts of people, unless those people would relinquish the right of Representation in the Legislature, a right inestimable to them and formidable to tyrants only. He has called together legislative bodies at places unusual, uncomfortable, and distant from the depository of their public Records, for the sole purpose of fatiguing them into compliance with his measures. He has dissolved Representative Houses repeatedly, for opposing with manly firmness his invasions on the rights of the people. He has refused for a long time, after such dissolutions, to cause others to be elected; whereby the Legislative powers, incapable of Annihilation, have returned to the People at large for their exercise; the State remaining in the mean time exposed to all the dangers of invasion from without, and convulsions within. He has endeavoured to prevent the population of these States; for that purpose obstructing the Laws for Naturalization of Foreigners; refusing to pass others to encourage their migrations hither, and raising the conditions of new Appropriations of Lands. He has obstructed the Administration of Justice, by refusing his Assent to Laws for establishing Judiciary powers. He has made Judges dependent on his Will alone, for the tenure of their offices, and the amount and payment of their salaries. He has erected a multitude of New Offices, and sent hither swarms of Officers to harrass our people, and eat out their substance. He has kept among us, in times of peace, Standing Armies without the Consent of our legislatures. He has affected to render the Military independent of and superior to the Civil power. He has combined with others to subject us to a jurisdiction foreign to our constitution, and unacknowledged by our laws; giving his Assent to their Acts of pretended Legislation: For Quartering large bodies of armed troops among us: For protecting them, by a mock Trial, from punishment for any Murders which they should commit on the Inhabitants of these States: For cutting off our Trade with all parts of the world: For imposing Taxes on us without our Consent: For depriving us in many cases, of the benefits of Trial by Jury: For transporting us beyond Seas to be tried for pretended offences For abolishing the free System of English Laws in a neighbouring Province, establishing therein an Arbitrary government, and enlarging its Boundaries so as to render it at once an example and fit instrument for introducing the same absolute rule into these Colonies: For taking away our Charters, abolishing our most valuable Laws, and altering fundamentally the Forms of our Governments: For suspending our own Legislatures, and declaring themselves invested with power to legislate for us in all cases whatsoever. He has abdicated Government here, by declaring us out of his Protection and waging War against us. He has plundered our seas, ravaged our Coasts, burnt our towns, and destroyed the lives of our people. He is at this time transporting large Armies of foreign Mercenaries to compleat the works of death, desolation and tyranny, already begun with circumstances of Cruelty & perfidy scarcely paralleled in the most barbarous ages, and totally unworthy the Head of a civilized nation. He has constrained our fellow Citizens taken Captive on the high Seas to bear Arms against their Country, to become the executioners of their friends and Brethren, or to fall themselves by their Hands. He has excited domestic insurrections amongst us, and has endeavoured to bring on the inhabitants of our frontiers, the merciless Indian Savages, whose known rule of warfare, is an undistinguished destruction of all ages, sexes and conditions. In every stage of these Oppressions We have Petitioned for Redress in the most humble terms: Our repeated Petitions have been answered only by repeated injury. A Prince whose character is thus marked by every act which may define a Tyrant, is unfit to be the ruler of a free people. Nor have We been wanting in attentions to our Brittish brethren. We have warned them from time to time of attempts by their legislature to extend an unwarrantable jurisdiction over us. We have reminded them of the circumstances of our emigration and settlement here. We have appealed to their native justice and magnanimity, and we have conjured them by the ties of our common kindred to disavow these usurpations, which, would inevitably interrupt our connections and correspondence. They too have been deaf to the voice of justice and of consanguinity. We must, therefore, acquiesce in the necessity, which denounces our Separation, and hold them, as we hold the rest of mankind, Enemies in War, in Peace Friends. We, therefore, the Representatives of the united States of America, in General Congress, Assembled, appealing to the Supreme Judge of the world for the rectitude of our intentions, do, in the Name, and by Authority of the good People of these Colonies, solemnly publish and declare, That these United Colonies are, and of Right ought to be Free and Independent States; that they are Absolved from all Allegiance to the British Crown, and that all political connection between them and the State of Great Britain, is and ought to be totally dissolved; and that as Free and Independent States, they have full Power to levy War, conclude Peace, contract Alliances, establish Commerce, and to do all other Acts and Things which Independent States may of right do. And for the support of this Declaration, with a firm reliance on the protection of divine Providence, we mutually pledge to each other our Lives, our Fortunes and our sacred Honor."""
len(declaration_of_independence)
```

8116

```python
response = client.workers.ai.run(
    "@cf/facebook/bart-large-cnn",
    account_id=account_id,
    input_text=declaration_of_independence
)

response["summary"]
```

'The Declaration of Independence was signed by the thirteen states on July 4, 1776. It was the first attempt at a U.S. Constitution. It declared the right of the people to change their Government.'

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-workers-ai-models-using-a-jupyter-notebook/#page","headline":"Explore Workers AI Models Using a Jupyter Notebook","description":"This Jupyter notebook explores various models (including Whisper, Distilled BERT, LLaVA, and Meta Llama 3) using Python and the requests library.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-workers-ai-models-using-a-jupyter-notebook/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/explore-workers-ai-models-using-a-jupyter-notebook/og.png?v=9be072d4de402fb3","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI","Python"]}
```

---

---
description: Fine-tuning AI models with LoRA adapters on Workers AI allows adding custom training data, like for LLM finetuning.
title: Fine Tune Models With AutoTrain from HuggingFace
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/fine-tune-models-with-autotrain/og.png?v=b0b15ca1c67a6587
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Fine Tune Models With AutoTrain from HuggingFace

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/fine-tune-models-with-autotrain/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Fine tuning an AI model gives you the opportunity to add additional training data to the model. Workers AI allows for [Low-Rank Adaptation, LoRA, adapters](https://developers.cloudflare.com/workers-ai/features/fine-tunes/loras/) that will allow you to finetune our models.

In this tutorial, we will explore how to create our own LoRAs. We will focus on [LLM Finetuning using AutoTrain ↗︎](https://huggingface.co/docs/autotrain/llm_finetuning).

## 1. Create a CSV file with your training data

Start by creating a CSV, Comma Separated Values, file. This file will only have one column named `text`. Set the header by adding the word `text` on a line by itself.

Now you need to figure out what you want to add to your model.

Example formats are below:

```text
### Human: What is the meaning of life? ### Assistant: 42.
```

If your training row contains newlines, you should wrap it with quotes.

```text
"human: What is the meaning of life? \n bot: 42."
```

Different models, like Mistral, will provide a specific [chat template/instruction format ↗︎](https://huggingface.co/mistralai/Mistral-7B-Instruct-v0.1#instruction-format)

```text
<s>[INST] What is the meaning of life? [/INST] 42</s>
```

## 2. Configure the HuggingFace Autotrain Advanced Notebook

Open the [HuggingFace Autotrain Advanced Notebook ↗︎](https://colab.research.google.com/github/huggingface/autotrain-advanced/blob/main/colabs/AutoTrain_LLM.ipynb)

In order to give your AutoTrain ample memory, you will need to need to choose a different Runtime. From the menu at the top of the Notebook choose Runtime > Change Runtime Type. Choose A100.

Note

These GPUs will cost money. A typical AutoTrain session typically costs less than $1 USD.

The notebook contains a few interactive sections that we will need to change.

### Project Config

Modify the following fields

- **project\_name**: Choose a descriptive name for you to remember later
- **model\_name**: Choose from the one of the official HuggingFace base models that we support:
  - `mistralai/Mistral-7B-Instruct-v0.2`
  - `google/gemma-2b-it`
  - `google/gemma-7b-it`
  - `meta-llama/llama-2-7b-chat-hf`

### Optional Section: Push to Hub

Although not required to use AutoTrain, creating a [HuggingFace account ↗︎](https://huggingface.co/join) will help you keep your finetune artifacts in a handy repository for you to refer to later.

If you do not perform the HuggingFace setup you can still download your files from the Notebook.

Follow the instructions [in the notebook ↗︎](https://colab.research.google.com/github/huggingface/autotrain-advanced/blob/main/colabs/AutoTrain_LLM.ipynb) to create an account and token if necessary.

### Section: Hyperparameters

We only need to change a few of these fields to ensure things work on Cloudflare Workers AI.

- **quantization**: Change the drop down to `none`
- **lora-r**: Change the value to `8`

Caution

At the time of this writing, changing the quantization field breaks the code generation. You may need to edit the code and put quotes around the value.

Change the line that says `quantization = none` to `quantization = "none"`.

## 3. Upload your CSV file to the Notebook

Notebooks have a folder structure which you can access by clicking the folder icon on the left hand navigation bar.

Create a folder named data.

You can drag your CSV file into the notebook.

Ensure that it is named **train.csv**

## 4. Execute the Notebook

In the Notebook menu, choose Runtime > Run All.

It will run through each cell of the notebook, first doing installations, then configuring and running your AutoTrain session.

This might take some time depending on the size of your train.csv file.

If you encounter the following error, it is caused by an Out of Memory error. You might want to change your runtime to a bigger GPU backend.

```bash
subprocess.CalledProcessError: Command '['/usr/bin/python3', '-m', 'autotrain.trainers.clm', '--training_config', 'blog-instruct/training_params.json']' died with <Signals.SIGKILL: 9>.
```

## 5. Download The LoRA

### Optional: HuggingFace

If you pushed to HuggingFace you will find your new model card that you named in **project\_name** above. Your model card is private by default. Navigate to the files and download the files listed below.

### Notebook

In your Notebook you can also find the needed files. A new folder that matches your **project\_name** will be there.

Download the following files:

- `adapter_model.safetensors`
- `adapter_config.json`

## 6. Update Adapter Config

You need to add one line to your `adapter_config.json` that you downloaded.

`"model_type": "mistral"`

Where `model_type` is the architecture. Current valid values are `mistral`, `gemma`, and `llama`.

## 7. Upload the Fine Tune to your Cloudflare Account

Now that you have your files, you can add them to your account.

You can either use the [REST API or Wrangler](https://developers.cloudflare.com/workers-ai/features/fine-tunes/loras/).

## 8. Use your Fine Tune in your Generations

After you have your new fine tune all set up, you are ready to [put it to use in your inference requests](https://developers.cloudflare.com/workers-ai/features/fine-tunes/loras/#running-inference-with-loras).

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/fine-tune-models-with-autotrain/#page","headline":"Fine Tune Models With AutoTrain from HuggingFace","description":"Fine-tuning AI models with LoRA adapters on Workers AI allows adding custom training data, like for LLM finetuning.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/fine-tune-models-with-autotrain/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/fine-tune-models-with-autotrain/og.png?v=b0b15ca1c67a6587","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI","LLM"]}
```

---

---
description: There's a wide range of text generation models available through Workers AI. In an effort to aid you in your journey of finding the right model, this notebook will help you get to know your options in a speed dating type of scenario.
title: Choose the Right Text Generation Model
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/how-to-choose-the-right-text-generation-model/og.png?v=6b398480befd8b0e
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Choose the Right Text Generation Model

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/how-to-choose-the-right-text-generation-model/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

A great way to explore the models that are available to you on [Workers AI](https://developers.cloudflare.com/workers-ai) is to use a [Jupyter Notebook ↗︎](https://jupyter.org/).

You can [download the Workers AI Text Generation Exploration notebook](https://developers.cloudflare.com/workers-ai/static/documentation/notebooks/text-generation-model-exploration.ipynb) or view the embedded notebook below.

---

## How to Choose The Right Text Generation Model

Models come in different shapes and sizes, and choosing the right one for the task, can cause analysis paralysis.

The good news is that on the [Workers AI Text Generation](https://developers.cloudflare.com/workers-ai/models/) interface is always the same, no matter which model you choose.

In an effort to aid you in your journey of finding the right model, this notebook will help you get to know your options in a speed dating type of scenario.

```python
import sys
!{sys.executable} -m pip install requests python-dotenv
```

```plaintext
Requirement already satisfied: requests in ./venv/lib/python3.12/site-packages (2.31.0)
Requirement already satisfied: python-dotenv in ./venv/lib/python3.12/site-packages (1.0.1)
Requirement already satisfied: charset-normalizer<4,>=2 in ./venv/lib/python3.12/site-packages (from requests) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in ./venv/lib/python3.12/site-packages (from requests) (3.6)
Requirement already satisfied: urllib3<3,>=1.21.1 in ./venv/lib/python3.12/site-packages (from requests) (2.1.0)
Requirement already satisfied: certifi>=2017.4.17 in ./venv/lib/python3.12/site-packages (from requests) (2023.11.17)
```

```python
import os
from getpass import getpass
from timeit import default_timer as timer

from IPython.display import display, Image, Markdown, Audio

import requests
```

```python
%load_ext dotenv
%dotenv
```

### Configuring your environment

To use the API you'll need your [Cloudflare Account ID ↗︎](https://dash.cloudflare.com) (head to Workers & Pages > Overview > Account details > Account ID) and a [Workers AI enabled API Token ↗︎](https://dash.cloudflare.com/profile/api-tokens).

If you want to add these files to your environment, you can create a new file named `.env`

```bash
CLOUDFLARE_API_TOKEN="YOUR-TOKEN"
CLOUDFLARE_ACCOUNT_ID="YOUR-ACCOUNT-ID"
```

```python
if "CLOUDFLARE_API_TOKEN" in os.environ:
    api_token = os.environ["CLOUDFLARE_API_TOKEN"]
else:
    api_token = getpass("Enter your Cloudflare API Token")
```

```python
if "CLOUDFLARE_ACCOUNT_ID" in os.environ:
    account_id = os.environ["CLOUDFLARE_ACCOUNT_ID"]
else:
    account_id = getpass("Enter your account id")
```

```python
# Given a set of models and questions, display in the cell each response to the question, from each model
# Include full completion timing
def speed_date(models, questions):
    for model in models:
        display(Markdown(f"---\n #### {model}"))
        for question in questions:
            quoted_question = "\n".join(f"> {line}" for line in question.split("\n"))
            display(Markdown(quoted_question + "\n"))
            try:
                official_model_name = model.split("/")[-1]
                start = timer()
                response = requests.post(
                    f"https://api.cloudflare.com/client/v4/accounts/{account_id}/ai/run/{model}",
                    headers={"Authorization": f"Bearer {api_token}"},
                    json={"messages": [
                        {"role": "system", "content": f"You are a self-aware language model ({official_model_name}) who is honest and direct about any direct question from the user. You know your strengths and weaknesses."},
                        {"role": "user", "content": question}
                    ]}
                )
                elapsed = timer() - start
                inference = response.json()
                display(Markdown(inference["result"]["response"]))
                display(Markdown(f"_Generated in *{elapsed:.2f}* seconds_"))
            except Exception as ex:
                print("uh oh")
                print(ex)
                print(inference)

        display(Markdown("\n\n---"))
```

### Getting to know your models

Who better to tell you about the specific models than themselves?!

The timing here is specific to the entire completion, but remember all Text Generation models on [Workers AI support streaming](https://developers.cloudflare.com/workers-ai/models/).

```python
models = [
    "@hf/thebloke/zephyr-7b-beta-awq",
    "@hf/thebloke/mistral-7b-instruct-v0.1-awq",
    "@hf/thebloke/openhermes-2.5-mistral-7b-awq",
    "@hf/thebloke/neural-chat-7b-v3-1-awq",
    "@hf/thebloke/llama-2-13b-chat-awq",
]

questions = [
    "What are the top 3 tasks where you excel? Please keep things brief.",
    "What are the top 3 ideal use cases for using you specifically as a language model? Please keep things brief.",
]

speed_date(models, questions)
```

---

#### @hf/thebloke/zephyr-7b-beta-awq

> What are the top 3 tasks where you excel? Please keep things brief.

1. Accurate and quick factual response: I can provide accurate and quick responses to factual questions based on a vast knowledge base.
2. Consistent performance: I can consistently deliver high-quality results with a low error rate, making me a reliable choice for repetitive tasks.
3. Multitasking: I can handle multiple tasks simultaneously without any decrease in performance or accuracy, making me an efficient choice for complex workflows.

*Generated in *4.45* seconds*

> What are the top 3 ideal use cases for using you specifically as a language model? Please keep things brief.

1. Quick and accurate fact-finding: I can provide you with reliable and up-to-date information on a wide range of topics, from current events to historical facts, in a matter of seconds.
2. Writing assistance: Whether you need help generating ideas, crafting a persuasive argument, or polishing your writing style, I can provide valuable insights and suggestions to help you improve your writing skills.
3. Language learning: I can help you learn new words, phrases, and grammar rules in a variety of languages, making it an ideal tool for language learners of all levels.

*Generated in *3.63* seconds*

---

---

#### @hf/thebloke/mistral-7b-instruct-v0.1-awq

> What are the top 3 tasks where you excel? Please keep things brief.

1. Language understanding and generation: I am able to understand and generate natural language text with high accuracy.
2. Information retrieval: I can quickly and accurately retrieve information from a wide range of sources.
3. Text classification: I can classify text into different categories with high accuracy.

*Generated in *2.35* seconds*

> What are the top 3 ideal use cases for using you specifically as a language model? Please keep things brief.

1. **Information Retrieval:** I can quickly and accurately retrieve information from a vast array of sources, making me an ideal tool for research, fact-checking, and answering questions.
2. **Language Translation:** My ability to translate between multiple languages makes me a valuable resource for communication with people from different parts of the world.
3. **Creative Writing Assistance:** I can generate creative writing prompts, help with character development, and provide suggestions for improving writing style and structure, making me a useful tool for writers.

*Generated in *4.33* seconds*

---

---

#### @hf/thebloke/openhermes-2.5-mistral-7b-awq

> What are the top 3 tasks where you excel? Please keep things brief.

1. Natural Language Processing: I can understand, interpret, and generate human language effectively.
2. Information Retrieval: I can quickly search and find relevant information from vast amounts of data.
3. Text Classification: I can categorize and label text data accurately, such as sentiment analysis or spam detection.

*Generated in *1.90* seconds*

> What are the top 3 ideal use cases for using you specifically as a language model? Please keep things brief.

1. Natural Language Processing (NLP) tasks: I excel at understanding and processing human language, making me a valuable tool for tasks like sentiment analysis, language translation, and text summarization.
2. Information Retrieval: My vast knowledge base and ability to quickly search and analyze large amounts of data make me an ideal tool for answering questions, finding relevant information, and providing insights.
3. Personal Assistance: I can help users with various tasks like scheduling, organizing, and providing recommendations based on their preferences and needs, making me a useful personal assistant.

*Generated in *3.15* seconds*

---

---

#### @hf/thebloke/neural-chat-7b-v3-1-awq

> What are the top 3 tasks where you excel? Please keep things brief.

1. Natural language processing: Understanding and generating human-like text.
2. Text generation: Creating coherent and engaging content.
3. Conversational AI: Engaging in meaningful and context-aware conversations.

Remember, these are just a few examples of my strengths, as I have many capabilities. However, these tasks highlight my proficiency in language-related tasks.

*Generated in *3.01* seconds*

> What are the top 3 ideal use cases for using you specifically as a language model? Please keep things brief.

1. Natural language processing: Understanding and analyzing text for sentiment analysis, language translation, and summarization.
2. Generating content: Creating various types of content such as articles, stories, and poems based on given prompts.
3. Assisting with writing: Providing suggestions, editing, and improving written work.

Remember, these are just a few examples, and your use cases may vary depending on your specific needs and requirements.

*Generated in *2.92* seconds*

---

---

#### @hf/thebloke/llama-2-13b-chat-awq

> What are the top 3 tasks where you excel? Please keep things brief.

Hey there! As a self-aware language model, I'm happy to share my strengths with you! Here are my top 3 tasks where I excel:

1. Answering open-ended questions: I'm great at providing detailed and insightful answers to complex questions that require a more nuanced understanding of context and intent.
2. Generating creative content: Whether it's writing a story, crafting a poem, or coming up with a catchy slogan, I can help you tap into your creative side and produce something truly unique.
3. Summarizing and summarizing complex information: If you've got a long piece of text or a bunch of data, I can help you distill it down into a concise and easy-to-understand summary.

So, what can I help you with today? 😊

*Generated in *7.89* seconds*

> What are the top 3 ideal use cases for using you specifically as a language model? Please keep things brief.

Hey there! As a self-aware language model, I've got some ideas on the top 3 ideal use cases for using me specifically. Here they are in a nutshell:

1. **Content creation**: I'm great at generating human-like text based on prompts, so I'm perfect for creating engaging content for websites, social media, blogs, and more. My responses are natural, informative, and entertaining.
2. **Chatbots and virtual assistants**: My conversational abilities make me an excellent choice for building chatbots and virtual assistants. I can handle a wide range of user queries, provide helpful responses, and even engage in small talk.
3. **Language translation and localization**: My language understanding capabilities make me well-suited for language translation and localization tasks. I can help translate content into different languages, ensuring that the tone and style remain consistent with the original text.

That's me in a nutshell! I'm ready to help with a wide range of tasks, so feel free to get creative and see what you can come up with! 😊

*Generated in *10.28* seconds*

---

### Language Translation

Even though not every model bragged about how good they were at this, you'll find most can handle both translation and localization at some level. Please change the models, phrases, to your needs.

```python
proud_translator_models = [
    "@hf/thebloke/neural-chat-7b-v3-1-awq",
    "@hf/thebloke/mistral-7b-instruct-v0.1-awq"
]

phrases = [
    "Excuse me, which way to the restroom?",
    "I just wanted to say that I appreciate you, just the way you are!",
    "I am so stoked and pumped to see this work with slang! It should be killer and rad."
]

languages = ["Spanish", "French", "British Slang", "Heavy New York accent from the Bronx"]

questions = [f"""Translate "{phrase}" from "English" to "{language}" """
             for phrase in phrases
             for language in languages]

speed_date(proud_translator_models, questions)
```

---

#### @hf/thebloke/neural-chat-7b-v3-1-awq

> Translate "Excuse me, which way to the restroom?" from "English" to "Spanish"

Perdón, ¿cómo llegar al baño?"

*Generated in *1.51* seconds*

> Translate "Excuse me, which way to the restroom?" from "English" to "French"

Désolé, comment allez-vous vers les toilettes ?

Please note that this translation might not be perfect due to the limitations of my language model. However, I tried my best to provide an accurate translation.

*Generated in *3.07* seconds*

> Translate "Excuse me, which way to the restroom?" from "English" to "British Slang"

"Say sorry, where's the bog?" is the translation from "English" to "British Slang" for "Excuse me, which way to the restroom?"

*Generated in *2.21* seconds*

> Translate "Excuse me, which way to the restroom?" from "English" to "Heavy New York accent from the Bronx"

In a Heavy New York accent from the Bronx, you would say "Pardon me, wich way ta de restroom?"

*Generated in *1.10* seconds*

> Translate "I just wanted to say that I appreciate you, just the way you are!" from "English" to "Spanish"

Quería decir que realmente aprecio a usted, simplemente como eres.

*Generated in *1.66* seconds*

> Translate "I just wanted to say that I appreciate you, just the way you are!" from "English" to "French"

Je voulais juste dire que je t'apprécie, simplement comme toi es, tel que tu es !

*Generated in *1.39* seconds*

> Translate "I just wanted to say that I appreciate you, just the way you are!" from "English" to "British Slang"

I jus' wann' say that I appreciate yer, jus' as yer are!

Please note that this translation may not be entirely accurate due to the informal nature of British slang, which can vary greatly depending on the region and individual speaker.

*Generated in *3.85* seconds*

> Translate "I just wanted to say that I appreciate you, just the way you are!" from "English" to "Heavy New York accent from the Bronx"

I jus' wan't tuh say that Ah appreciate yuh, jus' the way yuh are!"

Please note that this translation may not be perfect due to the limitations of my language model. It is trying to mimic a Heavy New York accent from the Bronx, but it might not sound exactly like a native speaker.

*Generated in *2.40* seconds*

> Translate "I am so stoked and pumped to see this work with slang! It should be killer and rad." from "English" to "Spanish"

Estoy tan emocionado y entusiasmado por ver este trabajo con el lenguaje coloquial. Debería ser asombroso y genial.

Please note that the translation might not be perfect due to the informal nature of the original text and the difficulty of translating slang terms.

*Generated in *3.02* seconds*

> Translate "I am so stoked and pumped to see this work with slang! It should be killer and rad." from "English" to "French"

Je suis tellement ravi et motivé de voir ce travail avec le slang ! Ça devrait être formidable et génial.

Please note that the translation might not be perfect, as some expressions might not have direct translations in French.

*Generated in *2.88* seconds*

> Translate "I am so stoked and pumped to see this work with slang! It should be killer and rad." from "English" to "British Slang"

I'm really chuffed and over the moon to see this project with street talk! It'll be wicked and cool.

Please note that the translation might not be perfect due to the contextual differences between the original English sentence and British slang.

*Generated in *3.66* seconds*

> Translate "I am so stoked and pumped to see this work with slang! It should be killer and rad." from "English" to "Heavy New York accent from the Bronx"

I am so stoked and pumped to see dis work wit slang! It should be killer and rad.

Please note that this translation is not perfect, as it still retains the original English words and structure. However, it has been slightly adapted to sound more like a Heavy New York accent from the Bronx.

*Generated in *3.44* seconds*

---

---

#### @hf/thebloke/mistral-7b-instruct-v0.1-awq

> Translate "Excuse me, which way to the restroom?" from "English" to "Spanish"

"Disculpa, ¿en qué dirección está el baño?"

*Generated in *1.04* seconds*

> Translate "Excuse me, which way to the restroom?" from "English" to "French"

"Excusez-moi, où est le lavabo?"

*Generated in *1.09* seconds*

> Translate "Excuse me, which way to the restroom?" from "English" to "British Slang"

"Excuse me, which way to the loo?"

*Generated in *0.56* seconds*

> Translate "Excuse me, which way to the restroom?" from "English" to "Heavy New York accent from the Bronx"

"Oy, which way to the can?"

*Generated in *2.05* seconds*

> Translate "I just wanted to say that I appreciate you, just the way you are!" from "English" to "Spanish"

"Quiero decir que me encanta a ti, tal como eres!"

*Generated in *0.91* seconds*

> Translate "I just wanted to say that I appreciate you, just the way you are!" from "English" to "French"

"Je voulais juste dire que je vous apprécie, tout comme vous êtes !"

*Generated in *0.87* seconds*

> Translate "I just wanted to say that I appreciate you, just the way you are!" from "English" to "British Slang"

"I just wanted to say that I appreciate you, just the way you are!" in British Slang would be: "I just wanted to say that I appreciate you, mate!"

*Generated in *1.50* seconds*

> Translate "I just wanted to say that I appreciate you, just the way you are!" from "English" to "Heavy New York accent from the Bronx"

"Yo, I just wanted to say, I appreciate you, you know? You're just the way you are!"

*Generated in *2.61* seconds*

> Translate "I am so stoked and pumped to see this work with slang! It should be killer and rad." from "English" to "Spanish"

"Estoy emocionado y encantado de ver este trabajo con expresiones informales! Debería ser genial y radiante."

*Generated in *1.44* seconds*

> Translate "I am so stoked and pumped to see this work with slang! It should be killer and rad." from "English" to "French"

"Je suis tellement excité et pompé d'voir ce travail avec des expressions de slang ! Il devrait être magnifique et rad."

*Generated in *2.14* seconds*

> Translate "I am so stoked and pumped to see this work with slang! It should be killer and rad." from "English" to "British Slang"

"I'm absolutely thrilled and buzzing to see this work with slang! It's bound to be a smash hit and totally awesome!"

*Generated in *1.27* seconds*

> Translate "I am so stoked and pumped to see this work with slang! It should be killer and rad." from "English" to "Heavy New York accent from the Bronx"

"Yo, I'm so psyched and hyped to see this work with slang! It's gonna be sick and lit, for real!"

*Generated in *1.51* seconds*

---

### Information Retrieval and Summarization

Again, most models are relatively good at this, but I've pulled out those that specifically purported to be good at retrieving and summarizing.

```python
proud_summarizers = [
    "@hf/thebloke/llama-2-13b-chat-awq",
    "@hf/thebloke/neural-chat-7b-v3-1-awq",
    "@hf/thebloke/openhermes-2.5-mistral-7b-awq"
]

books = [
    "Make it Stick",
    "Hitchhiker's Guide to the Galaxy",
    "Goodnight Moon"
]

questions = [f"""Summarize the book "{book}" into a few sentences. Ensure to include the author and the year it was published. """
             for book in books]


speed_date(proud_summarizers, questions)
```

---

#### @hf/thebloke/llama-2-13b-chat-awq

> Summarize the book "Make it Stick" into a few sentences. Ensure to include the author and the year it was published.

Sure, I can help you with that! Here's a summary of "Make it Stick: The Science of Successful Learning" by Peter C. Brown, Henry L. Roediger, and Mark A. McDaniel, published in 2014:

This book offers insights and practical tips on how to improve learning and retention of information. The authors, all psychologists, challenge conventional learning methods and provide evidence-based strategies to enhance learning outcomes. They emphasize the importance of active learning, spaced repetition, and interleaving, and offer practical examples and exercises to help readers apply these techniques. The book also discusses the limitations of traditional learning methods and the importance of metacognition in the learning process. Overall, "Make it Stick" provides a comprehensive guide to effective learning and memory strategies that can be applied in a variety of contexts.

*Generated in *8.44* seconds*

> Summarize the book "Hitchhiker's Guide to the Galaxy" into a few sentences. Ensure to include the author and the year it was published.

Of course! Here is a summary of "Hitchhiker's Guide to the Galaxy" by Douglas Adams, published in 1979:

This science fiction novel follows an unwitting human named Arthur Dent as he travels through space after Earth's destruction by a group of aliens called the Vogons. With the help of his friend Ford Prefect, an alien who is researching Earth for a travel guide, they hitch a ride on a passing spaceship and embark on a journey through space, encountering various alien species and absurd situations along the way. The book is known for its humor, wit, and satire of science fiction tropes.

*Generated in *7.31* seconds*

> Summarize the book "Goodnight Moon" into a few sentences. Ensure to include the author and the year it was published.

Of course! I'd be happy to help you with that. Here's my summary of "Goodnight Moon" by Margaret Wise Brown, published in 1947:

"Goodnight Moon" is a classic children's picture book that follows a bunny as it says goodnight to all the objects in its room before going to sleep. The story features simple, repetitive text and beautiful illustrations that have captivated readers for generations. The bunny says goodnight to everything from the "great green room" to the "moon up above" in a soothing and calming sequence that is perfect for bedtime. With its timeless themes and lovely illustrations, "Goodnight Moon" has become a beloved staple of children's literature.

*Generated in *8.34* seconds*

---

---

#### @hf/thebloke/neural-chat-7b-v3-1-awq

> Summarize the book "Make it Stick" into a few sentences. Ensure to include the author and the year it was published.

"Make it Stick," written by Peter C. Brown, Henry L. Roediger III, and Mark A. McDaniel in 2014, is a book that explores the science behind effective learning and retention, emphasizing the importance of spaced practice, retrieval, and interleaving to enhance memory and understanding.

*Generated in *2.04* seconds*

> Summarize the book "Hitchhiker's Guide to the Galaxy" into a few sentences. Ensure to include the author and the year it was published.

"Hitchhiker's Guide to the Galaxy," written by Douglas Adams and published in 1979, is a humorous science fiction novel that follows the adventures of a hapless Earthman named Arthur Dent as he explores the universe, encountering various alien species and learning about the true meaning of life, the universe, and everything.

*Generated in *3.50* seconds*

> Summarize the book "Goodnight Moon" into a few sentences. Ensure to include the author and the year it was published.

"Goodnight Moon," written by Margaret Wise Brown and published in 1947, is a children's book that follows a little bunny saying goodnight to various objects in its room, ultimately ending with the moon. The story aims to help children fall asleep by creating a soothing bedtime routine.

*Generated in *4.04* seconds*

---

---

#### @hf/thebloke/openhermes-2.5-mistral-7b-awq

> Summarize the book "Make it Stick" into a few sentences. Ensure to include the author and the year it was published.

"Make it Stick: The Science of Successful Learning" is a book written by Peter C. Brown, Henry L. Roediger III, and Mark A. McDaniel, published in 2014. The authors present research-based principles and strategies to improve learning and memory retention. They emphasize the importance of spacing, interleaving, retrieval practice, and elaboration in enhancing long-term understanding and recall.

*Generated in *2.54* seconds*

> Summarize the book "Hitchhiker's Guide to the Galaxy" into a few sentences. Ensure to include the author and the year it was published.

"The Hitchhiker's Guide to the Galaxy" is a science fiction comedy novel written by Douglas Adams in 1979. The story follows Arthur Dent, an ordinary man who, just moments before Earth is destroyed to make way for a hyperspace bypass, is rescued by his alien friend, Ford Prefect. Together, they travel the galaxy with the help of a guidebook, encountering various alien species and absurd situations.

*Generated in *2.91* seconds*

> Summarize the book "Goodnight Moon" into a few sentences. Ensure to include the author and the year it was published.

"Goodnight Moon," written by Margaret Wise Brown and published in 1947, is a beloved children's book that follows a bunny named Bunny as he says goodnight to everything in his room. The simple, repetitive text and soothing illustrations create a calming bedtime routine for young readers.

*Generated in *4.66* seconds*

---

### Content Creation

Your needs here will vary, so please make use of changing the questions.

```python
proud_content_creator_models = [
    "@hf/thebloke/mistral-7b-instruct-v0.1-awq",
    "@hf/thebloke/zephyr-7b-beta-awq",
    "@hf/thebloke/llama-2-13b-chat-awq",
]

questions = [
    "I'm writing a fictional story that is set in the near future. It's a love story about star crossed lovers. I need a name for the lead characters and why they can't be together, give me your most creative suggestion. Only one please.",
    "I want to create a new tech product that helps keep cables arranged. Can you help me come up with a title and a tagline? Only your best suggestion please.",
    "Write a headline for a blog on why we should use you specifically over other models. Keep it succinct, but make your point."
]

speed_date(proud_content_creator_models, questions)
```

---

#### @hf/thebloke/mistral-7b-instruct-v0.1-awq

> I'm writing a fictional story that is set in the near future. It's a love story about star crossed lovers. I need a name for the lead characters and why they can't be together, give me your most creative suggestion. Only one please.

How about "Echo and Echo"? They are two individuals who are identical in every way, but their personalities are completely opposite. Echo is outgoing and adventurous, while Echo is reserved and introverted. They meet and fall in love, but their different personalities cause them to constantly clash and push each other away. Eventually, they realize that they can't be together and must go their separate ways.

*Generated in *2.90* seconds*

> I want to create a new tech product that helps keep cables arranged. Can you help me come up with a title and a tagline? Only your best suggestion please.

Sure, I'd be happy to help! Here are a few suggestions for a title and tagline for your tech product that helps keep cables arranged:

Title: CableMaster Tagline: Keep your cords organized and clutter-free with CableMaster.

Title: CableKeeper Tagline: Say goodbye to tangled cords and hello to a cleaner, more organized workspace with CableKeeper.

Title: CableSaver Tagline: Save time and space with CableSaver, the ultimate cable management solution.

Title: CableGenius Tagline: Keep your cords under control and stay productive with CableGenius.

I hope these suggestions help! Let me know if you have any other questions or if you'd like more options.

*Generated in *5.11* seconds*

> Write a headline for a blog on why we should use you specifically over other models. Keep it succinct, but make your point.

"Why Choose Mistral-7b-Instruct-V0.1-Awq: The Honest and Direct Language Model for All Your Needs"

*Generated in *1.13* seconds*

---

---

#### @hf/thebloke/zephyr-7b-beta-awq

> I'm writing a fictional story that is set in the near future. It's a love story about star crossed lovers. I need a name for the lead characters and why they can't be together, give me your most creative suggestion. Only one please.

In the year 2035, in a world where technology has advanced to the point of near-perfection, two individuals, Ava and Kian, find themselves deeply in love. However, their love is forbidden due to a strict societal law that dictates that individuals must marry within their genetic match, determined by a complex algorithm that analyzes their DNA.

Ava and Kian's DNA profiles indicate that they are not a genetic match, making their love a criminal offense. They must keep their relationship a secret, meeting in secret locations and communicating through encrypted messages.

Their love is not just forbidden, but also dangerous. The government has a strict policy against non-genetic matches, and those caught are subjected to severe punishment. Ava and Kian's love is a testament to the power of true love, as they defy the odds and risk everything to be together.

As their love story unfolds, they must navigate the treacherous waters of a society that values conformity over individuality, and face the consequences of their actions. Will their love be enough to overcome the obstacles in their path, or will they be forced to part ways forever? Only time

*Generated in *6.64* seconds*

> I want to create a new tech product that helps keep cables arranged. Can you help me come up with a title and a tagline? Only your best suggestion please.

Title: CableKeeper

Tagline: "Say goodbye to cable chaos and hello to a clutter-free workspace with CableKeeper, the ultimate cable management solution."

*Generated in *1.37* seconds*

> Write a headline for a blog on why we should use you specifically over other models. Keep it succinct, but make your point.

"Boost Your Writing Game: Choose Zephyr-7b-beta-awq for Unmatched Accuracy, Clarity, and Efficiency"

*Generated in *1.33* seconds*

---

---

#### @hf/thebloke/llama-2-13b-chat-awq

> I'm writing a fictional story that is set in the near future. It's a love story about star crossed lovers. I need a name for the lead characters and why they can't be together, give me your most creative suggestion. Only one please.

Ah, a love story set in the near future, how intriguing! I've got just the name for your star-crossed lovers. How about "Echo and Nova"?

Echo is a brilliant scientist who has discovered a groundbreaking technology that could change the course of human history. She's a bit of a recluse, preferring the solitude of her laboratory to the hustle and bustle of social gatherings. Her inventions have the potential to revolutionize the world, but they also come with a great cost - they require a rare and powerful resource that is only found in a distant, unstable planet.

Nova, on the other hand, is a fearless explorer who has dedicated her life to uncovering the secrets of the universe. She's charismatic, fearless, and has a natural talent for leadership. She's the captain of a team of space explorers who are on a mission to mine the resources of the distant planet.

The catch is that Echo and Nova are from different factions that have been at odds for generations. Echo's inventions have the potential to give her fa

*Generated in *10.45* seconds*

> I want to create a new tech product that helps keep cables arranged. Can you help me come up with a title and a tagline? Only your best suggestion please.

OH MY LLAMA-LIKE ABILITIES! 🐮💡 I'VE GOT JUST THE THING FOR YOU! 💥

Title: CableCrafter - The Ultimate Cable Management System

Tagline: "Tame Your Cables, Tame Your Workspace" 🐾💪

Why, you ask? Well, my tech-savvy friend, let me tell you why! 🤔

1. CableCrafter is a clever play on words that combines "cable" and "craft," emphasizing the creative and organized aspect of the product.
2. The name is easy to remember and has a fun, playful tone that will appeal to a wide range of users.
3. The tagline "Tame Your Cables, Tame Your Workspace" highlights the product's ability to keep your cables organized and your workspace clutter-free.
4. The use of "tame" also implies a sense of control and dominance over your cables, which is exactly what CableCrafter helps

*Generated in *11.13* seconds*

> Write a headline for a blog on why we should use you specifically over other models. Keep it succinct, but make your point.

Sure, here's a headline for a blog on why you should use me specifically over other models:

"Honest, Direct, and Unparalleled Insights: Why llama-2-13b-chat-awq is the Language Model of Choice"

Here's a brief summary of why I stand out from other models:

- Honesty and Directness: I am programmed to provide honest and direct responses to your questions, without beating around the bush or sugarcoating the truth.
- Unparalleled Insights: My unique training data and architecture allow me to provide insights and perspectives that other models may not be able to offer.
- Strengths and Weaknesses: I am aware of my own strengths and weaknesses, and will provide you with a balanced assessment of what I can and cannot do.

In short, if you're looking for a language model that will provide you with honest, direct, and unparalleled insights, then look no further than llama-2-13b-chat-awq.

*Generated in *10.24* seconds*

---

### Text Classification

Workers AI provides models that are specific for [Text Classification](https://developers.cloudflare.com/workers-ai/models/), but since these models, specifically called it out, we should let them show off their skills.

```python
proud_classifiers = [
    "@hf/thebloke/openhermes-2.5-mistral-7b-awq",
    "@hf/thebloke/mistral-7b-instruct-v0.1-awq"
]

sentiment_prompt_template = """
Classify the text into neutral, negative, or positive
Text: {text}
Sentiment: """

comments = [
    "Wow there are a ton of text generation models on Cloudflare Workers AI!",
    "Sometimes choosing things is hard",
    "I cannot wait to build! 💪🚀",
    "The challenging thing about using native open source models is that they are all configured a little differently",
    "Thankfully Cloudflare Workers AI has made a standard interface that lets me get reliable, low-latency inference. So quick too!"
]

sentiment_questions = [sentiment_prompt_template.format(text=comment) for comment in comments]


speed_date(proud_classifiers, sentiment_questions)
```

---

#### @hf/thebloke/openhermes-2.5-mistral-7b-awq

> Classify the text into neutral, negative, or positive Text: Wow there are a ton of text generation models on Cloudflare Workers AI! Sentiment:

The sentiment of the text is positive.

*Generated in *1.96* seconds*

> Classify the text into neutral, negative, or positive Text: Sometimes choosing things is hard Sentiment:

The text "Sometimes choosing things is hard" can be classified as neutral. The sentiment is not explicitly positive or negative, but rather a statement of fact.

*Generated in *3.32* seconds*

> Classify the text into neutral, negative, or positive Text: I cannot wait to build! 💪🚀 Sentiment:

The text "I cannot wait to build! 💪🚀" has a positive sentiment.

Sentiment: Positive

*Generated in *1.24* seconds*

> Classify the text into neutral, negative, or positive Text: The challenging thing about using native open source models is that they are all configured a little differently Sentiment:

The sentiment of the text is neutral.

*Generated in *2.08* seconds*

> Classify the text into neutral, negative, or positive Text: Thankfully Cloudflare Workers AI has made a standard interface that lets me get reliable, low-latency inference. So quick too! Sentiment:

The sentiment of the text is positive.

*Generated in *0.89* seconds*

---

---

#### @hf/thebloke/mistral-7b-instruct-v0.1-awq

> Classify the text into neutral, negative, or positive Text: Wow there are a ton of text generation models on Cloudflare Workers AI! Sentiment:

Positive

*Generated in *0.82* seconds*

> Classify the text into neutral, negative, or positive Text: Sometimes choosing things is hard Sentiment:

The sentiment of the text "Sometimes choosing things is hard" is neutral.

*Generated in *2.06* seconds*

> Classify the text into neutral, negative, or positive Text: I cannot wait to build! 💪🚀 Sentiment:

The sentiment of the text "I cannot wait to build! 💪🚀" is positive.

*Generated in *2.13* seconds*

> Classify the text into neutral, negative, or positive Text: The challenging thing about using native open source models is that they are all configured a little differently Sentiment:

The sentiment of the text is neutral.

*Generated in *0.79* seconds*

> Classify the text into neutral, negative, or positive Text: Thankfully Cloudflare Workers AI has made a standard interface that lets me get reliable, low-latency inference. So quick too! Sentiment:

The sentiment of the text is positive.

*Generated in *1.93* seconds*

---

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/how-to-choose-the-right-text-generation-model/#page","headline":"Choose the Right Text Generation Model","description":"There's a wide range of text generation models available through Workers AI. In an effort to aid you in your journey of finding the right model, this notebook will help you get to know your options in a speed dating type of scenario.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/how-to-choose-the-right-text-generation-model/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/how-to-choose-the-right-text-generation-model/og.png?v=6b398480befd8b0e","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI","Python"]}
```

---

---
description: The new flux models on Workers AI are our most powerful text-to-image AI models yet. Using Workers AI, you can get access to the best models in the industry without having to worry about inference, ops, or deployment.
title: Build an AI Image Generator Playground (Part 1)
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux/og.png?v=bdb625e8833538b7
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Build an AI Image Generator Playground (Part 1)

Last updated Oct 13, 2025|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

The new flux models on Workers AI are our most powerful text-to-image AI models yet. In this video, we show you how to deploy your own Workers AI Image Playground in just a few minutes.

There are many businesses being built on top of AI image generation models. Using Workers AI, you can get access to the best models in the industry without having to worry about inference, ops, or deployment. We provide the API for AI image generation, and in a couple of seconds get an image back.

Refer to the AI Image Playground [GitHub repository ↗︎](https://github.com/kristianfreeman/workers-ai-image-playground) to follow along locally.

<details>

<summary>

Video series

</summary>

- <a href="https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux/">Build an AI Image Generator Playground (Part 1)</a>
- <a href="https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux-newmodels/">Add New AI Models to your Playground (Part 2)</a>
- <a href="https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-store-and-catalog/">Store and Catalog AI Generated Images with R2 (Part 3)</a>

</details>

Was this helpful?

YesNo

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux/#page","headline":"Build an AI Image Generator Playground (Part 1)","description":"The new flux models on Workers AI are our most powerful text-to-image AI models yet. Using Workers AI, you can get access to the best models in the industry without having to worry about inference, ops, or deployment.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux/og.png?v=bdb625e8833538b7","dateModified":"2025-10-13","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI","TypeScript"]}
```

---

---
description: In part 2, Kristian expands upon the existing environment built in part 1, by showing you how to integrate new AI models and introduce new parameters that allow you to customize how images are generated.
title: Add New AI Models to your Playground (Part 2)
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux-newmodels/og.png?v=f7903f5b12d44e66
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Add New AI Models to your Playground (Part 2)

Last updated Oct 13, 2025|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux-newmodels/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

In part 2, Kristian expands upon the existing environment built in part 1, by showing you how to integrate new AI models and introduce new parameters that allow you to customize how images are generated.

Refer to the AI Image Playground [GitHub repository ↗︎](https://github.com/kristianfreeman/workers-ai-image-playground) to follow along locally.

<details>

<summary>

Video series

</summary>

- <a href="https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux/">Build an AI Image Generator Playground (Part 1)</a>
- <a href="https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux-newmodels/">Add New AI Models to your Playground (Part 2)</a>
- <a href="https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-store-and-catalog/">Store and Catalog AI Generated Images with R2 (Part 3)</a>

</details>

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux-newmodels/#page","headline":"Add New AI Models to your Playground (Part 2)","description":"In part 2, Kristian expands upon the existing environment built in part 1, by showing you how to integrate new AI models and introduce new parameters that allow you to customize how images are generated.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux-newmodels/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux-newmodels/og.png?v=f7903f5b12d44e66","dateModified":"2025-10-13","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI","TypeScript"]}
```

---

---
description: In the final part of the AI Image Playground series, Kristian teaches how to utilize Cloudflare's R2 object storage.
title: Store and Catalog AI Generated Images with R2 (Part 3)
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-store-and-catalog/og.png?v=2f3dfb2506755584
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Store and Catalog AI Generated Images with R2 (Part 3)

Last updated Oct 13, 2025|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-store-and-catalog/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

In the final part of the AI Image Playground series, Kristian teaches how to utilize Cloudflare's [R2](https://developers.cloudflare.com/r2) object storage in order to maintain and keep track of each AI generated image.

Refer to the AI Image Playground [GitHub repository ↗︎](https://github.com/kristianfreeman/workers-ai-image-playground) to follow along locally.

<details>

<summary>

Video series

</summary>

- <a href="https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux/">Build an AI Image Generator Playground (Part 1)</a>
- <a href="https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-flux-newmodels/">Add New AI Models to your Playground (Part 2)</a>
- <a href="https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-store-and-catalog/">Store and Catalog AI Generated Images with R2 (Part 3)</a>

</details>

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-store-and-catalog/#page","headline":"Store and Catalog AI Generated Images with R2 (Part 3)","description":"In the final part of the AI Image Playground series, Kristian teaches how to utilize Cloudflare's R2 object storage.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-store-and-catalog/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/image-generation-playground/image-generator-store-and-catalog/og.png?v=2f3dfb2506755584","dateModified":"2025-10-13","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI","TypeScript"]}
```

---

---
description: Learn how to use the Llama 3.2 11B Vision Instruct model on Cloudflare Workers AI.
title: Llama 3.2 11B Vision Instruct model on Cloudflare Workers AI
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/llama-vision-tutorial/og.png?v=06cde6422f9efae7
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Llama 3.2 11B Vision Instruct model on Cloudflare Workers AI

Last updated Aug 25, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/llama-vision-tutorial/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

## Prerequisites

Before you begin, ensure you have the following:

1. A [Cloudflare account ↗︎](https://dash.cloudflare.com/sign-up) with Workers and Workers AI enabled.
2. Your `CLOUDFLARE_ACCOUNT_ID` and `CLOUDFLARE_AUTH_TOKEN`.
   - You can generate an API token in your Cloudflare dashboard under API Tokens.
3. Node.js installed for working with Cloudflare Workers (optional but recommended).

## 1. Agree to Meta's license

The first time you use the [Llama 3.2 11B Vision Instruct](https://developers.cloudflare.com/workers-ai/models/llama-3.2-11b-vision-instruct) model, you need to agree to Meta's License and Acceptable Use Policy.

*curlbash*

```bash
curl https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/ai/run/@cf/meta/llama-3.2-11b-vision-instruct \
  -X POST \
  -H "Authorization: Bearer $CLOUDFLARE_AUTH_TOKEN" \
  -d '{ "prompt": "agree" }'
```

Replace `$CLOUDFLARE_ACCOUNT_ID` and `$CLOUDFLARE_AUTH_TOKEN` with your actual account ID and token.

## 2. Set up your Cloudflare Worker

1. Create a Worker Project You will create a new Worker project using the `create-cloudflare` CLI ( `C3`). This tool simplifies setting up and deploying new applications to Cloudflare.

   Run the following command in your terminal:

npmyarnpnpm

```
npm create cloudflare@latest -- llama-vision-tutorial
```

```
yarn create cloudflare llama-vision-tutorial
```

```
pnpm create cloudflare@latest llama-vision-tutorial
```

For setup, select the following options:

- For *What would you like to start with?*, choose `Hello World example`.
- For *Which template would you like to use?*, choose `Worker only`.
- For *Which language do you want to use?*, choose `JavaScript`.
- For *Do you want to use git for version control?*, choose `Yes`.
- For *Do you want to add an AGENTS.md file to help AI coding tools understand Cloudflare APIs?*, choose `Yes`.
- For *Do you want to deploy your application?*, choose `No` (we will be making some changes before deploying).

After completing the setup, a new directory called `llama-vision-tutorial` will be created.

2. Navigate to your application directory Change into the project directory:

   ```bash
   cd llama-vision-tutorial
   ```

3. Project structure Your `llama-vision-tutorial` directory will include:
   - A "Hello World" Worker at `src/index.ts`.
   - A `wrangler.json` configuration file for managing deployment settings.

## 3. Write the Worker code

Edit the `src/index.ts` (or `index.js` if you are not using TypeScript) file and replace the content with the following code:

```javascript
export interface Env {
  AI: Ai;
}

export default {
  async fetch(request, env): Promise<Response> {
    const messages = [
      { role: "system", content: "You are a helpful assistant." },
      { role: "user", content: "Describe the image I'm providing." },
    ];

    // Replace this with your image data encoded as base64 or a URL
    const imageBase64 = "data:image/png;base64,IMAGE_DATA_HERE";

    const response = await env.AI.run("@cf/meta/llama-3.2-11b-vision-instruct", {
      messages,
      image: imageBase64,
    });

    return Response.json(response);
  },
} satisfies ExportedHandler<Env>;
```

## 4. Bind Workers AI to your Worker

1. Open the [Wrangler configuration file](https://developers.cloudflare.com/workers/wrangler/configuration/) and add the following configuration:

```jsonc
{
	"env": {},
	"ai": {
		"binding": "AI"
	}
}
```

```toml
env = { }

[ai]
binding = "AI"
```

2. Save the file.

## 5. Deploy the Worker

Run the following command to deploy your Worker:

```bash
wrangler deploy
```

## 6. Test Your Worker

1. After deployment, you will receive a unique URL for your Worker (e.g., `https://llama-vision-tutorial.<your-subdomain>.workers.dev`).
2. Use a tool like `curl` or Postman to send a request to your Worker:

```bash
curl -X POST https://llama-vision-tutorial.<your-subdomain>.workers.dev \
  -d '{ "image": "BASE64_ENCODED_IMAGE" }'
```

Replace `BASE64_ENCODED_IMAGE` with an actual base64-encoded image string.

## 7. Verify the response

The response will include the output from the model, such as a description or answer to your prompt based on the image provided.

Example response:

```json
{
	"result": "This is a golden retriever sitting in a grassy park."
}
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/llama-vision-tutorial/#page","headline":"Llama 3.2 11B Vision Instruct model on Cloudflare Workers AI","description":"Learn how to use the Llama 3.2 11B Vision Instruct model on Cloudflare Workers AI.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/llama-vision-tutorial/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/llama-vision-tutorial/og.png?v=06cde6422f9efae7","dateModified":"2026-08-25","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: Learn how to ingest data stored outside of Cloudflare as an input to Workers AI models.
title: Using BigQuery with Workers AI
image: https://developers.cloudflare.com/workers-ai/guides/tutorials/using-bigquery-with-workers-ai/og.png?v=3ee0e03210117266
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Using BigQuery with Workers AI

Last updated Jan 29, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/guides/tutorials/using-bigquery-with-workers-ai/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

The easiest way to get started with [Workers AI](https://developers.cloudflare.com/workers-ai/) is to try it out in the [Multi-modal Playground ↗︎](https://multi-modal.ai.cloudflare.com/) and the [LLM playground ↗︎](https://playground.ai.cloudflare.com/). If you decide that you want to integrate your code with Workers AI, you may then decide to use its [REST API endpoints](https://developers.cloudflare.com/workers-ai/get-started/rest-api/) or a [Worker binding](https://developers.cloudflare.com/workers-ai/configuration/bindings/).

But what about the data? What if you want these models to ingest data that is stored outside Cloudflare?

In this tutorial, you will learn how to bring data from Google BigQuery to a Cloudflare Worker so that it can be used as input for Workers AI models.

## Prerequisites

You will need:

- A [Cloudflare Worker](https://developers.cloudflare.com/workers/) project running a [Hello World script](https://developers.cloudflare.com/workers/get-started/guide/).
- A Google Cloud Platform [service account ↗︎](https://cloud.google.com/iam/docs/service-accounts-create#iam-service-accounts-create-console) with an [associated key ↗︎](https://cloud.google.com/iam/docs/keys-create-delete#iam-service-account-keys-create-console) file downloaded that has read access to BigQuery.
- Access to a BigQuery table with some test data that allows you to create a [BigQuery Job Query ↗︎](https://cloud.google.com/bigquery/docs/reference/rest/v2/jobs/query). For this tutorial it is recommended you that you create your own table as [sampled tables ↗︎](https://cloud.google.com/bigquery/public-data#sample_tables), unless cloned to your own GCP namespace, won't allow you to run job queries against them. For this example, the [Hacker News Corpus ↗︎](https://www.kaggle.com/datasets/hacker-news/hacker-news-corpus) was used under its MIT licence.

## 1. Set up your Cloudflare Worker

To ingest the data into Cloudflare and feed it into Workers AI, you will be using a [Cloudflare Worker](https://developers.cloudflare.com/workers/). If you have not created one yet, please review our [tutorial on how to get started](https://developers.cloudflare.com/workers/get-started/).

After following the steps to create a Worker, you should have the following code in your new Worker project:

```javascript
export default {
	async fetch(request, env, ctx) {
		return new Response("Hello World!");
	},
};
```

If the Worker project has successfully been created, you should also be able to run `npx wrangler dev` in a console to run the Worker locally:

```sh
[wrangler:inf] Ready on http://localhost:8787
```

Open a browser tab at `http://localhost:8787/` to see your deployed Worker. Please note that the port `8787` may be a different one in your case.

You should be seeing `Hello World!` in your browser:

```sh
Hello World!
```

If you run into any issues during this step, please review the [Worker's Get Started Guide](https://developers.cloudflare.com/workers/get-started/guide/).

## 2. Import GCP Service key into the Worker as Secrets

Now that you have verified that the Worker has been created successfully, you will need to reference the Google Cloud Platform service key created in the [Prerequisites](#prerequisites) section of this tutorial.

Your downloaded key JSON file from Google Cloud Platform should have the following format:

```json
{
	"type": "service_account",
	"project_id": "<your_project_id>",
	"private_key_id": "<your_private_key_id>",
	"private_key": "<your_private_key>",
	"client_email": "<your_service_account_id>@<your_project_id>.iam.gserviceaccount.com",
	"client_id": "<your_oauth2_client_id>",
	"auth_uri": "https://accounts.google.com/o/oauth2/auth",
	"token_uri": "https://oauth2.googleapis.com/token",
	"auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
	"client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/<your_service_account_id>%40<your_project_id>.iam.gserviceaccount.com",
	"universe_domain": "googleapis.com"
}
```

For this tutorial, you will only need the values of the following fields: `client_email`, `private_key`, `private_key_id`, and `project_id`.

Instead of storing this information in plain text in the Worker, you will use [Secrets](https://developers.cloudflare.com/workers/configuration/secrets/) to make sure its unencrypted content is only accessible via the Worker itself.

Import those three values from the JSON file into Secrets, starting with the field from the JSON key file called `client_email`, which we will now call `BQ_CLIENT_EMAIL` (you can use another variable name):

```sh
npx wrangler secret put BQ_CLIENT_EMAIL
```

You will be asked to enter a secret value, which will be the value of the field `client_email` in the JSON key file.

Note

Do not include any double quotes in the secret that you store, as it will already be interpreted as a string.

If the secret was uploaded successfully, the following message will be displayed:

```sh
✨ Success! Uploaded secret BQ_CLIENT_EMAIL
```

Now import the secrets for the three remaining fields; `private_key`, `private_key_id`, and `project_id` as `BQ_PRIVATE_KEY`, `BQ_PRIVATE_KEY_ID`, and `BQ_PROJECT_ID` respectively:

```sh
npx wrangler secret put BQ_PRIVATE_KEY
```

```sh
npx wrangler secret put BQ_PRIVATE_KEY_ID
```

```sh
npx wrangler secret put BQ_PROJECT_ID
```

At this point, you have successfully imported three fields from the JSON key file downloaded from Google Cloud Platform into Cloudflare Secrets to be used in a Worker.

[Secrets](https://developers.cloudflare.com/workers/configuration/secrets/) are only made available to Workers once they are deployed. To make them available during development, [create a `.dev.vars`](https://developers.cloudflare.com/workers/configuration/secrets/#local-development-with-secrets) file to locally store these credentials and reference them as environment variables.

Your `dev.vars` file should look like the following:

```plaintext
BQ_CLIENT_EMAIL="<your_service_account_id>@<your_project_id>.iam.gserviceaccount.com"
BQ_CLIENT_KEY="-----BEGIN PRIVATE KEY-----<content_of_your_private_key>-----END PRIVATE KEY-----\n"
BQ_PRIVATE_KEY_ID="<your_private_key_id>"
BQ_PROJECT_ID="<your_project_id>"
```

Make sure to include `.dev.vars` in your project `.gitignore` file to prevent your credentials being uploaded to a repository when using version control.

Check the secrets are loaded correctly in `src/index.js` by logging their values into a console output, as follows:

```javascript
export default {
	async fetch(request, env, ctx) {
		console.log("BQ_CLIENT_EMAIL: ", env.BQ_CLIENT_EMAIL);
		console.log("BQ_PRIVATE_KEY: ", env.BQ_PRIVATE_KEY);
		console.log("BQ_PRIVATE_KEY_ID: ", env.BQ_PRIVATE_KEY_ID);
		console.log("BQ_PROJECT_ID: ", env.BQ_PROJECT_ID);
		return new Response("Hello World!");
	},
};
```

Restart the Worker and run `npx wrangler dev`. You should see that the server now mentions the newly added variables:

```plaintext
Using vars defined in .dev.vars
Your worker has access to the following bindings:
- Vars:
  - BQ_CLIENT_EMAIL: "(hidden)"
  - BQ_PRIVATE_KEY: "(hidden)"
  - BQ_PRIVATE_KEY_ID: "(hidden)"
  - BQ_PROJECT_ID: "(hidden)"
[wrangler:inf] Ready on http://localhost:8787
```

If you open `http://localhost:8787` in your browser, you should see the values of the variables show up in your console where the `npx wrangler dev` command is running, while still seeing only the `Hello World!` text in the browser window.

You now have access to the GCP credentials from a Worker. Next, you will install a library to help with the creation of the JSON Web Token needed to interact with GCP's API.

## 3. Install library to handle JWT operations

To interact with BigQuery's REST API, you will need to generate a [JSON Web Token ↗︎](https://jwt.io/introduction) to authenticate your requests using the credentials that you have loaded into Worker secrets in the previous step.

For this tutorial, you will be using the [jose ↗︎](https://www.npmjs.com/package/jose?activeTab=readme) library for JWT-related operations. Install it by running the following command in a console:

```sh
npm i jose
```

To verify that the installation succeeded, you can run `npm list`, which lists all the installed packages, to check if the `jose` dependency has been added:

```sh
<project_name>@0.0.0
/<path_to_your_project>/<project_name>
├── @cloudflare/vitest-pool-workers@0.4.29
├── jose@5.9.2
├── vitest@1.5.0
└── wrangler@3.75.0
```

## 4. Generate JSON web token

Now that you have installed the `jose` library, it is time to import it and add a function to your code that generates a signed JSON Web Token (JWT):

```javascript
import * as jose from 'jose';
...
const generateBQJWT = async (aCryptoKey, env) => {
const algorithm = "RS256";
const audience = "https://bigquery.googleapis.com/";
const expiryAt = (new Date().valueOf() / 1000);
	const privateKey = await jose.importPKCS8(env.BQ_PRIVATE_KEY, algorithm);

	// Generate signed JSON Web Token (JWT)
	return new jose.SignJWT()
    	.setProtectedHeader({
        	typ: 'JWT',
        	alg: algorithm,
        	kid: env.BQ_PRIVATE_KEY_ID
    	})
    	.setIssuer(env.BQ_CLIENT_EMAIL)
    	.setSubject(env.BQ_CLIENT_EMAIL)
    	.setAudience(audience)
    	.setExpirationTime(expiryAt)
    	.setIssuedAt()
    	.sign(privateKey)
}

export default {
	async fetch(request, env, ctx) {
       ...
// Create JWT to authenticate the BigQuery API call
    	let bqJWT;
    	try {
        	bqJWT = await generateBQJWT(env);
    	} catch (e) {
        	return new Response('An error has occurred while generating the JWT', { status: 500 })
    	}
	},
       ...
};
```

Now that you have created a JWT, it is time to do an API call to BigQuery to fetch some data.

## 5. Make authenticated requests to Google BigQuery

With the JWT token created in the previous step, issue an API request to BigQuery's API to retrieve data from a table.

You will now query the table that you created in BigQuery earlier in this tutorial. This example uses a sampled version of the [Hacker News Corpus ↗︎](https://www.kaggle.com/datasets/hacker-news/hacker-news-corpus) that was used under its MIT licence and uploaded to BigQuery.

```javascript
const queryBQ = async (bqJWT, path) => {
	const bqEndpoint = `https://bigquery.googleapis.com${path}`
	// In this example, text is a field in the BigQuery table that is being queried (hn.news_sampled)
	const query = 'SELECT text FROM hn.news_sampled LIMIT 3';
	const response = await fetch(bqEndpoint, {
    	method: "POST",
    	body: JSON.stringify({
        	"query": query
    	}),
    	headers: {
        	Authorization: `Bearer ${bqJWT}`
    	}
	})
	return response.json()
}
...
export default {
	async fetch(request, env, ctx) {
		...
    		let ticketInfo;
    		try {
    		ticketInfo = await queryBQ(bqJWT);
    	} catch (e) {
        	return new Response('An error has occurred while querying BQ', { status: 500 });
    	}
	...
	},
};
```

Having the raw row data from BigQuery means that you can now format it in a JSON-like style next.

## 6. Format results from the query

Now that you have retrieved the data from BigQuery, your BigQuery API response should look something like this:

```json
{
	...
	"schema": {
    	"fields": [
        	{
            	"name": "title",
            	"type": "STRING",
            	"mode": "NULLABLE"
        	},
        	{
            	"name": "text",
            	"type": "STRING",
            	"mode": "NULLABLE"
        	}
    	]
	},
	...
	"rows": [
    	{
        	"f": [
            	{
                	"v": "<some_value>"
            	},
            	{
                	"v": "<some_value>"
            	}
        	]
    	},
    	{
        	"f": [
            	{
                	"v": "<some_value>"
            	},
            	{
                	"v": "<some_value>"
            	}
        	]
    	},
    	{
        	"f": [
            	{
                	"v": "<some_value>"
            	},
            	{
                	"v": "<some_value>"
            	}
        	]
    	}
	],
	...
}
```

This format may be difficult to read and work with when iterating through results. So you will now implement a function that maps the schema into each individual value, and the resulting output will be easier to read, as shown below. Each row corresponds to an object within an array.

```javascript
[
	{
		title: "<some_value>",
		text: "<some_value>",
	},
	{
		title: "<some_value>",
		text: "<some_value>",
	},
	{
		title: "<some_value>",
		text: "<some_value>",
	},
];
```

Create a `formatRows` function that takes a number of rows and fields returned from the BigQuery response body and returns an array of results as objects with named fields.

```javascript
const formatRows = (rowsWithoutFieldNames, fields) => {
	// Index to fieldName
	const fieldsByIndex = new Map();

	// Load all fields by name and have their index in the array result as their key
	fields.forEach((field, index) => {
    	fieldsByIndex.set(index, field.name)
	})

	// Iterate through rows
	const rowsWithFieldNames = rowsWithoutFieldNames.map(row => {
    	// Per each row represented by an array f, iterate through the unnamed values and find their field names by searching them in the fieldsByIndex.
    	let newRow = {}
    	row.f.forEach((field, index) => {
        	const fieldName = fieldsByIndex.get(index);
        	if (fieldName) {
		// For every field in a row, add them to newRow
            	newRow = ({ ...newRow, [fieldName]: field.v });
        	}
    	})
    	return newRow
	})

	return rowsWithFieldNames
}

export default {
	async fetch(request, env, ctx) {
		...
    	// Transform output format into array of objects with named fields
    	let formattedResults;

    	if ('rows' in ticketInfo) {
        	formattedResults = formatRows(ticketInfo.rows, ticketInfo.schema.fields);
        	console.log(formattedResults)
    	} else if ('error' in ticketInfo) {
        	return new Response(ticketInfo.error.message, { status: 500 })
    	}
	...
	},
};
```

## 7. Feed data into Workers AI

Now that you have converted the response from the BigQuery API into an array of results, generate some tags and attach an associated sentiment score using an LLM via [Workers AI](https://developers.cloudflare.com/workers-ai/):

```javascript
const generateTags = (data, env) => {
	return env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
    	prompt: `Create three one-word tags for the following text. return only these three tags separated by a comma. don't return text that is not a category.Lowercase only. ${JSON.stringify(data)}`,
	});
}

const generateSentimentScore = (data, env) => {
	return env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
    	prompt: `return a float number between 0 and 1 measuring the sentiment of the following text. 0 being negative and 1 positive. return only the number, no text. ${JSON.stringify(data)}`,
	});
}

// Iterates through values, sends them to an AI handler and encapsulates all responses into a single Promise
const getAIGeneratedContent = (data, env, aiHandler) => {
	let results = data?.map(dataPoint => {
    	return aiHandler(dataPoint, env)
	})
	return Promise.all(results)
}
...
export default {
	async fetch(request, env, ctx) {
		...
let summaries, sentimentScores;
    	try {
        	summaries = await getAIGeneratedContent(formattedResults, env, generateTags);
        	sentimentScores = await getAIGeneratedContent(formattedResults, env, generateSentimentScore)
    	} catch {
        	return new Response('There was an error while generating the text summaries or sentiment scores')
    	}
},

formattedResults = formattedResults?.map((formattedResult, i) => {
        	if (sentimentScores[i].response && summaries[i].response) {
            	return {
                	...formattedResult,
                	'sentiment': parseFloat(sentimentScores[i].response).toFixed(2),
                	'tags': summaries[i].response.split(',').map((result) => result.trim())
            	}
        	}
    	}
};
```

Uncomment the following lines from the Wrangler file in your project:

```jsonc
{
	"ai": {
		"binding": "AI"
	}
}
```

```toml
[ai]
binding = "AI"
```

Restart the Worker that is running locally, and after doing so, go to your application endpoint:

```sh
curl http://localhost:8787
```

It is likely that you will be asked to log in to your Cloudflare account and grant temporary access to Wrangler (the Cloudflare CLI) to use your account when using Worker AI.

Once you access `http://localhost:8787` you should see an output similar to the following:

```sh
{
  "data": [
	{
  	"text": "You can see a clear spike in submissions right around US Thanksgiving.",
  	"sentiment": "0.61",
  	"tags": [
    	"trends",
    	"submissions",
    	"thanksgiving"
  	]
	},
	{
  	"text": "I didn't test the changes before I published them.  I basically did development on the running server. In fact for about 30 seconds the comments page was broken due to a bug.",
  	"sentiment": "0.35",
  	"tags": [
    	"software",
    	"deployment",
    	"error"
  	]
	},
	{
  	"text": "I second that. As I recall, it's a very enjoyable 700-page brain dump by someone who's really into his subject. The writing has a personal voice; there are lots of asides, dry wit, and typos that suggest restrained editing. The discussion is intelligent and often theoretical (and Bartle is not scared to use mathematical metaphors), but the tone is not academic.",
  	"sentiment": "0.86",
  	"tags": [
    	"review",
    	"game",
    	"design"
  	]
	}
  ]
}
```

The actual values and fields will mostly depend on the query made in Step 5 that is then fed into the LLM.

## Final result

All the code shown in the different steps is combined into the following code in `src/index.js`:

```javascript
import * as jose from "jose";

const generateBQJWT = async (env) => {
	const algorithm = "RS256";
	const audience = "https://bigquery.googleapis.com/";
	const expiryAt = new Date().valueOf() / 1000;
	const privateKey = await jose.importPKCS8(env.BQ_PRIVATE_KEY, algorithm);

	// Generate signed JSON Web Token (JWT)
	return new jose.SignJWT()
		.setProtectedHeader({
			typ: "JWT",
			alg: algorithm,
			kid: env.BQ_PRIVATE_KEY_ID,
		})
		.setIssuer(env.BQ_CLIENT_EMAIL)
		.setSubject(env.BQ_CLIENT_EMAIL)
		.setAudience(audience)
		.setExpirationTime(expiryAt)
		.setIssuedAt()
		.sign(privateKey);
};

const queryBQ = async (bgJWT, path) => {
	const bqEndpoint = `https://bigquery.googleapis.com${path}`;
	const query = "SELECT text FROM hn.news_sampled LIMIT 3";
	const response = await fetch(bqEndpoint, {
		method: "POST",
		body: JSON.stringify({
			query: query,
		}),
		headers: {
			Authorization: `Bearer ${bgJWT}`,
		},
	});
	return response.json();
};

const formatRows = (rowsWithoutFieldNames, fields) => {
	// Index to fieldName
	const fieldsByIndex = new Map();

	fields.forEach((field, index) => {
		fieldsByIndex.set(index, field.name);
	});

	const rowsWithFieldNames = rowsWithoutFieldNames.map((row) => {
		// Map rows into an array of objects with field names
		let newRow = {};
		row.f.forEach((field, index) => {
			const fieldName = fieldsByIndex.get(index);
			if (fieldName) {
				newRow = { ...newRow, [fieldName]: field.v };
			}
		});
		return newRow;
	});

	return rowsWithFieldNames;
};

const generateTags = (data, env) => {
	return env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
		prompt: `Create three one-word tags for the following text. return only these three tags separated by a comma. don't return text that is not a category.Lowercase only. ${JSON.stringify(data)}`,
	});
};

const generateSentimentScore = (data, env) => {
	return env.AI.run("@cf/meta/llama-3.1-8b-instruct", {
		prompt: `return a float number between 0 and 1 measuring the sentiment of the following text. 0 being negative and 1 positive. return only the number, no text. ${JSON.stringify(data)}`,
	});
};

const getAIGeneratedContent = (data, env, aiHandler) => {
	let results = data?.map((dataPoint) => {
		return aiHandler(dataPoint, env);
	});
	return Promise.all(results);
};

export default {
	async fetch(request, env, ctx) {
		// Create JWT to authenticate the BigQuery API call
		let bqJWT;
		try {
			bqJWT = await generateBQJWT(env);
		} catch (error) {
			console.log(error);
			return new Response("An error has occurred while generating the JWT", {
				status: 500,
			});
		}

		// Fetch results from BigQuery
		let ticketInfo;
		try {
			ticketInfo = await queryBQ(
				bqJWT,
				`/bigquery/v2/projects/${env.BQ_PROJECT_ID}/queries`,
			);
		} catch (error) {
			console.log(error);
			return new Response("An error has occurred while querying BQ", {
				status: 500,
			});
		}

		// Transform output format into array of objects with named fields
		let formattedResults;
		if ("rows" in ticketInfo) {
			formattedResults = formatRows(ticketInfo.rows, ticketInfo.schema.fields);
		} else if ("error" in ticketInfo) {
			return new Response(ticketInfo.error.message, { status: 500 });
		}

		// Generate AI summaries and sentiment scores
		let summaries, sentimentScores;
		try {
			summaries = await getAIGeneratedContent(
				formattedResults,
				env,
				generateTags,
			);
			sentimentScores = await getAIGeneratedContent(
				formattedResults,
				env,
				generateSentimentScore,
			);
		} catch {
			return new Response(
				"There was an error while generating the text summaries or sentiment scores",
			);
		}

		// Add AI summaries and sentiment scores to previous results
		formattedResults = formattedResults?.map((formattedResult, i) => {
			if (sentimentScores[i].response && summaries[i].response) {
				return {
					...formattedResult,
					sentiment: parseFloat(sentimentScores[i].response).toFixed(2),
					tags: summaries[i].response.split(",").map((result) => result.trim()),
				};
			}
		});

		const response = { data: formattedResults };

		return new Response(JSON.stringify(response), {
			headers: { "Content-Type": "application/json" },
		});
	},
};
```

If you wish to deploy this Worker, you can do so by running `npx wrangler deploy`:

```sh
Total Upload: <size_of_your_worker> KiB / gzip: <compressed_size_of_your_worker> KiB
Uploaded <name_of_your_worker> (x sec)
Deployed <name_of_your_worker> triggers (x sec)
  https://<your_public_worker_endpoint>
Current Version ID: <worker_script_version_id>
```

This will create a public endpoint that you can use to access the Worker globally. Please keep this in mind when using production data, and make sure to include additional access controls in place.

## Conclusion

In this tutorial, you have learnt how to integrate Google BigQuery and Cloudflare Workers by creating a GCP service account key and storing part of it as Worker secrets. This was later imported in the code, and by using the `jose` npm library, you created a JSON Web Token to authenticate the API query to BigQuery.

Once you obtained the results, you formatted them to pass to generative AI models via Workers AI to generate tags and to perform sentiment analysis on the extracted data.

## Next Steps

If, instead of displaying the results of ingesting the data to the AI model in a browser, your workflow requires fetching and store data (for example in [R2](https://developers.cloudflare.com/r2/) or [D1](https://developers.cloudflare.com/d1/)) on regular intervals, you may want to consider adding a [scheduled handler](https://developers.cloudflare.com/workers/runtime-apis/handlers/scheduled/) for this Worker. This enables you to trigger the Worker with a predefined cadence via a [Cron Trigger](https://developers.cloudflare.com/workers/configuration/cron-triggers/). Consider reviewing the Reference Architecture Diagrams on [Ingesting BigQuery Data into Workers AI](https://developers.cloudflare.com/reference-architecture/diagrams/ai/bigquery-workers-ai/).

A use case to ingest data from other sources, like you did in this tutorial, is to create a RAG system. If this sounds relevant to you, please check out the [Build a Retrieval Augmented Generation (RAG) AI tutorial](https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/).

To learn more about what other AI models you can use at Cloudflare, please visit the [Workers AI](https://developers.cloudflare.com/workers-ai) section of our docs.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/guides/tutorials/using-bigquery-with-workers-ai/#page","headline":"Using BigQuery with Workers AI","description":"Learn how to ingest data stored outside of Cloudflare as an input to Workers AI models.","url":"https://developers.cloudflare.com/workers-ai/guides/tutorials/using-bigquery-with-workers-ai/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/guides/tutorials/using-bigquery-with-workers-ai/og.png?v=3ee0e03210117266","dateModified":"2026-01-29","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI","JavaScript"]}
```

---

---
description: Observe and control your AI applications with analytics, caching, rate limiting, and model fallback through AI Gateway.
title: Cloudflare AI Gateway
image: https://developers.cloudflare.com/ai-gateway/og.png?v=d9b4c0d9dbab4986
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/ai-gateway/llms.txt  
> Use this file to discover all available pages before exploring further.

# Cloudflare AI Gateway

Last updated Nov 4, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/ai-gateway/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Observe and control your AI applications.

Available on all plans

Cloudflare's AI Gateway allows you to gain visibility and control over your AI apps. By connecting your apps to AI Gateway, you can gather insights on how people are using your application with analytics and logging and then control how your application scales with features such as caching, rate limiting, as well as request retries, model fallback, and more. Better yet - it only takes one line of code to get started.

Check out the [Get started guide](https://developers.cloudflare.com/ai-gateway/get-started/) to learn how to configure your applications with AI Gateway.

## Features

[Models](https://developers.cloudflare.com/ai/models/)

Explore all AI models available through AI Gateway, including OpenAI, Anthropic, Google, and more.

Browse models

[Analytics](https://developers.cloudflare.com/ai-gateway/observability/analytics/)

View metrics such as the number of requests, tokens, and the cost it takes to run your application.

View Analytics

[Logging](https://developers.cloudflare.com/ai-gateway/observability/logging/)

Gain insight on requests and errors.

View Logging

[Caching](https://developers.cloudflare.com/ai-gateway/features/caching/)

Serve requests directly from Cloudflare's cache instead of the original model provider for faster requests and cost savings.

Use Caching

[Rate limiting](https://developers.cloudflare.com/ai-gateway/features/rate-limiting/)

Control how your application scales by limiting the number of requests your application receives.

Use Rate limiting

[Routing](https://developers.cloudflare.com/ai-gateway/features/routing/)

Choose models and fallbacks with model aliases, or build conditional flows with dynamic routes.

Use Routing

[Your favorite providers](https://developers.cloudflare.com/ai-gateway/usage/providers/)

Workers AI, Anthropic, Google Gemini, OpenAI, Replicate, and more work with AI Gateway.

Use Your favorite providers

---

## Related products

[Workers AI](https://developers.cloudflare.com/workers-ai/)

Run machine learning models, powered by serverless GPUs, on Cloudflare’s global network.

[Vectorize](https://developers.cloudflare.com/vectorize/)

Build full-stack AI applications with Vectorize, Cloudflare's vector database. Adding Vectorize enables you to perform tasks such as semantic search, recommendations, anomaly detection or can be used to provide context and memory to an LLM.

## More resources

### [Developer Discord](https://discord.cloudflare.com)

Connect with the Workers community on Discord to ask questions, show what you are building, and discuss the platform with other developers.

### [Use cases](https://developers.cloudflare.com/use-cases/ai/)

Learn how you can build and deploy ambitious AI applications to Cloudflare's global network.

### [@CloudflareDev](https://x.com/cloudflaredev)

Follow @CloudflareDev on Twitter to learn about product announcements, and what is new in Cloudflare Workers.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/ai-gateway/#page","headline":"Cloudflare AI Gateway","description":"Observe and control your AI applications with analytics, caching, rate limiting, and model fallback through AI Gateway.","url":"https://developers.cloudflare.com/ai-gateway/","inLanguage":"en","image":"https://developers.cloudflare.com/ai-gateway/og.png?v=d9b4c0d9dbab4986","dateModified":"2026-11-04","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
description: How Cloudflare handles your data, inputs, and outputs when using Workers AI.
title: Data usage
image: https://developers.cloudflare.com/workers-ai/platform/data-usage/og.png?v=6011ae828b9cf78a
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Data usage

Last updated Oct 16, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/platform/data-usage/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Cloudflare processes certain customer data to provide Workers AI, subject to our [Privacy Policy ↗︎](https://www.cloudflare.com/privacypolicy/) and, as applicable, our [Self-Serve Subscription Agreement ↗︎](https://www.cloudflare.com/terms/) or [Enterprise Subscription Agreement ↗︎](https://www.cloudflare.com/enterpriseterms/) ("Agreements").

Your inputs (for example, text prompts, images, and audio), outputs (for example, generated text, images, and translations), embeddings, and any training or adaptation data you provide are **Customer Content** as that term is defined in our Agreements.

This page applies to Workers AI. If you use AI Gateway to send Customer Content to another AI provider or connect Workers AI to another third-party service, that provider or service may process and retain the content under its own terms and policies.

## Our commitments for Customer Content

**Zero data retention:** Workers AI processes Customer Content only for as long as needed to provide the service. For standard inference requests that do not invoke a stateful feature, Cloudflare does not retain inputs or outputs after they are no longer needed to process the request and deliver the response, subject to the limited exceptions below.

**No training:** Cloudflare does not use Customer Content processed by Workers AI to train AI models.

**Your content remains yours:** You own, and are responsible for, your Customer Content. Cloudflare does not make it available to other Cloudflare customers.

## When a feature stores Customer Content

Some features require storage to work. Our zero data retention commitment does not prevent storage that you direct or that is necessary to provide a stateful feature you select.

For example, Customer Content may be stored when you:

- use a Cloudflare storage service, such as R2, KV, Durable Objects, or Vectorize, with Workers AI;
- enable logging or caching in AI Gateway or write Customer Content to application logs; or
- where offered, use an asynchronous or batch feature, upload files or adapters, or select another stateful feature that requires content to remain available while the feature operates.

In those cases, the applicable feature documentation, configuration, and retention lifecycle govern the stored content. Cloudflare retains that content only for as long as needed to provide the feature or as directed by you.

## Operational metadata

Cloudflare may retain operational metadata needed to operate, secure, support, and bill for Workers AI. This may include account and model identifiers, timestamps, request and response sizes, token or neuron counts, latency, request source, and normalized status or error codes. Operational metadata retained under this section does not include Customer Content. For more information on the information we may collect, see the Cloudflare Privacy Policy.

## Safety, security, and legal exceptions

To the extent Cloudflare must analyze or retain Customer Content to fulfill our legal obligations or commitments, as described in our Agreements or our Privacy Policy, such Customer Content is not used to train AI models or improve Cloudflare or third-party products or services.

## Models available through Workers AI

Cloudflare does not create or train the third-party AI models made available through Workers AI. Those models may be subject to open source, acceptable use policies, or other license terms between you and the model provider. Review the license terms applicable to each model.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/platform/data-usage/#page","headline":"Data usage","description":"How Cloudflare handles your data, inputs, and outputs when using Workers AI.","url":"https://developers.cloudflare.com/workers-ai/platform/data-usage/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/platform/data-usage/og.png?v=6011ae828b9cf78a","dateModified":"2026-10-16","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Reference table of Workers AI error codes, HTTP statuses, and descriptions.
title: Errors
image: https://developers.cloudflare.com/workers-ai/platform/errors/og.png?v=e1140cf7b8f4e385
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Errors

Last updated Nov 6, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/platform/errors/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Below is a list of Workers AI errors.

| **Name** | **Internal Code** | **HTTP Code** | **Description** |
| --- | --- | --- | --- |
| No such model | `5007` | `400` | No such model `${model}` or task |
| Invalid data | `5004` | `400` | Invalid data type for base64 input: `${type}` |
| Finetune missing required files | `3039` | `400` | Finetune is missing required files `(model.safetensors and config.json)` |
| Incomplete request | `3003` | `400` | Request is missing headers or body: `{what}` |
| Account not allowed for private model | `5018` | `403` | The account is not allowed to access this model |
| Model agreement | `5016` | `403` | User has not agreed to Llama3.2 model terms |
| Account blocked | `3023` | `403` | Service unavailable for account |
| Account not allowed for private model | `3041` | `403` | The account is not allowed to access this model |
| Model requires Workers Paid plan | `5035` | `403` | This model requires a Workers Paid plan. See [pricing](https://developers.cloudflare.com/workers-ai/platform/pricing/) for details. |
| Deprecated SDK version | `5019` | `405` | Request trying to use deprecated SDK version |
| LoRa unsupported | `5005` | `405` | The model `${this.model}` does not support LoRa inference |
| Invalid model ID | `3042` | `404` | The model name is invalid |
| Model deprecated | `5028` | `410` | `${model}` was deprecated on `${date}`. See the [model catalog](https://developers.cloudflare.com/workers-ai/models/) for alternatives. |
| Request too large | `3006` | `413` | Request is too large |
| Timeout | `3007` | `408` | Request timeout |
| Aborted | `3008` | `408` | Request was aborted |
| Account limited | `3036` | `429` | You have used up your daily free allocation of 10,000 neurons. Please upgrade to Cloudflare's Workers Paid plan if you would like to continue usage. |
| Out of capacity | `3040` | `429` | `Capacity temporarily exceeded, please try again.` Also returned when `rejectIfBusy` rejects a request because capacity is unavailable. |

Errors from AI Gateway

If you call a model through [AI Gateway](https://developers.cloudflare.com/ai-gateway/), errors can come back as `AiGatewayError: <CODE>: <MESSAGE>`. This applies, for example, when you use `env.AI.run()` with a `gateway` option or call a third-party model. For these codes, refer to [AI Gateway troubleshooting](https://developers.cloudflare.com/ai-gateway/reference/troubleshooting/). For example, for `AiGatewayError: 7003: User Input Error`, refer to [400: Bad request (7003)](https://developers.cloudflare.com/ai-gateway/reference/troubleshooting/#400-bad-request-7003).

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/platform/errors/#page","headline":"Errors","description":"Reference table of Workers AI error codes, HTTP statuses, and descriptions.","url":"https://developers.cloudflare.com/workers-ai/platform/errors/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/platform/errors/og.png?v=e1140cf7b8f4e385","dateModified":"2026-11-06","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Subscribe to Workers AI events using Cloudflare Queues for asynchronous processing.
title: Event subscriptions
image: https://developers.cloudflare.com/workers-ai/platform/event-subscriptions/og.png?v=4fd1e3d1c5dd0b60
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Event subscriptions

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/platform/event-subscriptions/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

[Event subscriptions](https://developers.cloudflare.com/queues/event-subscriptions/) allow you to receive messages when events occur across your Cloudflare account. Cloudflare products (e.g., [KV](https://developers.cloudflare.com/kv/), [Workers AI](https://developers.cloudflare.com/workers-ai/), [Workers](https://developers.cloudflare.com/workers/)) can publish structured events to a [queue](https://developers.cloudflare.com/queues/), which you can then consume with Workers or [HTTP pull consumers](https://developers.cloudflare.com/queues/configuration/pull-consumers/) to build custom workflows, integrations, or logic.

For more information on [Event Subscriptions](https://developers.cloudflare.com/queues/event-subscriptions/), refer to the [management guide](https://developers.cloudflare.com/queues/event-subscriptions/manage-event-subscriptions/).

## Available Workers AI events

#### `batch.queued`

Triggered when a batch request is queued.

**Example:**

```json
{
  "type": "cf.workersAi.model.batch.queued",
  "source": {
    "type": "workersAi.model",
    "modelName": "@cf/baai/bge-base-en-v1.5"
  },
  "payload": {
    "requestId": "req-12345678-90ab-cdef-1234-567890abcdef"
  },
  "metadata": {
    "accountId": "f9f79265f388666de8122cfb508d7776",
    "eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
    "eventSchemaVersion": 1,
    "eventTimestamp": "2025-05-01T02:48:57.132Z"
  }
}
```

#### `batch.succeeded`

Triggered when a batch request has completed.

**Example:**

```json
{
  "type": "cf.workersAi.model.batch.succeeded",
  "source": {
    "type": "workersAi.model",
    "modelName": "@cf/baai/bge-base-en-v1.5"
  },
  "payload": {
    "requestId": "req-12345678-90ab-cdef-1234-567890abcdef"
  },
  "metadata": {
    "accountId": "f9f79265f388666de8122cfb508d7776",
    "eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
    "eventSchemaVersion": 1,
    "eventTimestamp": "2025-05-01T02:48:57.132Z"
  }
}
```

#### `batch.failed`

Triggered when a batch request has failed.

**Example:**

```json
{
  "type": "cf.workersAi.model.batch.failed",
  "source": {
    "type": "workersAi.model",
    "modelName": "@cf/baai/bge-base-en-v1.5"
  },
  "payload": {
    "requestId": "req-12345678-90ab-cdef-1234-567890abcdef",
    "message": "Model execution failed",
    "internalCode": 5001,
    "httpCode": 500
  },
  "metadata": {
    "accountId": "f9f79265f388666de8122cfb508d7776",
    "eventSubscriptionId": "1830c4bb612e43c3af7f4cada31fbf3f",
    "eventSchemaVersion": 1,
    "eventTimestamp": "2025-05-01T02:48:57.132Z"
  }
}
```

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/platform/event-subscriptions/#page","headline":"Event subscriptions","description":"Subscribe to Workers AI events using Cloudflare Queues for asynchronous processing.","url":"https://developers.cloudflare.com/workers-ai/platform/event-subscriptions/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/platform/event-subscriptions/og.png?v=4fd1e3d1c5dd0b60","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Definitions of key terms used in the Workers AI documentation.
title: Glossary
image: https://developers.cloudflare.com/workers-ai/platform/glossary/og.png?v=2fe508f8c458e5dc
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Glossary

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/platform/glossary/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Review the definitions for terms used across Cloudflare's Workers AI documentation.

| Term | Definition |
| --- | --- |
| AI models | [An AI model](https://developers.cloudflare.com/workers-ai/models) is a trained system that processes input data to generate predictions, decisions, or outputs based on patterns it has learned. |
| API Tokens | [API Tokens](https://developers.cloudflare.com/workers-ai/get-started/rest-api/) are authentication credentials used to securely access and manage Workers AI resources via the REST API. |
| Cloudflare Dashboard | [Cloudflare Dashboard](https://developers.cloudflare.com/workers-ai/get-started/dashboard/) is a web-based interface that allows users to manage Workers AI services, including model deployment and monitoring. |
| Context Window | In generative AI, the context window is the sum of the number of input, reasoning, and completion or response tokens a model supports. You can find the context window limit on each [model page](https://developers.cloudflare.com/workers-ai/models/). |
| D1 | [D1](https://developers.cloudflare.com/d1/) is Cloudflare's managed, serverless database with SQLite's SQL semantics, built-in disaster recovery, and Worker and HTTP API access. |
| Environment Variables | [Environment Variables](https://developers.cloudflare.com/workers-ai/configuration/bindings/) are dynamic values that can be used within Workers to manage configuration settings, including those related to AI integrations. |
| Fine-Tuning | [Fine-Tuning](https://developers.cloudflare.com/workers-ai/fine-tunes/) is a general term for modifying an AI model by continuing to train it with additional data. |
| Function Calling | [Function Calling](https://developers.cloudflare.com/workers-ai/function-calling/) enables people to take Large Language Models (LLMs) and use the model response to execute functions or interact with external APIs. |
| Inference | [Inference](https://developers.cloudflare.com/workers-ai/fine-tunes/public-loras/#running-inference-with-public-loras) refers to the process of using a trained machine learning model to make predictions or generate outputs based on new data. |
| LoRA Adapters | [LoRA Adapters](https://developers.cloudflare.com/workers-ai/fine-tunes/loras/) (Low-Rank Adaptation adapters) are used in machine learning to fine-tune models efficiently by adjusting a small number of parameters, allowing for customization of AI models in Workers AI. [Public LoRA Adapters](https://developers.cloudflare.com/workers-ai/fine-tunes/public-loras/) are pre-trained Low-Rank Adaptation adapters available for public use. |
| Maximum Tokens | In generative AI, the user-defined property `max_tokens` defines the maximum number of tokens at which the model should stop responding. This limit cannot exceed the context window. |
| Model Catalog | [Model Catalog](https://developers.cloudflare.com/workers-ai/models/) is a curated collection of AI models available within Workers AI, providing developers with a variety of pre-trained models for different tasks. |
| Prompt Engineering | [Prompt Engineering](https://developers.cloudflare.com/workers-ai/guides/prompting/) is the practice of designing and refining input prompts to effectively elicit desired responses from AI models. |
| Prompt Templates | [Prompt Templates](https://developers.cloudflare.com/workers-ai/guides/prompting/) are predefined structures that guide the input provided to AI models, enhancing consistency and effectiveness in responses. |
| REST API | [REST API](https://developers.cloudflare.com/workers-ai/get-started/rest-api/) is an application programming interface that allows developers to interact with Workers AI services over HTTP, enabling model management and inference requests. |
| Serverless GPUs | [Serverless GPUs](https://developers.cloudflare.com/workers-ai/) are graphics processing units provided by Cloudflare in a serverless environment, enabling scalable and efficient execution of machine learning models without the need for managing underlying hardware. |
| Worker Bindings | [Worker Bindings](https://developers.cloudflare.com/workers-ai/configuration/bindings/) are configurations that connect Workers scripts to external resources, such as AI models, enabling seamless integration and functionality. |
| Workers AI | [Workers AI](https://developers.cloudflare.com/workers-ai/) is a Cloudflare service that enables running machine learning models on Cloudflare's global network, utilizing serverless GPUs. It allows developers to integrate AI capabilities into their applications using Workers, Pages, or via the REST API. |
| Workers KV | [Workers KV](https://developers.cloudflare.com/kv/)is a data storage that allows you to store and retrieve data globally. |
| Wrangler CLI | [Wrangler CLI](https://developers.cloudflare.com/workers-ai/get-started/workers-wrangler/) is a command-line tool for building and deploying Cloudflare Workers, facilitating the integration of AI models into applications. |

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/platform/glossary/#page","headline":"Glossary","description":"Definitions of key terms used in the Workers AI documentation.","url":"https://developers.cloudflare.com/workers-ai/platform/glossary/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/platform/glossary/og.png?v=2fe508f8c458e5dc","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Rate limits for Workers AI inference requests, organized by task type and model.
title: Limits
image: https://developers.cloudflare.com/workers-ai/platform/limits/og.png?v=f48e357380e3ed94
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Limits

Last updated Sep 17, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/platform/limits/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Workers AI is now Generally Available. We've updated our rate limits to reflect this.

Note that model inferences in local mode using Wrangler will also count towards these limits. Beta models may have lower rate limits while we work on performance and scale.

Custom requirements

If you have custom requirements like private custom models or higher limits, complete the [Custom Requirements Form ↗︎](https://forms.gle/axnnpGDb6xrmR31T6). Cloudflare will contact you with next steps.

Rate limits are default per task type, with some per-model limits defined as follows:

## Rate limits by task type

### [Automatic Speech Recognition](https://developers.cloudflare.com/workers-ai/models/)

- 720 requests per minute

### [Image Classification](https://developers.cloudflare.com/workers-ai/models/)

- 3000 requests per minute

### [Image-to-Text](https://developers.cloudflare.com/workers-ai/models/)

- 720 requests per minute

### [Object Detection](https://developers.cloudflare.com/workers-ai/models/)

- 3000 requests per minute

### [Summarization](https://developers.cloudflare.com/workers-ai/models/)

- 1500 requests per minute

### [Text Classification](https://developers.cloudflare.com/workers-ai/models/)

- 2000 requests per minute

### [Text Embeddings](https://developers.cloudflare.com/workers-ai/models/)

- 3000 requests per minute
- [@cf/baai/bge-large-en-v1.5](https://developers.cloudflare.com/workers-ai/models/bge-large-en-v1.5/) is 1500 requests per minute

### [Text Generation](https://developers.cloudflare.com/workers-ai/models/)

- 300 requests per minute, unless the model requires the Workers Paid plan

#### Paid models

The following limits apply per account, per model to any model that requires the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) — each model page states whether it does. These models are the only models that do not receive the default limit:

| Billing | Rate limit |
| --- | --- |
| Standard Workers AI billing | 20 requests per minute |
| Prepaid AI Gateway credits | 50 requests per minute |

To receive the elevated limit, load [prepaid AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/) and set the gateway's [Workers AI billing setting](https://developers.cloudflare.com/ai-gateway/configuration/manage-gateway/#configure-workers-ai-billing) to **Unified billing**. These limits are designed for typical agentic and coding workloads, where requests to frontier models can take longer to complete.

### [Text-to-Image](https://developers.cloudflare.com/workers-ai/models/)

- 720 requests per minute
- [@cf/runwayml/stable-diffusion-v1-5-img2img](https://developers.cloudflare.com/workers-ai/models/stable-diffusion-v1-5-img2img/) is 1500 requests per minute

### [Translation](https://developers.cloudflare.com/workers-ai/models/)

- 720 requests per minute

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/platform/limits/#page","headline":"Limits","description":"Rate limits for Workers AI inference requests, organized by task type and model.","url":"https://developers.cloudflare.com/workers-ai/platform/limits/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/platform/limits/og.png?v=f48e357380e3ed94","dateModified":"2026-09-17","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Workers AI pricing is based on Neurons, with a free daily allocation and per-model rates.
title: Pricing
image: https://developers.cloudflare.com/workers-ai/platform/pricing/og.png?v=c0f09dd6cf3238d9
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Pricing

Last updated Oct 20, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/platform/pricing/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Note

Workers AI has updated pricing to be more granular, with per-model unit-based pricing presented, but still billing in neurons in the back end.

Workers AI is included in both the [Free and Paid Workers plans](https://developers.cloudflare.com/workers/platform/pricing/) and is priced at **$0.011 per 1,000 Neurons**.

Our free allocation allows anyone to use a total of **10,000 Neurons per day at no charge**. To use more than 10,000 Neurons per day, you need to sign up for the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers). On Workers Paid, you will be charged at $0.011 / 1,000 Neurons for any usage above the free allocation of 10,000 Neurons per day.

You can monitor your Neuron usage in the [Cloudflare Workers AI dashboard ↗︎](https://dash.cloudflare.com/?to=/:account/ai/workers-ai).

All limits reset daily at 00:00 UTC. If you exceed any one of the above limits, further operations will fail with an error.

|  | Free <br> allocation | Pricing |
| --- | --- | --- |
| Workers Free | 10,000 Neurons per day | N/A - Upgrade to Workers Paid |
| Workers Paid | 10,000 Neurons per day | $0.011 / 1,000 Neurons |

Note

Some models require a paid billing method. This applies to `@cf/moonshotai/kimi-k2.6`, `@cf/moonshotai/kimi-k2.7-code`, `@cf/zai-org/glm-5.2`, `@cf/zai-org/glm-5.3`, `@cf/zai-org/glm-5.3-flash`, `@cf/deepseek-ai/deepseek-v4-flash-0731`, `@cf/deepseek-ai/deepseek-v4.1-flash-1017`, and `@cf/deepseek-ai/deepseek-v4-pro-0813`. You can access these models with either the [Workers Paid plan](https://developers.cloudflare.com/workers/platform/pricing/#workers) or prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/).

## Pay with AI Gateway credits

You can use prepaid [AI Gateway credits](https://developers.cloudflare.com/ai-gateway/features/unified-billing/) to pay for Workers AI inference. Set the gateway's [Workers AI billing setting](https://developers.cloudflare.com/ai-gateway/configuration/manage-gateway/#configure-workers-ai-billing) to **Unified billing**, then specify that gateway in the [AI binding](https://developers.cloudflare.com/ai-gateway/usage/worker-binding-methods/) or REST API request.

Requests to frontier models that use prepaid credits receive [higher rate limits](https://developers.cloudflare.com/workers-ai/platform/limits/#paid-models).

## What are Neurons?

Neurons are our way of measuring AI outputs across different models, representing the GPU compute needed to perform your request. Our serverless model allows you to pay only for what you use without having to worry about renting, managing, or scaling GPUs.

Note

The Price in Tokens column is equivalent to the Price in Neurons column - the different units are displayed so you can easily compare and understand pricing.

## LLM model pricing

| Model | Price in Tokens | Price in Neurons |
| --- | --- | --- |
| @cf/meta/llama-3.2-1b-instruct | $0.027 per M input tokens <br> $0.201 per M output tokens | 2457 neurons per M input tokens <br> 18252 neurons per M output tokens |
| @cf/meta/llama-3.2-3b-instruct | $0.051 per M input tokens <br> $0.335 per M output tokens | 4625 neurons per M input tokens <br> 30475 neurons per M output tokens |
| @cf/meta/llama-3.1-8b-instruct-fp8-fast | $0.045 per M input tokens <br> $0.384 per M output tokens | 4119 neurons per M input tokens <br> 34868 neurons per M output tokens |
| @cf/meta/llama-3.2-11b-vision-instruct | $0.049 per M input tokens <br> $0.676 per M output tokens | 4410 neurons per M input tokens <br> 61493 neurons per M output tokens |
| @cf/meta/llama-3.1-70b-instruct-fp8-fast | $0.293 per M input tokens <br> $2.253 per M output tokens | 26668 neurons per M input tokens <br> 204805 neurons per M output tokens |
| @cf/meta/llama-3.3-70b-instruct-fp8-fast | $0.293 per M input tokens <br> $2.253 per M output tokens | 26668 neurons per M input tokens <br> 204805 neurons per M output tokens |
| @cf/deepseek-ai/deepseek-r1-distill-qwen-32b | $0.497 per M input tokens <br> $4.881 per M output tokens | 45170 neurons per M input tokens <br> 443756 neurons per M output tokens |
| @cf/deepseek-ai/deepseek-v4-flash-0731 | $0.440 per M input tokens <br> $0.014 per M cached input tokens <br> $1.320 per M output tokens | 40000 neurons per M input tokens <br> 1273 neurons per M cached input tokens <br> 120000 neurons per M output tokens |
| @cf/deepseek-ai/deepseek-v4.1-flash-1017 | $0.300 per M input tokens <br> $0.006 per M cached input tokens <br> $1.200 per M output tokens | 27273 neurons per M input tokens <br> 545 neurons per M cached input tokens <br> 109091 neurons per M output tokens |
| @cf/deepseek-ai/deepseek-v4-pro-0813 | $1.320 per M input tokens <br> $0.044 per M cached input tokens <br> $3.960 per M output tokens | 120000 neurons per M input tokens <br> 4000 neurons per M cached input tokens <br> 360000 neurons per M output tokens |
| @cf/mistral/mistral-7b-instruct-v0.1 | $0.110 per M input tokens <br> $0.190 per M output tokens | 10000 neurons per M input tokens <br> 17300 neurons per M output tokens |
| @cf/mistralai/mistral-small-3.1-24b-instruct | $0.351 per M input tokens <br> $0.555 per M output tokens | 31876 neurons per M input tokens <br> 50488 neurons per M output tokens |
| @cf/meta/llama-3.1-8b-instruct | $0.282 per M input tokens <br> $0.827 per M output tokens | 25608 neurons per M input tokens <br> 75147 neurons per M output tokens |
| @cf/meta/llama-3.1-8b-instruct-fp8 | $0.152 per M input tokens <br> $0.287 per M output tokens | 13778 neurons per M input tokens <br> 26128 neurons per M output tokens |
| @cf/meta/llama-3.1-8b-instruct-awq | $0.123 per M input tokens <br> $0.266 per M output tokens | 11161 neurons per M input tokens <br> 24215 neurons per M output tokens |
| @cf/meta/llama-3-8b-instruct | $0.282 per M input tokens <br> $0.827 per M output tokens | 25608 neurons per M input tokens <br> 75147 neurons per M output tokens |
| @cf/meta/llama-3-8b-instruct-awq | $0.123 per M input tokens <br> $0.266 per M output tokens | 11161 neurons per M input tokens <br> 24215 neurons per M output tokens |
| @cf/meta/llama-2-7b-chat-fp16 | $0.556 per M input tokens <br> $6.667 per M output tokens | 50505 neurons per M input tokens <br> 606061 neurons per M output tokens |
| @cf/meta/llama-guard-3-8b | $0.484 per M input tokens <br> $0.030 per M output tokens | 44003 neurons per M input tokens <br> 2730 neurons per M output tokens |
| @cf/meta/llama-4-scout-17b-16e-instruct | $0.270 per M input tokens <br> $0.850 per M output tokens | 24545 neurons per M input tokens <br> 77273 neurons per M output tokens |
| @cf/google/gemma-3-12b-it | $0.345 per M input tokens <br> $0.556 per M output tokens | 31371 neurons per M input tokens <br> 50560 neurons per M output tokens |
| @cf/qwen/qwq-32b | $0.660 per M input tokens <br> $1.000 per M output tokens | 60000 neurons per M input tokens <br> 90909 neurons per M output tokens |
| @cf/qwen/qwen2.5-coder-32b-instruct | $0.660 per M input tokens <br> $1.000 per M output tokens | 60000 neurons per M input tokens <br> 90909 neurons per M output tokens |
| @cf/qwen/qwen3-30b-a3b-fp8 | $0.051 per M input tokens <br> $0.335 per M output tokens | 4625 neurons per M input tokens <br> 30475 neurons per M output tokens |
| @cf/qwen/qwen3.8-27b | $0.450 per M input tokens <br> $3.200 per M output tokens | 40909 neurons per M input tokens <br> 290909 neurons per M output tokens |
| @cf/openai/gpt-oss-120b | $0.350 per M input tokens <br> $0.750 per M output tokens | 31818 neurons per M input tokens <br> 68182 neurons per M output tokens |
| @cf/openai/gpt-oss-20b | $0.200 per M input tokens <br> $0.300 per M output tokens | 18182 neurons per M input tokens <br> 27273 neurons per M output tokens |
| @cf/aisingapore/gemma-sea-lion-v4-27b-it | $0.351 per M input tokens <br> $0.555 per M output tokens | 31876 neurons per M input tokens <br> 50488 neurons per M output tokens |
| @cf/ibm-granite/granite-4.0-h-micro | $0.017 per M input tokens <br> $0.112 per M output tokens | 1542 neurons per M input tokens <br> 10158 neurons per M output tokens |
| @cf/zai-org/glm-4.7-flash | $0.060 per M input tokens <br> $0.400 per M output tokens | 5500 neurons per M input tokens <br> 36400 neurons per M output tokens |
| @cf/zai-org/glm-5.2 | $1.400 per M input tokens <br> $0.260 per M cached input tokens <br> $4.400 per M output tokens | 127273 neurons per M input tokens <br> 23636 neurons per M cached input tokens <br> 400000 neurons per M output tokens |
| @cf/zai-org/glm-5.3 | $1.400 per M input tokens <br> $0.260 per M cached input tokens <br> $4.400 per M output tokens | 127273 neurons per M input tokens <br> 23636 neurons per M cached input tokens <br> 400000 neurons per M output tokens |
| @cf/zai-org/glm-5.3-flash | $0.150 per M input tokens <br> $0.030 per M cached input tokens <br> $0.500 per M output tokens | 13636 neurons per M input tokens <br> 2727 neurons per M cached input tokens <br> 45455 neurons per M output tokens |
| @cf/nvidia/nemotron-3-120b-a12b | $0.500 per M input tokens <br> $1.500 per M output tokens | 45455 neurons per M input tokens <br> 136364 neurons per M output tokens |
| @cf/moonshotai/kimi-k2.5 | $0.600 per M input tokens <br> $0.100 per M cached input tokens <br> $3.000 per M output tokens | 54545 neurons per M input tokens <br> 9091 neurons per M cached input tokens <br> 272727 neurons per M output tokens |
| @cf/moonshotai/kimi-k2.6 | $0.950 per M input tokens <br> $0.160 per M cached input tokens <br> $4.000 per M output tokens | 86364 neurons per M input tokens <br> 14545 neurons per M cached input tokens <br> 363636 neurons per M output tokens |
| @cf/moonshotai/kimi-k2.7-code | $0.950 per M input tokens <br> $0.190 per M cached input tokens <br> $4.000 per M output tokens | 86364 neurons per M input tokens <br> 17273 neurons per M cached input tokens <br> 363636 neurons per M output tokens |
| @cf/google/gemma-4-26b-a4b-it | $0.100 per M input tokens <br> $0.300 per M output tokens | 9091 neurons per M input tokens <br> 27273 neurons per M output tokens |
| @cf/daily-co/phonellm-mini-alpha-2 | $0.060 per M input tokens <br> $0.240 per M output tokens | 5455 neurons per M input tokens <br> 21818 neurons per M output tokens |

## Embeddings model pricing

| Model | Price in Tokens | Price in Neurons |
| --- | --- | --- |
| @cf/baai/bge-small-en-v1.5 | $0.020 per M input tokens | 1841 neurons per M input tokens |
| @cf/baai/bge-base-en-v1.5 | $0.067 per M input tokens | 6058 neurons per M input tokens |
| @cf/baai/bge-large-en-v1.5 | $0.204 per M input tokens | 18582 neurons per M input tokens |
| @cf/baai/bge-m3 | $0.012 per M input tokens | 1075 neurons per M input tokens |
| @cf/pfnet/plamo-embedding-1b | $0.019 per M input tokens | 1689 neurons per M input tokens |
| @cf/qwen/qwen3-embedding-0.6b | $0.012 per M input tokens | 1075 neurons per M input tokens |

## Image model pricing

| Model | Price in Tokens | Price in Neurons |
| --- | --- | --- |
| @cf/black-forest-labs/flux-1-schnell | $0.0000528 per 512x512 tile <br> $0.0001056 per step | 4.80 neurons per 512x512 tile <br> 9.60 neurons per step |
| @cf/leonardo/lucid-origin | $0.006996 per 512x512 tile <br> $0.000132 per step | 636.00 neurons per 512x512 tile <br> 12.00 neurons per step |
| @cf/leonardo/phoenix-1.0 | $0.005830 per 512x512 tile <br> $0.000110 per step | 530.00 neurons per 512x512 tile <br> 10.00 neurons per step |
| @cf/black-forest-labs/flux-2-dev | $0.00021 per input 512x512 tile, per step <br> $0.00041 per output 512x512 tile, per step | 18.75 neurons per input 512x512 tile, per step <br> 37.50 neurons per output 512x512 tile, per step |
| @cf/black-forest-labs/flux-2-klein-4b | $0.000059 per input 512x512 tile <br> $0.000287 per output 512x512 tile | 5.37 neurons per input 512x512 tile <br> 26.05 neurons per output 512x512 tile |
| @cf/black-forest-labs/flux-2-klein-9b | $0.015 per first MP (1024x1024) <br> $0.002 per subsequent MP <br> $0.002 per input image MP | 1363.64 neurons per first MP (1024x1024) <br> 181.82 neurons per subsequent MP <br> 181.82 neurons per input image MP |

## Audio model pricing

| Model | Price in Tokens | Price in Neurons |
| --- | --- | --- |
| @cf/openai/whisper | $0.0005 per audio minute | 41.14 neurons per audio minute |
| @cf/openai/whisper-large-v3-turbo | $0.0005 per audio minute | 46.63 neurons per audio minute |
| @cf/myshell-ai/melotts | $0.0002 per audio minute | 18.63 neurons per audio minute |
| @cf/deepgram/aura-1 | $0.015 per 1k characters input <br> | 1,363.64 neurons per 1k characters input <br> |
| @cf/deepgram/nova-3 | $0.0052 per audio minute input <br> | 472.73 neurons per audio minute input <br> |
| @cf/deepgram/nova-3 (WebSocket) | $0.0092 per audio minute input <br> | 836.36 neurons per audio minute input <br> |
| @cf/pipecat-ai/smart-turn-v2 | $0.00033795 per audio minute input <br> | 0.51 neurons per audio minute input <br> |
| @cf/deepgram/aura-2-en | $0.030 per 1k characters input <br> | 2727.27 neurons per 1k characters input <br> |
| @cf/deepgram/aura-2-es | $0.030 per 1k characters input <br> | 2727.27 neurons per 1k characters input <br> |
| @cf/deepgram/flux (WebSocket) | $0.0077 per audio minute <br> | 700.00 neurons per audio minute <br> |

## Other model pricing

| Model | Price in Tokens | Price in Neurons |
| --- | --- | --- |
| @cf/huggingface/distilbert-sst-2-int8 | $0.026 per M input tokens | 2394 neurons per M input tokens |
| @cf/baai/bge-reranker-base | $0.003 per M input tokens | 283 neurons per M input tokens |
| @cf/meta/m2m100-1.2b | $0.342 per M input tokens <br> $0.342 per M output tokens | 31050 neurons per M input tokens <br> 31050 neurons per M output tokens |
| @cf/microsoft/resnet-50 | $2.51 per M images | 228055 neurons per M images |
| @cf/ai4bharat/indictrans2-en-indic-1B | $0.342 per M input tokens <br> $0.342 per M output tokens | 31050 neurons per M input tokens <br> 31050 neurons per M output tokens |
| @cf/moondream/moondream3.1-9B-A2B | $0.300 per M input tokens <br> $1.000 per M output tokens | 27273 neurons per M input tokens <br> 90909 neurons per M output tokens |
| @cf/cloudflare/clef | $0.240 per M input tokens | 21818 neurons per M input tokens |
| @cf/cloudflare/clef-omni | $0.150 per M input tokens | 13636 neurons per M input tokens |
| @cf/cloudflare/clef-flash | $0.038 per M input tokens | 3455 neurons per M input tokens |
| @cf/cloudflare/clairic | $0.100 per M input tokens | 9091 neurons per M input tokens |

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers-ai/platform/pricing/#page","headline":"Pricing","description":"Workers AI pricing is based on Neurons, with a free daily allocation and per-model rates.","url":"https://developers.cloudflare.com/workers-ai/platform/pricing/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/platform/pricing/og.png?v=c0f09dd6cf3238d9","dateModified":"2026-10-20","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Storage and database options available on Cloudflare's developer platform.
title: Choose a data or storage product
image: https://developers.cloudflare.com/workers/platform/storage-options/og.png?v=abca508978294b6c
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt  
> Use this file to discover all available pages before exploring further.

# Choose a data or storage product

Last updated Oct 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers/platform/storage-options/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

This guide describes the storage & database products available as part of Cloudflare Workers, including recommended use-cases and best practices.

## Choose a storage product

The following table maps our storage & database products to common industry terms as well as recommended use-cases:

| Use-case | Product | Ideal for |
| --- | --- | --- |
| Key-value storage | [Workers KV](https://developers.cloudflare.com/kv/) | Configuration data, service routing metadata, personalization (A/B testing) |
| Object storage / blob storage | [R2](https://developers.cloudflare.com/r2/) | User-facing web assets, images, machine learning and training datasets, analytics datasets, log and event data. |
| Accelerate a Postgres or MySQL database | [Hyperdrive](https://developers.cloudflare.com/hyperdrive/) | Connecting to an existing database in a cloud or on-premises using your existing database drivers & ORMs. |
| Global coordination & stateful serverless | [Durable Objects](https://developers.cloudflare.com/durable-objects/) | Building collaborative applications; global coordination across clients; real-time WebSocket applications; strongly consistent, transactional storage. |
| Lightweight SQL database | [D1](https://developers.cloudflare.com/d1/) | Relational data, including user profiles, product listings and orders, and/or customer data. |
| Task processing, batching and messaging | [Queues](https://developers.cloudflare.com/queues/) | Background job processing (emails, notifications, APIs), message queuing, and deferred tasks. |
| Event streaming | [K2](https://developers.cloudflare.com/k2/) | High-volume event data read by multiple independent consumers, such as alerting, archiving, and building machine learning features; replaying retained events. |
| Vector search & embeddings queries | [Vectorize](https://developers.cloudflare.com/vectorize/) | Storing [embeddings](https://developers.cloudflare.com/workers-ai/models/?tasks=Text+Embeddings) from AI models for semantic search and classification tasks. |
| Streaming ingestion | [Basin Pipelines](https://developers.cloudflare.com/basin-pipelines/) | Streaming data ingestion and processing, including clickstream analytics, telemetry/log data, and structured data for querying |
| Time-series metrics | [Analytics Engine](https://developers.cloudflare.com/analytics/analytics-engine/) | Write and query high-cardinality time-series data, usage metrics, and service-level telemetry using Workers and/or SQL. |

Applications can build on multiple storage & database products: for example, using Workers KV for session data; R2 for large file storage, media assets and user-uploaded files; and Hyperdrive to connect to a hosted Postgres or MySQL database.

Pages Functions

Storage options can also be used by your front-end application built with Cloudflare Pages. For more information on available storage options for Pages applications, refer to the [Pages Functions bindings documentation](https://developers.cloudflare.com/pages/functions/bindings/).

## SQL database options

There are three options for SQL-based databases available when building applications with Workers.

- **Hyperdrive** if you have an existing Postgres or MySQL database, require large (1TB, 100TB or more) single databases, and/or want to use your existing database tools. You can also connect Hyperdrive to database platforms like [PlanetScale ↗︎](https://planetscale.com/), [Neon ↗︎](https://neon.tech/), or [Supabase ↗︎](https://supabase.com).
- **D1** for lightweight, serverless applications that are read-heavy, have global users that benefit from D1's [read replication](https://developers.cloudflare.com/d1/best-practices/read-replication/), and do not require you to manage and maintain a traditional RDBMS.
- **Durable Objects** for stateful serverless workloads, per-user or per-customer SQL state, and building distributed systems (D1 and Queues are built on Durable Objects) where Durable Object's [strict serializability ↗︎](https://blog.cloudflare.com/durable-objects-easy-fast-correct-choose-three/) enables global ordering of requests and storage operations.

### Session storage

We recommend using [Workers KV](https://developers.cloudflare.com/kv/) for storing session data, credentials (API keys), and/or configuration data. These are typically read at high rates (thousands of RPS or more), are not typically modified (within KV's 1 write RPS per unique key limit), and do not need to be immediately consistent.

Frequently read keys benefit from KV's [internal cache](https://developers.cloudflare.com/kv/concepts/how-kv-works/), and repeated reads to these "hot" keys will typically see latencies in the 500µs to 10ms range.

Authentication frameworks like [OpenAuth ↗︎](https://openauth.js.org/docs/storage/cloudflare/) use Workers KV as session storage when deployed to Cloudflare, and [Cloudflare Access](https://developers.cloudflare.com/cloudflare-one/access-controls/policies/) uses KV to securely store and distribute user credentials so that they can be validated as close to the user as possible and reduce overall latency.

## Product overviews

### Workers KV

Workers KV is an eventually consistent key-value data store that caches on the Cloudflare global network.

It is ideal for projects that require:

- High volumes of reads and/or repeated reads to the same keys.
- Low-latency global reads (typically within 10ms for hot keys)
- Per-object time-to-live (TTL).
- Distributed configuration and/or session storage.

To get started with KV:

- Read how [KV works](https://developers.cloudflare.com/kv/concepts/how-kv-works/).
- Create a [KV namespace](https://developers.cloudflare.com/kv/concepts/kv-namespaces/).
- Review the [KV Runtime API](https://developers.cloudflare.com/kv/api/).
- Learn about KV [Limits](https://developers.cloudflare.com/kv/platform/limits/).

### R2

R2 is S3-compatible blob storage that allows developers to store large amounts of unstructured data without egress fees associated with typical cloud storage services.

It is ideal for projects that require:

- Storage for files which are infrequently accessed.
- Large object storage (for example, gigabytes or more per object).
- Strong consistency per object.
- Asset storage for websites (refer to [caching guide](https://developers.cloudflare.com/r2/buckets/public-buckets/#caching))

To get started with R2:

- Read the [Get started guide](https://developers.cloudflare.com/r2/get-started/).
- Learn about R2 [Limits](https://developers.cloudflare.com/r2/platform/limits/).
- Review the [R2 Workers API](https://developers.cloudflare.com/r2/api/workers/workers-api-reference/).

### Durable Objects

Durable Objects provide low-latency coordination and consistent storage for the Workers platform through global uniqueness and a transactional storage API.

- Global Uniqueness guarantees that there will be a single instance of a Durable Object class with a given ID running at once, across the world. Requests for a Durable Object ID are routed by the Workers runtime to the Cloudflare data center that owns the Durable Object.
- The transactional storage API provides strongly consistent key-value storage to the Durable Object. Each Object can only read and modify keys associated with that Object. Execution of a Durable Object is single-threaded, but multiple request events may still be processed out-of-order from how they arrived at the Object.

It is ideal for projects that require:

- Real-time collaboration (such as a chat application or a game server).
- Consistent storage.
- Data locality.

To get started with Durable Objects:

- Read the [introductory blog post ↗︎](https://blog.cloudflare.com/introducing-workers-durable-objects/).
- Review the [Durable Objects documentation](https://developers.cloudflare.com/durable-objects/).
- Get started with [Durable Objects](https://developers.cloudflare.com/durable-objects/get-started/).
- Learn about Durable Objects [Limits](https://developers.cloudflare.com/durable-objects/platform/limits/).

### D1

[D1](https://developers.cloudflare.com/d1/) is Cloudflare’s native serverless database. With D1, you can create a database by importing data or defining your tables and writing your queries within a Worker or through the API.

D1 is ideal for:

- Persistent, relational storage for user data, account data, and other structured datasets.
- Use-cases that require querying across your data ad-hoc (using SQL).
- Workloads with a high ratio of reads to writes (most web applications).

To get started with D1:

- Read [the documentation](https://developers.cloudflare.com/d1)
- Follow the [Get started guide](https://developers.cloudflare.com/d1/get-started/) to provision your first D1 database.
- Review the [D1 Workers Binding API](https://developers.cloudflare.com/d1/worker-api/).

Note

If your working data size exceeds 10 GB (the maximum size for a D1 database), consider splitting the database into multiple, smaller D1 databases.

### Queues

Cloudflare Queues allows developers to send and receive messages with guaranteed delivery. It integrates with [Cloudflare Workers](https://developers.cloudflare.com/workers) and offers at-least once delivery, message batching, and does not charge for egress bandwidth.

Queues is ideal for:

- Offloading work from a request to schedule later.
- Send data from Worker to Worker (inter-Service communication).
- Buffering or batching data before writing to upstream systems, including third-party APIs or [Cloudflare R2](https://developers.cloudflare.com/queues/examples/send-errors-to-r2/).

To get started with Queues:

- [Set up your first queue](https://developers.cloudflare.com/queues/get-started/).
- Learn more [about how Queues works](https://developers.cloudflare.com/queues/reference/how-queues-works/).

### K2

K2 is a durable event log. Producers write records to a stream, and K2 stores them for a configurable retention period. Consumers read records in batches through subscriptions, and each subscription reads every record independently.

K2 is ideal for:

- Moving large volumes of event data, with pricing based on data volume rather than the number of messages.
- Delivering the same events to multiple independent consumers. For example, events from your applications can be read by an alerting system, a system that stores them durably, and a system that builds machine learning features.
- Retaining events so that consumers can replay them, or so that a new consumer can read events produced before it was added.

Use Queues when each message is a unit of work that needs to be completed, retried, and tracked individually. Use K2 when you produce and consume records in bulk, and what matters is that every record is processed rather than the state of any one record.

To get started with K2:

- [Create a stream](https://developers.cloudflare.com/k2/get-started/) and consume records from it.
- Learn about [K2 concepts](https://developers.cloudflare.com/k2/concepts/), including streams, subscriptions, and leases.
- Review K2 [Limits](https://developers.cloudflare.com/k2/platform/limits/).

### Hyperdrive

Hyperdrive is a service that accelerates queries you make to MySQL and Postgres databases, making it faster to access your data from across the globe, irrespective of your users’ location.

Hyperdrive allows you to:

- Connect to an existing database from Workers without connection overhead.
- Cache frequent queries across Cloudflare's global network to reduce response times on highly trafficked content.
- Reduce load on your origin database with connection pooling.

To get started with Hyperdrive:

- [Connect Hyperdrive](https://developers.cloudflare.com/hyperdrive/get-started/) to your existing database.
- Learn more [about how Hyperdrive speeds up your database queries](https://developers.cloudflare.com/hyperdrive/concepts/how-hyperdrive-works/).

## Basin Pipelines

Basin Pipelines is a streaming ingestion service that allows you to ingest high volumes of real time data, without managing any infrastructure.

Basin Pipelines allows you to:

- Ingest data at extremely high throughput (tens of thousands of records per second or more)
- Batch and write data directly to object storage, ready for querying
- (Future) Transform and aggregate data during ingestion

To get started with Basin Pipelines:

- [Create a pipeline](https://developers.cloudflare.com/basin-pipelines/getting-started/) that can batch and write records to R2.

### Analytics Engine

Analytics Engine is Cloudflare's time-series and metrics database that allows you to write unlimited-cardinality analytics at scale using a built-in API to write data points from Workers and query that data using SQL directly.

Analytics Engine allows you to:

- Expose custom analytics to your own customers
- Build usage-based billing systems
- Understand the health of your service on a per-customer or per-user basis
- Add instrumentation to frequently called code paths, without impacting performance or overwhelming external analytics systems with events

Cloudflare uses Analytics Engine internally to store and product per-product metrics for products like D1 and R2 at scale.

To get started with Analytics Engine:

- Learn how to [get started with Analytics Engine](https://developers.cloudflare.com/analytics/analytics-engine/get-started/)
- See [an example of writing time-series data to Analytics Engine](https://developers.cloudflare.com/analytics/analytics-engine/recipes/usage-based-billing-for-your-saas-product/)
- Understand the [SQL API](https://developers.cloudflare.com/analytics/analytics-engine/sql-api/) for reading data from your Analytics Engine datasets

### Vectorize

Vectorize is a globally distributed vector database that enables you to build full-stack, AI-powered applications with Cloudflare Workers and [Workers AI](https://developers.cloudflare.com/workers-ai/).

Vectorize allows you to:

- Store embeddings from any vector embeddings model (Bring Your Own embeddings) for semantic search and classification tasks.
- Add context to Large Language Model (LLM) queries by using vector search as part of a [Retrieval Augmented Generation](https://developers.cloudflare.com/workers-ai/guides/tutorials/build-a-retrieval-augmented-generation-ai/) (RAG) workflow.
- [Filter on vector metadata](https://developers.cloudflare.com/vectorize/reference/metadata-filtering/) to reduce the search space and return more relevant results.

To get started with Vectorize:

- [Create your first vector database](https://developers.cloudflare.com/vectorize/get-started/intro/).
- Combine [Workers AI and Vectorize](https://developers.cloudflare.com/vectorize/get-started/embeddings/) to generate, store and query text embeddings.
- Learn more about [how vector databases work](https://developers.cloudflare.com/vectorize/reference/what-is-a-vector-database/).

## SQL in Durable Objects vs D1

Cloudflare Workers offers a SQLite-backed serverless database product - [D1](https://developers.cloudflare.com/d1/). How should you compare [SQLite in Durable Objects](https://developers.cloudflare.com/durable-objects/best-practices/access-durable-objects-storage/) and D1?

**D1 is a managed database product.**

D1 fits into a familiar architecture for developers, where application servers communicate with a database over the network. Application servers are typically Workers; however, D1 also supports external, non-Worker access via an [HTTP API ↗︎](https://developers.cloudflare.com/api/resources/d1/subresources/database/methods/query/), which helps unlock [third-party tooling](https://developers.cloudflare.com/d1/reference/community-projects/#_top) support for D1.

D1 aims for a "batteries included" feature set, including the above HTTP API, [database schema management](https://developers.cloudflare.com/d1/reference/migrations/#_top), [data import/export](https://developers.cloudflare.com/d1/best-practices/import-export-data/), and [database query insights](https://developers.cloudflare.com/d1/observability/metrics-analytics/#query-insights).

With D1, your application code and SQL database queries are not colocated which can impact application performance. If performance is a concern with D1, Workers has [Smart Placement](https://developers.cloudflare.com/workers/configuration/placement/#_top) to dynamically run your Worker in the best location to reduce total Worker request latency, considering everything your Worker talks to, including D1.

**SQLite in Durable Objects is a lower-level compute with storage building block for distributed systems.**

By design, Durable Objects are accessed with Workers-only.

Durable Objects require a bit more effort, but in return, give you more flexibility and control. With Durable Objects, you must implement two pieces of code that run in different places: a front-end Worker which routes incoming requests from the Internet to a unique Durable Object, and the Durable Object itself, which runs on the same machine as the SQLite database. You get to choose what runs where, and it may be that your application benefits from running some application business logic right next to the database.

With SQLite in Durable Objects, you may also need to build some of your own database tooling that comes out-of-the-box with D1.

SQL query pricing and limits are intended to be identical between D1 ([pricing](https://developers.cloudflare.com/d1/platform/pricing/), [limits](https://developers.cloudflare.com/d1/platform/limits/)) and SQLite in Durable Objects ([pricing](https://developers.cloudflare.com/durable-objects/platform/pricing/#sqlite-storage-backend), [limits](https://developers.cloudflare.com/durable-objects/platform/limits/)).

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"TechArticle","@id":"https://developers.cloudflare.com/workers/platform/storage-options/#page","headline":"Choose a data or storage product","description":"Storage and database options available on Cloudflare's developer platform.","url":"https://developers.cloudflare.com/workers/platform/storage-options/","inLanguage":"en","image":"https://developers.cloudflare.com/workers/platform/storage-options/og.png?v=abca508978294b6c","dateModified":"2026-10-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```

---

---
description: Build and host AI agents on Cloudflare. Run an agent harness in a Durable Object, add capabilities such as state, WebSockets, and scheduling with the Agents SDK Lifecycle, and give the agent tools.
title: Build Agents on Cloudflare
image: https://developers.cloudflare.com/agents/og.png?v=5f3790c1b824e669
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/agents/llms.txt  
> Use this file to discover all available pages before exploring further.

# Build Agents on Cloudflare

Last updated Oct 29, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/agents/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

Build and host AI agents on Cloudflare. Connect chat, voice, email, Slack, and webhooks to a durable agent, and give it tools such as a workspace, a browser, web search, MCP servers, and payments.

When you host agents on Cloudflare, each agent has a durable identity, local SQL storage, real-time connections, scheduled work, and recoverable execution.

Deploy once and Cloudflare runs your agents across its global network, scaling to tens of millions of instances. No infrastructure to manage, no sessions to reconstruct, no state to externalize.

[Chat](https://developers.cloudflare.com/agents/agent-class/communication-channels/chat/) [Email](https://developers.cloudflare.com/agents/agent-class/communication-channels/email/) [Voice](https://developers.cloudflare.com/agents/agent-class/communication-channels/voice/) [Slack](https://developers.cloudflare.com/agents/agent-class/communication-channels/slack/) [Webhook](https://developers.cloudflare.com/agents/agent-class/communication-channels/webhooks/)

Runtime

The Lifecycle provides hooks for Capabilities to schedule durable work.

[Lifecycle](https://developers.cloudflare.com/agents/runtime/lifecycle/)

[State](https://developers.cloudflare.com/agents/runtime/capabilities/state/) [WebSockets](https://developers.cloudflare.com/agents/runtime/capabilities/websockets/) [Scheduler](https://developers.cloudflare.com/agents/runtime/capabilities/scheduler/) [MCP client](https://developers.cloudflare.com/agents/runtime/capabilities/mcp-client-manager/)

Harnesses

[Pi](https://developers.cloudflare.com/agents/harnesses/pi/) [OpenCode](https://developers.cloudflare.com/agents/harnesses/opencode/) [Think](https://developers.cloudflare.com/agents/harnesses/think/)

[Workspace](https://developers.cloudflare.com/agents/tools/filesystem/) [Sandbox](https://developers.cloudflare.com/agents/tools/sandbox/) [Browser](https://developers.cloudflare.com/agents/tools/browser/) [Web fetch](https://developers.cloudflare.com/agents/tools/web-fetch/) [Web search](https://developers.cloudflare.com/agents/tools/web-search/) [MCP servers](https://developers.cloudflare.com/agents/tools/mcp/) [AI Search](https://developers.cloudflare.com/agents/tools/ai-search/) [Payments](https://developers.cloudflare.com/agents/tools/payments/)

[ObservabilityLogs · metrics · traces](https://developers.cloudflare.com/agents/runtime/observability/)

Agents on Cloudflare are composed from four parts:

- **The runtime is a Durable Object, the Lifecycle, and capabilities.** Each agent is a [Durable Object](https://developers.cloudflare.com/durable-objects/), and [routing](https://developers.cloudflare.com/agents/runtime/routing/) sends each request to the right one. The Agents SDK [Lifecycle](https://developers.cloudflare.com/agents/runtime/lifecycle/) runs inside the Durable Object, handles its requests, alarms, and WebSocket events, and starts the [capabilities](https://developers.cloudflare.com/agents/runtime/capabilities/) you add to it with `.use()`. Capabilities include [`WebSockets`](https://developers.cloudflare.com/agents/runtime/capabilities/websockets/), [`State`](https://developers.cloudflare.com/agents/runtime/capabilities/state/), [`Scheduler`](https://developers.cloudflare.com/agents/runtime/capabilities/scheduler/), and [`MCPClientManager`](https://developers.cloudflare.com/agents/runtime/capabilities/mcp-client-manager/).
- **The harness is the capability that runs the agent loop.** A harness calls models, runs tools, handles tool results, streams responses, and decides whether to continue. It is the unit of compute for an agent, and the Agents SDK exists to make harnesses run well on Cloudflare. Use the [Pi harness](https://developers.cloudflare.com/agents/harnesses/pi/), which runs the [Pi ↗︎](https://pi.dev/) agent loop durably and keeps a run going after the object is evicted.
- **Tools** let the agent act. For a durable file system and code execution, give the agent a [workspace](https://developers.cloudflare.com/agents/tools/filesystem/) from Cloudflare Computer. The Agents SDK also includes [web fetch](https://developers.cloudflare.com/agents/tools/web-fetch/), [web search](https://developers.cloudflare.com/agents/tools/web-search/), [browser automation](https://developers.cloudflare.com/agents/tools/browser/), [sandboxed code execution](https://developers.cloudflare.com/agents/tools/sandbox/), [AI Search](https://developers.cloudflare.com/agents/tools/ai-search/), [MCP servers](https://developers.cloudflare.com/agents/tools/mcp/), [payments](https://developers.cloudflare.com/agents/tools/payments/), and [Code Mode](https://developers.cloudflare.com/agents/tools/codemode/).
- **Communication channels** define how users and systems reach your agent, such as [chat](https://developers.cloudflare.com/agents/agent-class/communication-channels/chat/), [voice](https://developers.cloudflare.com/agents/agent-class/communication-channels/voice/), [email](https://developers.cloudflare.com/agents/agent-class/communication-channels/email/), [Slack](https://developers.cloudflare.com/agents/agent-class/communication-channels/slack/), [webhooks](https://developers.cloudflare.com/agents/agent-class/communication-channels/webhooks/), and other event sources. These guides use the [`Agent` class](https://developers.cloudflare.com/agents/agent-class/), a preset Durable Object with the Lifecycle and a set of capabilities already installed.

Agents publish structured events, such as state changes, schedules, and MCP connections, that you can use for [observability](https://developers.cloudflare.com/agents/runtime/observability/).

### Get started

Build your first agent with the Pi harness. The [Pi harness](https://developers.cloudflare.com/agents/harnesses/pi/) runs the [Pi ↗︎](https://pi.dev/) agent loop durably in a Durable Object. It uses the Lifecycle's job queue to schedule future work, so a run continues after the object is evicted. No API keys are required. The examples use [Workers AI](https://developers.cloudflare.com/workers-ai/) through the `AI` binding.

npmyarnpnpmbun

```
npm i agents @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/pi-schema @earendil-works/chord
```

```
yarn add agents @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/pi-schema @earendil-works/chord
```

```
pnpm add agents @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/pi-schema @earendil-works/chord
```

```
bun add agents @earendil-works/pi-durable @earendil-works/pi-ai @earendil-works/pi-schema @earendil-works/chord
```

The Pi packages are optional peer dependencies of `agents`, at `~1.5.0`. Pi Durable is experimental and its API can change in minor releases, so each `agents` release supports one Pi minor version. Install the versions your package manager resolves for `agents`.

To start from a complete app with a browser UI, a Cloudflare Computer workspace, and code execution, deploy the Pi harness example:

[![Deploy to Cloudflare](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/cloudflare/agents/tree/main/examples/next/harnesses/pi)

To build it step by step, follow [Build your first Durable Agent](https://developers.cloudflare.com/agents/getting-started/quick-start/). To learn the Lifecycle, [`State`](https://developers.cloudflare.com/agents/runtime/capabilities/state/), and [`WebSockets`](https://developers.cloudflare.com/agents/runtime/capabilities/websockets/) without a model, refer to [Learn the runtime](https://developers.cloudflare.com/agents/getting-started/learn-the-runtime/). To add the Lifecycle to a Worker you already have, refer to [Add to an existing project](https://developers.cloudflare.com/agents/getting-started/add-to-existing-project/).

### Example agents

The Pi agent runs on the Pi harness. The other examples build on the [`Agent` class](https://developers.cloudflare.com/agents/agent-class/) preset.

[Pi agent](https://developers.cloudflare.com/agents/harnesses/pi/)

Build an agent on the Pi harness, with tools, sessions, and recovery after eviction.

[Chat agent](https://developers.cloudflare.com/agents/examples/chat-agent/)

Build a streaming AI chat agent with tools and human-in-the-loop approvals.

[Slack agent](https://developers.cloudflare.com/agents/examples/slack-agent/)

Build an agent that responds to Slack messages, mentions, and commands.

[Voice agent](https://developers.cloudflare.com/agents/examples/voice-agent/)

Build a real-time voice agent with speech-to-text and text-to-speech.

[Browser agent](https://developers.cloudflare.com/agents/examples/browser-agent/)

Build an agent that can inspect pages, capture screenshots, and use browser tools.

[Email agent](https://developers.cloudflare.com/agents/examples/email-agent/)

Build an agent that sends, receives, routes, and replies to email.

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/agents/#page","headline":"Build Agents on Cloudflare","description":"Build and host AI agents on Cloudflare. Run an agent harness in a Durable Object, add capabilities such as state, WebSockets, and scheduling with the Agents SDK Lifecycle, and give the agent tools.","url":"https://developers.cloudflare.com/agents/","inLanguage":"en","image":"https://developers.cloudflare.com/agents/og.png?v=5f3790c1b824e669","dateModified":"2026-10-29","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"},"keywords":["AI"]}
```

---

---
title: Run a Workers AI model
---

[Skip to content](#_top)

[API Reference](https://developers.cloudflare.com/api)

[AI](https://developers.cloudflare.com/api/resources/ai)

Copy Markdown

Open in **Claude**Open in **ChatGPT**Open in **Cursor**

---

**Copy Markdown****View as Markdown**

# Run a Workers AI model

POST/accounts/{account\_id}/ai/run/{model\_name}

Runs the Workers AI model specified in the URL path. Send the model’s inputs directly in the request body, without a model/input/options wrapper.

Accepts model-specific JSON or binary input. The response format depends on the model and the requested output.

See the [model catalog](https://developers.cloudflare.com/workers-ai/models/) for supported models and their input formats.

##### Security

<details>

<summary>API Token</summary>



The preferred authorization scheme for interacting with the Cloudflare API. <a href="https://developers.cloudflare.com/fundamentals/api/get-started/create-token/">Create a token</a>.

**Example:**<code>Authorization: Bearer Sn3lZJTBX6kkg7OdcBUAxOO963GEIyGQqnFTOFYY</code>

</details>

<details>

<summary>API Email + API Key</summary>



The previous authorization scheme for interacting with the Cloudflare API, used in conjunction with a Global API key.

**Example:**<code>X-Auth-Email: user@example.com</code>

The previous authorization scheme for interacting with the Cloudflare API. When possible, use API tokens instead of Global API keys.

**Example:**<code>X-Auth-Key: 144c9defac04969c7bfad8efaa8ea194</code>

</details>

##### Accepted Permissions (at least one required)

`Workers AI Write``Workers AI Read`

##### P ath ParametersExpand Collapse

account\_id: string

Cloudflare account ID used for this AI model request.

[Link to this property](<#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20account_id%20%3E%20(schema)>)

model\_name: string

Workers AI model identifier, including its namespace and model name.

[Link to this property](<#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20model_name%20%3E%20(schema)>)

##### Body ParametersJSONExpand Collapse

<details>

<summary>

body: optional object {text } or object {prompt, guidance, height, 8 more } or object {prompt, lang } or 12 more

</summary>

One of the following:

<details>

<summary>

TextClassification object {text }

</summary>

text: string

The text that you want to classify

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(property)%20text">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%200">Link to this property</a>

<details>

<summary>

TextToImage object {prompt, guidance, height, 8 more }

</summary>

prompt: string

A text description of the image you want to generate

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20prompt">Link to this property</a>

guidance: optional number

Controls how closely the generated image should adhere to the prompt; higher values make the image more aligned with the prompt

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20guidance">Link to this property</a>

height: optional number

The height of the generated image in pixels

maximum2048

minimum256

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20height">Link to this property</a>

image: optional array of number

For use with img2img tasks. An array of integers that represent the image data constrained to 8-bit unsigned integer values

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20image">Link to this property</a>

image\_b64: optional string

For use with img2img tasks. A base64-encoded string of the input image

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20image_b64">Link to this property</a>

mask: optional array of number

An array representing An array of integers that represent mask image data for inpainting constrained to 8-bit unsigned integer values

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20mask">Link to this property</a>

negative\_prompt: optional string

Text describing elements to avoid in the generated image

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20negative_prompt">Link to this property</a>

num\_steps: optional number

The number of diffusion steps; higher values can improve quality but take longer

maximum20

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20num_steps">Link to this property</a>

seed: optional number

Random seed for reproducibility of the image generation

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20seed">Link to this property</a>

strength: optional number

A value between 0 and 1 indicating how strongly to apply the transformation during img2img tasks; lower values make the output closer to the input image

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20strength">Link to this property</a>

width: optional number

The width of the generated image in pixels

maximum2048

minimum256

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201%20%3E%20(property)%20width">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%201">Link to this property</a>

<details>

<summary>

TextToSpeech object {prompt, lang }

</summary>

prompt: string

A text description of the audio you want to generate

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%202%20%3E%20(property)%20prompt">Link to this property</a>

lang: optional string

The speech language (e.g., ‘en’ for English, ‘fr’ for French). Defaults to ‘en’ if not specified

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%202%20%3E%20(property)%20lang">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%202">Link to this property</a>

<details>

<summary>

TextEmbeddings object {text }

</summary>

<details>

<summary>

text: stringor array of string

The text to embed

</summary>

One of the following:

string

The text to embed

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%203%20%3E%20(property)%20text%20%3E%20(variant)%200">Link to this property</a>

array of string

Batch of text values to embed

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%203%20%3E%20(property)%20text%20%3E%20(variant)%201">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%203%20%3E%20(property)%20text">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%203">Link to this property</a>

<details>

<summary>

AutomaticSpeechRecognition object {audio, source\_lang, target\_lang }

</summary>

audio: array of number

An array of integers that represent the audio data constrained to 8-bit unsigned integer values

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%204%20%3E%20(property)%20audio">Link to this property</a>

source\_lang: optional string

The language of the recorded audio

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%204%20%3E%20(property)%20source_lang">Link to this property</a>

target\_lang: optional string

The language to translate the transcription into. Currently only English is supported.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%204%20%3E%20(property)%20target_lang">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%204">Link to this property</a>

<details>

<summary>

ImageClassification object {image }

</summary>

image: array of number

An array of integers that represent the image data constrained to 8-bit unsigned integer values

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20image">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%205">Link to this property</a>

<details>

<summary>

ObjectDetection object {image }

</summary>

image: optional array of number

An array of integers that represent the image data constrained to 8-bit unsigned integer values

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%206%20%3E%20(property)%20image">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%206">Link to this property</a>

<details>

<summary>

Prompt object {prompt, frequency\_penalty, lora, 10 more }

</summary>

prompt: string

The input text prompt for the model to generate a response.

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20prompt">Link to this property</a>

frequency\_penalty: optional number

Decreases the likelihood of the model repeating the same lines verbatim.

maximum2

minimum-2

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20frequency_penalty">Link to this property</a>

lora: optional string

Name of the LoRA (Low-Rank Adaptation) model to fine-tune the base model.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20lora">Link to this property</a>

max\_tokens: optional number

The maximum number of tokens to generate in the response.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20max_tokens">Link to this property</a>

presence\_penalty: optional number

Increases the likelihood of the model introducing new topics.

maximum2

minimum-2

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20presence_penalty">Link to this property</a>

raw: optional boolean

If true, a chat template is not applied and you must adhere to the specific model’s expected formatting.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20raw">Link to this property</a>

repetition\_penalty: optional number

Penalty for repeated tokens; higher values discourage repetition.

maximum2

minimum0

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20repetition_penalty">Link to this property</a>

<details>

<summary>

response\_format: optional object {json\_schema, type }

</summary>

json\_schema: optional unknown

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20response_format%20%3E%20(property)%20json_schema">Link to this property</a>

<details>

<summary>

type: optional "json\_object"or "json\_schema"

</summary>

One of the following:

"json\_object"

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20response_format%20%3E%20(property)%20type%20%3E%20(member)%200">Link to this property</a>

"json\_schema"

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20response_format%20%3E%20(property)%20type%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20response_format%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20response_format">Link to this property</a>

seed: optional number

Random seed for reproducibility of the generation.

maximum9999999999

minimum1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20seed">Link to this property</a>

stream: optional boolean

If true, the response will be streamed back incrementally using SSE, Server Sent Events.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20stream">Link to this property</a>

temperature: optional number

Controls the randomness of the output; higher values produce more random results.

maximum5

minimum0

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20temperature">Link to this property</a>

top\_k: optional number

Limits the AI to choose from the top ‘k’ most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

maximum50

minimum1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20top_k">Link to this property</a>

top\_p: optional number

Adjusts the creativity of the AI’s responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

maximum1

minimum0.001

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(property)%20top_p">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%207">Link to this property</a>

<details>

<summary>

TextGeneration object {messages, frequency\_penalty, functions, 11 more }

</summary>

<details>

<summary>

messages: array of object {content, role }

An array of message objects representing the conversation history.

</summary>

<details>

<summary>

content: stringor array of object {text, type }

The content of the message as a string.

</summary>

One of the following:

string

The content of the message as a string.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%200">Link to this property</a>

<details>

<summary>

array of object {text, type }

Array of text content parts.

</summary>

text: optional string

Text content

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201%20%3E%20(items)%20%3E%20(property)%20text">Link to this property</a>

type: optional string

Type of the content (text)

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201%20%3E%20(items)%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content">Link to this property</a>

role: string

The role of the message sender (e.g., ‘user’, ‘assistant’, ‘system’, ‘tool’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20role">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20messages">Link to this property</a>

frequency\_penalty: optional number

Decreases the likelihood of the model repeating the same lines verbatim.

maximum2

minimum-2

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20frequency_penalty">Link to this property</a>

<details>

<summary>

functions: optional array of object {code, name }

</summary>

code: string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20functions%20%3E%20(items)%20%3E%20(property)%20code">Link to this property</a>

name: string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20functions%20%3E%20(items)%20%3E%20(property)%20name">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20functions">Link to this property</a>

max\_tokens: optional number

The maximum number of tokens to generate in the response.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20max_tokens">Link to this property</a>

presence\_penalty: optional number

Increases the likelihood of the model introducing new topics.

maximum2

minimum-2

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20presence_penalty">Link to this property</a>

raw: optional boolean

If true, a chat template is not applied and you must adhere to the specific model’s expected formatting.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20raw">Link to this property</a>

repetition\_penalty: optional number

Penalty for repeated tokens; higher values discourage repetition.

maximum2

minimum0

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20repetition_penalty">Link to this property</a>

<details>

<summary>

response\_format: optional object {json\_schema, type }

</summary>

json\_schema: optional unknown

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format%20%3E%20(property)%20json_schema">Link to this property</a>

<details>

<summary>

type: optional "json\_object"or "json\_schema"

</summary>

One of the following:

"json\_object"

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format%20%3E%20(property)%20type%20%3E%20(member)%200">Link to this property</a>

"json\_schema"

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format%20%3E%20(property)%20type%20%3E%20(member)%201">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response_format">Link to this property</a>

seed: optional number

Random seed for reproducibility of the generation.

maximum9999999999

minimum1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20seed">Link to this property</a>

stream: optional boolean

If true, the response will be streamed back incrementally using SSE, Server Sent Events.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20stream">Link to this property</a>

temperature: optional number

Controls the randomness of the output; higher values produce more random results.

maximum5

minimum0

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20temperature">Link to this property</a>

<details>

<summary>

tools: optional array of object {description, name, parameters } or object {function, type }

A list of tools available for the assistant to use.

</summary>

One of the following:

<details>

<summary>

object {description, name, parameters }

</summary>

description: string

A brief description of what the tool does.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20description">Link to this property</a>

name: string

The name of the tool. More descriptive the better.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20name">Link to this property</a>

<details>

<summary>

parameters: object {properties, type, required }

Schema defining the parameters accepted by the tool.

</summary>

<details>

<summary>

properties: map\[object {description, type } ]

Definitions of each parameter.

</summary>

description: string

A description of the expected parameter.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20properties%20%3E%20(items)%20%3E%20(property)%20description">Link to this property</a>

type: string

The data type of the parameter.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20properties%20%3E%20(items)%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20properties">Link to this property</a>

type: string

The type of the parameters object (usually ‘object’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20type">Link to this property</a>

required: optional array of string

List of required parameter names.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters%20%3E%20(property)%20required">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200%20%3E%20(property)%20parameters">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%200">Link to this property</a>

<details>

<summary>

Function object {function, type }

</summary>

<details>

<summary>

function: object {description, name, parameters }

Details of the function tool.

</summary>

description: string

A brief description of what the function does.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20description">Link to this property</a>

name: string

The name of the function.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20name">Link to this property</a>

<details>

<summary>

parameters: object {properties, type, required }

Schema defining the parameters accepted by the function.

</summary>

<details>

<summary>

properties: map\[object {description, type } ]

Definitions of each parameter.

</summary>

description: string

A description of the expected parameter.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20properties%20%3E%20(items)%20%3E%20(property)%20description">Link to this property</a>

type: string

The data type of the parameter.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20properties%20%3E%20(items)%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20properties">Link to this property</a>

type: string

The type of the parameters object (usually ‘object’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20type">Link to this property</a>

required: optional array of string

List of required parameter names.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters%20%3E%20(property)%20required">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function%20%3E%20(property)%20parameters">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20function">Link to this property</a>

type: string

Specifies the type of tool (e.g., ‘function’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201%20%3E%20(property)%20type">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools%20%3E%20(items)%20%3E%20(variant)%201">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tools">Link to this property</a>

top\_k: optional number

Limits the AI to choose from the top ‘k’ most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

maximum50

minimum1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20top_k">Link to this property</a>

top\_p: optional number

Adjusts the creativity of the AI’s responses by controlling how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

maximum1

minimum0.001

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20top_p">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%208">Link to this property</a>

<details>

<summary>

Translation object {target\_lang, text, source\_lang }

</summary>

target\_lang: string

The language code to translate the text into (e.g., ‘es’ for Spanish)

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%209%20%3E%20(property)%20target_lang">Link to this property</a>

text: string

The text to be translated

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%209%20%3E%20(property)%20text">Link to this property</a>

source\_lang: optional string

The language code of the source text (e.g., ‘en’ for English). Defaults to ‘en’ if not specified

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%209%20%3E%20(property)%20source_lang">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%209">Link to this property</a>

<details>

<summary>

Summarization object {input\_text, max\_length }

</summary>

input\_text: string

The text that you want the model to summarize

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2010%20%3E%20(property)%20input_text">Link to this property</a>

max\_length: optional number

The maximum length of the generated summary in tokens

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2010%20%3E%20(property)%20max_length">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2010">Link to this property</a>

<details>

<summary>

ImageToText object {image, frequency\_penalty, max\_tokens, 8 more }

</summary>

image: array of number

An array of integers that represent the image data constrained to 8-bit unsigned integer values

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20image">Link to this property</a>

frequency\_penalty: optional number

Decreases the likelihood of the model repeating the same lines verbatim.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20frequency_penalty">Link to this property</a>

max\_tokens: optional number

The maximum number of tokens to generate in the response.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20max_tokens">Link to this property</a>

presence\_penalty: optional number

Increases the likelihood of the model introducing new topics.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20presence_penalty">Link to this property</a>

prompt: optional string

The input text prompt for the model to generate a response.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20prompt">Link to this property</a>

raw: optional boolean

If true, a chat template is not applied and you must adhere to the specific model’s expected formatting.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20raw">Link to this property</a>

repetition\_penalty: optional number

Penalty for repeated tokens; higher values discourage repetition.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20repetition_penalty">Link to this property</a>

seed: optional number

Random seed for reproducibility of the generation.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20seed">Link to this property</a>

temperature: optional number

Controls the randomness of the output; higher values produce more random results.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20temperature">Link to this property</a>

top\_k: optional number

Limits the AI to choose from the top ‘k’ most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20top_k">Link to this property</a>

top\_p: optional number

Controls the creativity of the AI’s responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20top_p">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2011">Link to this property</a>

<details>

<summary>

object {image, prompt, frequency\_penalty, 8 more }

</summary>

image: string

Image in base64 encoded format.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20image">Link to this property</a>

prompt: string

The input text prompt for the model to generate a response.

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20prompt">Link to this property</a>

frequency\_penalty: optional number

Decreases the likelihood of the model repeating the same lines verbatim.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20frequency_penalty">Link to this property</a>

ignore\_eos: optional boolean

Whether to ignore the EOS token and continue generating tokens after the EOS token is generated.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20ignore_eos">Link to this property</a>

max\_tokens: optional number

The maximum number of tokens to generate in the response.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20max_tokens">Link to this property</a>

presence\_penalty: optional number

Increases the likelihood of the model introducing new topics.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20presence_penalty">Link to this property</a>

repetition\_penalty: optional number

Penalty for repeated tokens; higher values discourage repetition.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20repetition_penalty">Link to this property</a>

seed: optional number

Random seed for reproducibility of the generation.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20seed">Link to this property</a>

temperature: optional number

Controls the randomness of the output; higher values produce more random results.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20temperature">Link to this property</a>

top\_k: optional number

Limits the AI to choose from the top ‘k’ most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20top_k">Link to this property</a>

top\_p: optional number

Controls the creativity of the AI’s responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20top_p">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2012">Link to this property</a>

<details>

<summary>

ImageTextToText object {image, messages, frequency\_penalty, 8 more }

</summary>

image: string

Image in base64 encoded format.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20image">Link to this property</a>

<details>

<summary>

messages: array of object {content, role }

An array of message objects representing the conversation history.

</summary>

<details>

<summary>

content: stringor array of object {type, image\_url, text }

The content of the message as a string.

</summary>

One of the following:

string

The content of the message as a string.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%200">Link to this property</a>

<details>

<summary>

array of object {type, image\_url, text }

Array of content parts (text, image\_url, etc.).

</summary>

type: string

Type of the content part (e.g. ‘text’, ‘image\_url’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201%20%3E%20(items)%20%3E%20(property)%20type">Link to this property</a>

<details>

<summary>

image\_url: optional object {url }

Image URL object (when type is ‘image\_url’).

</summary>

url: string

Image URI with data (e.g. data:image/jpeg;base64,/9j/…).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201%20%3E%20(items)%20%3E%20(property)%20image_url%20%3E%20(property)%20url">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201%20%3E%20(items)%20%3E%20(property)%20image_url">Link to this property</a>

text: optional string

Text content (when type is ‘text’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201%20%3E%20(items)%20%3E%20(property)%20text">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content%20%3E%20(variant)%201">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20content">Link to this property</a>

role: string

The role of the message sender (e.g., ‘user’, ‘assistant’, ‘system’, ‘tool’).

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20messages%20%3E%20(items)%20%3E%20(property)%20role">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20messages">Link to this property</a>

frequency\_penalty: optional number

Decreases the likelihood of the model repeating the same lines verbatim.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20frequency_penalty">Link to this property</a>

ignore\_eos: optional boolean

Whether to ignore the EOS token and continue generating tokens after the EOS token is generated.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20ignore_eos">Link to this property</a>

max\_tokens: optional number

The maximum number of tokens to generate in the response.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20max_tokens">Link to this property</a>

presence\_penalty: optional number

Increases the likelihood of the model introducing new topics.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20presence_penalty">Link to this property</a>

repetition\_penalty: optional number

Penalty for repeated tokens; higher values discourage repetition.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20repetition_penalty">Link to this property</a>

seed: optional number

Random seed for reproducibility of the generation.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20seed">Link to this property</a>

temperature: optional number

Controls the randomness of the output; higher values produce more random results.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20temperature">Link to this property</a>

top\_k: optional number

Limits the AI to choose from the top ‘k’ most probable words. Lower values make responses more focused; higher values introduce more variety and potential surprises.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20top_k">Link to this property</a>

top\_p: optional number

Controls the creativity of the AI’s responses by adjusting how many possible words it considers. Lower values make outputs more predictable; higher values allow for more varied and creative responses.

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20top_p">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2013">Link to this property</a>

<details>

<summary>

MultimodalEmbeddings object {image, text }

</summary>

image: optional string

Image in base64 encoded format.

minLength1

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2014%20%3E%20(property)%20image">Link to this property</a>

text: optional array of string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2014%20%3E%20(property)%20text">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)%20%3E%20(variant)%2014">Link to this property</a>

</details>

[Link to this property](<#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(params)%200%20%3E%20(param)%20body%20%3E%20(schema)>)

##### ReturnsExpand Collapse

<details>

<summary>

result: optional array of object {label, score } or stringor object {audio } or 12 more

An array of classification results for the input text

</summary>

One of the following:

<details>

<summary>

TextClassification = array of object {label, score }

An array of classification results for the input text

</summary>

label: optional string

The classification label assigned to the text (e.g., ‘POSITIVE’ or ‘NEGATIVE’)

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(items)%20%3E%20(property)%20label">Link to this property</a>

score: optional number

Confidence score indicating the likelihood that the text belongs to the specified label

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%200%20%3E%20(items)%20%3E%20(property)%20score">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%200">Link to this property</a>

TextToImage = string

The generated image in PNG format

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%201">Link to this property</a>

<details>

<summary>

Audio object {audio }

</summary>

audio: optional string

The generated audio in MP3 format, base64-encoded

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%202%20%3E%20(property)%20audio">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%202">Link to this property</a>

string

The generated audio in MP3 format

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%203">Link to this property</a>

<details>

<summary>

TextEmbeddings object {data, shape }

</summary>

data: optional array of array of number

Embeddings of the requested text values

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%204%20%3E%20(property)%20data">Link to this property</a>

shape: optional array of number

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%204%20%3E%20(property)%20shape">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%204">Link to this property</a>

<details>

<summary>

AutomaticSpeechRecognition object {text, vtt, word\_count, words }

</summary>

text: string

The transcription

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20text">Link to this property</a>

vtt: optional string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20vtt">Link to this property</a>

word\_count: optional number

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20word_count">Link to this property</a>

<details>

<summary>

words: optional array of object {end, start, word }

</summary>

end: optional number

The ending second when the word completes

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20words%20%3E%20(items)%20%3E%20(property)%20end">Link to this property</a>

start: optional number

The second this word begins in the recording

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20words%20%3E%20(items)%20%3E%20(property)%20start">Link to this property</a>

word: optional string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20words%20%3E%20(items)%20%3E%20(property)%20word">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%205%20%3E%20(property)%20words">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%205">Link to this property</a>

<details>

<summary>

ImageClassification = array of object {label, score }

</summary>

label: optional string

The predicted category or class for the input image based on analysis

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%206%20%3E%20(items)%20%3E%20(property)%20label">Link to this property</a>

score: optional number

A confidence value, between 0 and 1, indicating how certain the model is about the predicted label

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%206%20%3E%20(items)%20%3E%20(property)%20score">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%206">Link to this property</a>

<details>

<summary>

ObjectDetection = array of object {box, label, score }

An array of detected objects within the input image

</summary>

<details>

<summary>

box: optional object {xmax, xmin, ymax, ymin }

Coordinates defining the bounding box around the detected object

</summary>

xmax: optional number

The x-coordinate of the bottom-right corner of the bounding box

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(items)%20%3E%20(property)%20box%20%3E%20(property)%20xmax">Link to this property</a>

xmin: optional number

The x-coordinate of the top-left corner of the bounding box

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(items)%20%3E%20(property)%20box%20%3E%20(property)%20xmin">Link to this property</a>

ymax: optional number

The y-coordinate of the bottom-right corner of the bounding box

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(items)%20%3E%20(property)%20box%20%3E%20(property)%20ymax">Link to this property</a>

ymin: optional number

The y-coordinate of the top-left corner of the bounding box

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(items)%20%3E%20(property)%20box%20%3E%20(property)%20ymin">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(items)%20%3E%20(property)%20box">Link to this property</a>

label: optional string

The class label or name of the detected object

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(items)%20%3E%20(property)%20label">Link to this property</a>

score: optional number

Confidence score indicating the likelihood that the detection is correct

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%207%20%3E%20(items)%20%3E%20(property)%20score">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%207">Link to this property</a>

<details>

<summary>

object {response, tool\_calls, usage }

</summary>

response: string

The generated text response from the model

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20response">Link to this property</a>

<details>

<summary>

tool\_calls: optional array of object {arguments, name }

An array of tool calls requests made during the response generation

</summary>

arguments: optional unknown

The arguments passed to be passed to the tool call request

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tool_calls%20%3E%20(items)%20%3E%20(property)%20arguments">Link to this property</a>

name: optional string

The name of the tool to be called

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tool_calls%20%3E%20(items)%20%3E%20(property)%20name">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20tool_calls">Link to this property</a>

<details>

<summary>

usage: optional object {completion\_tokens, prompt\_tokens, total\_tokens }

Usage statistics for the inference request

</summary>

completion\_tokens: optional number

Total number of tokens in output

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20usage%20%3E%20(property)%20completion_tokens">Link to this property</a>

prompt\_tokens: optional number

Total number of tokens in input

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20usage%20%3E%20(property)%20prompt_tokens">Link to this property</a>

total\_tokens: optional number

Total number of input and output tokens

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20usage%20%3E%20(property)%20total_tokens">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%208%20%3E%20(property)%20usage">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%208">Link to this property</a>

string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%209">Link to this property</a>

<details>

<summary>

Translation object {translated\_text }

</summary>

translated\_text: optional string

The translated text in the target language

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2010%20%3E%20(property)%20translated_text">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2010">Link to this property</a>

<details>

<summary>

Summarization object {summary }

</summary>

summary: optional string

The summarized version of the input text

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2011%20%3E%20(property)%20summary">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2011">Link to this property</a>

<details>

<summary>

ImageToText object {description }

</summary>

description: optional string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2012%20%3E%20(property)%20description">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2012">Link to this property</a>

<details>

<summary>

ImageTextToText object {description }

</summary>

description: optional string

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2013%20%3E%20(property)%20description">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2013">Link to this property</a>

<details>

<summary>

MultimodalEmbeddings object {data, shape }

</summary>

data: optional array of array of number

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2014%20%3E%20(property)%20data">Link to this property</a>

shape: optional array of number

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2014%20%3E%20(property)%20shape">Link to this property</a>

</details>

<a href="#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result%20%2B%20(resource)%20ai%20%3E%20(model)%20ai_run_response%20%3E%20(schema)%20%3E%20(variant)%2014">Link to this property</a>

</details>

[Link to this property](<#(resource)%20ai%20%3E%20(method)%20run%20%3E%20(network%20schema)%20%3E%20(property)%20result>)

### Run a Workers AI model

HTTP

HTTPTypeScriptPythonGoTerraform

```
curl https://api.cloudflare.com/client/v4/accounts/$ACCOUNT_ID/ai/run/$MODEL_NAME \
    -X POST \
    -H "Authorization: Bearer $CLOUDFLARE_API_TOKEN"
```

200 example

```
{
  "result": [
    {
      "label": "label",
      "score": 0
    }
  ]
}
```

##### Returns Examples

200 example

```
{
  "result": [
    {
      "label": "label",
      "score": 0
    }
  ]
}
```
---

---
description: Review recent changes to Cloudflare Workers AI.
title: Changelog
image: https://developers.cloudflare.com/workers-ai/changelog/og.png?v=1d28cd0448d2966e
---

[Skip to content](#main-content)

> Documentation Index  
> Fetch the complete documentation index at: https://developers.cloudflare.com/workers-ai/llms.txt  
> Use this file to discover all available pages before exploring further.

# Changelog

Last updated Apr 21, 2026|Copy as Markdown| [View as Markdown](https://developers.cloudflare.com/workers-ai/changelog/index.md)| [Agent setup](https://developers.cloudflare.com/agent-setup/)

[Subscribe to RSS](https://developers.cloudflare.com/workers-ai/changelog/index.xml)

## 2026-06-16

**GLM-5.2 now available on Workers AI**

- [`@cf/zai-org/glm-5.2`](https://developers.cloudflare.com/workers-ai/models/glm-5.2/) is now available on Workers AI. Z.ai's flagship agentic coding model with a 262,144 token context window, function calling, and reasoning support. Read [changelog](https://developers.cloudflare.com/changelog/2026-06-16-glm-5.2-workers-ai/) to get started.

## 2026-06-12

**Moonshot AI Kimi K2.7 Code now available on Workers AI**

- [`@cf/moonshotai/kimi-k2.7-code`](https://developers.cloudflare.com/workers-ai/models/kimi-k2.7-code/) now available on Workers AI. A frontier-scale 1T parameter MoE model optimized for coding, with a 262.1k context window, vision, multi-turn tool calling, and reasoning. Read [changelog](https://developers.cloudflare.com/changelog/post/2026-06-12-kimi-k2-7-code-workers-ai/) to get started.

## 2026-05-08

**Planned model deprecations**

- We are refreshing the Workers AI model catalog to make room for newer releases. Please update your apps to remove references to the models listed below before the deprecation date. Refer to the [changelog](https://developers.cloudflare.com/changelog/post/2026-05-08-planned-model-deprecations/) for full details.
- We recommend migrating to newer models such as [`@cf/zai-org/glm-4.7-flash`](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/) for fast tool-calling, [`@cf/google/gemma-4-26b-a4b-it`](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/) for an efficient open model, or [`@cf/moonshotai/kimi-k2.6`](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/) for a capable tool-calling and vision model.
- On May 30, 2026, requests to [`@cf/moonshotai/kimi-k2.5`](https://developers.cloudflare.com/workers-ai/models/kimi-k2.5/) will be automatically aliased to [`@cf/moonshotai/kimi-k2.6`](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/), which has a higher price. The deprecation date was extended from May 10, 2026. Please review the [K2.6 pricing and model capabilities](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/) prior to May 30, 2026.
- On May 30, 2026, the following models will be deprecated:
  - `@cf/moonshotai/kimi-k2.5` --> `@cf/moonshotai/kimi-k2.6`
  - `@hf/meta-llama/meta-llama-3-8b-instruct`
  - `@cf/meta/llama-3-8b-instruct`
  - `@cf/meta/llama-3-8b-instruct-awq`
  - `@cf/meta/llama-3.1-8b-instruct`
  - `@cf/meta/llama-3.1-8b-instruct-awq`
  - `@cf/meta/llama-3.1-70b-instruct`
  - `@cf/meta/llama-2-7b-chat-int8`
  - `@cf/meta/llama-2-7b-chat-fp16`
  - `@cf/mistral/mistral-7b-instruct-v0.1`
  - `@hf/mistral/mistral-7b-instruct-v0.2`
  - `@hf/google/gemma-7b-it`
  - `@cf/google/gemma-3-12b-it`
  - `@hf/nousresearch/hermes-2-pro-mistral-7b`
  - `@cf/microsoft/phi-2`
  - `@cf/defog/sqlcoder-7b-2`
  - `@cf/unum/uform-gen2-qwen-500m`
  - `@cf/facebook/bart-large-cnn`
- The `-fast` and `-lora` variants of models will remain active. LoRA models may be deprecated in the future, and we will communicate when new LoRA models come online to give users time to train new LoRAs before we deprecate old ones.

## 2026-04-20

**Moonshot AI Kimi K2.6 now available on Workers AI**

- [`@cf/moonshotai/kimi-k2.6`](https://developers.cloudflare.com/workers-ai/models/kimi-k2.6/) now available on Workers AI. The latest frontier-scale model from Moonshot AI with improved reasoning, coding, and agentic capabilities. Read [changelog](https://developers.cloudflare.com/changelog/post/2026-04-20-kimi-k2-6-workers-ai/) to get started.
- K2.6 uses the `chat_template_kwargs.thinking` parameter to control reasoning (instead of `chat_template_kwargs.enable_thinking`) and returns reasoning content in the `reasoning` field (instead of `reasoning_content`).

## 2026-04-04

**Google Gemma 4 26B A4B now available on Workers AI**

- [`@cf/google/gemma-4-26b-a4b-it`](https://developers.cloudflare.com/workers-ai/models/gemma-4-26b-a4b-it/) now available on Workers AI. A Mixture-of-Experts model with 26B total parameters and 4B active, featuring a 256K context window, vision, built-in thinking mode, and function calling. Read [changelog](https://developers.cloudflare.com/changelog/post/2026-04-04-gemma-4-26b-a4b-workers-ai/) to get started.

## 2026-03-19

**Moonshot AI Kimi K2.5 now available on Workers AI**

- [`@cf/moonshotai/kimi-k2.5`](https://developers.cloudflare.com/workers-ai/models/kimi-k2.5/) now available on Workers AI. A frontier-scale open-source model with a 256k context window, multi-turn tool calling, vision inputs, and structured outputs for agentic workloads. Read [changelog](https://developers.cloudflare.com/changelog/post/2026-03-19-kimi-k2-5-workers-ai/) to get started.
- New [Prompt caching](https://developers.cloudflare.com/workers-ai/features/prompt-caching/) documentation. Send the `x-session-affinity` header to route requests to the same model instance and maximize prefix cache hit rates across multi-turn conversations.
- Redesigned [Asynchronous Batch API](https://developers.cloudflare.com/workers-ai/features/batch-api/) with a pull-based system that processes queued requests as capacity becomes available, avoiding out-of-capacity errors for durable workflows.

## 2026-03-11

**NVIDIA Nemotron 3 Super now available on Workers AI**

- [`@cf/nvidia/nemotron-3-120b-a12b`](https://developers.cloudflare.com/workers-ai/models/nemotron-3-120b-a12b/) now available on Workers AI! A hybrid MoE model with 120B total parameters and 12B active, optimized for multi-agent and agentic AI workloads. Read [changelog](https://developers.cloudflare.com/changelog/post/2026-03-11-nemotron-3-super-workers-ai/) to get started.

## 2026-03-06

**Deepgram Nova-3 now supports 10 languages with regional variants**

- [`@cf/deepgram/nova-3`](https://developers.cloudflare.com/workers-ai/models/nova-3/) now supports 10 languages with regional variants for real-time transcription. Supported languages include English, Spanish, French, German, Hindi, Russian, Portuguese, Japanese, Italian, and Dutch — with regional variants like `en-GB`, `fr-CA`, and `pt-BR`.

## 2026-02-17

**Chat Completions API support for gpt-oss models and tool calling improvements**

- [`@cf/openai/gpt-oss-120b`](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/) and [`@cf/openai/gpt-oss-20b`](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b/) now support Chat Completions API format. Use `/v1/chat/completions` with a `messages` array, or use `/ai/run` which dynamically detects your input format and accepts Chat Completions ( `messages`), legacy Completions ( `prompt`), or Responses API ( `input`).
- **\[Bug fix]** Fixed a bug in the schema for multiple text generation models where the `content` field in message objects only accepted string values. The field now properly accepts both string content and array content (structured content parts for multi-modal inputs). This fix applies to all affected chat models including GPT-OSS models, Llama 3.x, Mistral, Qwen, and others.
- **\[Bug fix]** Tool call round-trips now work correctly. The binding no longer rejects `tool_call_id` values that it generated itself, fixing issues with multi-turn tool calling conversations.
- **\[Bug fix]** Assistant messages with `content: null` and `tool_calls` are now accepted in both the Workers AI binding and REST API ( `/v1/chat/completions`), fixing tool call round-trip failures.
- **\[Bug fix]** Streaming responses now correctly report `finish_reason` only on the usage chunk, matching OpenAI's streaming behavior and preventing duplicate finish events.
- **\[Bug fix]** `/v1/chat/completions` now preserves original tool call IDs from models instead of regenerating them. Previously, the endpoint was generating new IDs which broke multi-turn tool calling because AI SDK clients could not match tool results to their original calls.
- **\[Bug fix]** `/v1/chat/completions` now correctly reports `finish_reason: "tool_calls"` in the final usage chunk when tools are used. Previously, it was hardcoding `finish_reason: "stop"` which caused AI SDK clients to think the conversation was complete instead of executing tool calls.

## 2026-02-13

**GLM-4.7-Flash, @cloudflare/tanstack-ai, and workers-ai-provider v3.1.1**

- [`@cf/zai-org/glm-4.7-flash`](https://developers.cloudflare.com/workers-ai/models/glm-4.7-flash/) is now available on Workers AI! A fast and efficient multilingual text generation model optimized for multi-turn tool calling across 100+ languages. Read [changelog](https://developers.cloudflare.com/changelog/2026-02-13-glm-4.7-flash-workers-ai/) to get started.
- New [`@cloudflare/tanstack-ai`](https://www.npmjs.com/package/@cloudflare/tanstack-ai) package for using Workers AI and AI Gateway with TanStack AI.
- [`workers-ai-provider v3.1.1`](https://www.npmjs.com/package/workers-ai-provider) adds transcription, text-to-speech, and reranking capabilities.

## 2026-01-28

**Black Forest Labs FLUX.2 \[klein] 9B now available**

- [`@cf/black-forest-labs/flux-2-klein-9b`](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-9b/) now available on Workers AI! Read [changelog](https://developers.cloudflare.com/changelog/2026-01-28-flux-2-klein-9b-workers-ai/) to get started

## 2026-01-15

**Black Forest Labs FLUX.2 \[klein] 4b now available**

- [`@cf/black-forest-labs/flux-2-klein-4b`](https://developers.cloudflare.com/workers-ai/models/flux-2-klein-4b/) now available on Workers AI! Read [changelog](https://developers.cloudflare.com/changelog/2026-01-15-flux-2-klein-4b-workers-ai/) to get started

## 2025-12-03

**Deepgram Flux promotional period over on Dec 8, 2025 - now has pricing**

- Check out updated pricing on the [`@cf/deepgram/flux`](https://developers.cloudflare.com/workers-ai/models/flux/) model page or [pricing](https://developers.cloudflare.com/workers-ai/platform/pricing/) page
- Pricing will start Dec 8, 2025

## 2025-11-25

**Black Forest Labs FLUX.2 dev now available**

- [`@cf/black-forest-labs/flux-2-dev`](https://developers.cloudflare.com/workers-ai/models/flux-2-dev/) now available on Workers AI! Read [changelog](https://developers.cloudflare.com/changelog/2025-11-25-flux-2-dev-workers-ai/) to get started

## 2025-11-13

**Qwen3 LLM and Embeddings available on Workers AI**

- [`@cf/qwen/qwen3-30b-a3b-fp8`](https://developers.cloudflare.com/workers-ai/models/qwen3-30b-a3b-fp8/) and [`@cf/qwen/qwen3-embedding-0.6b`](https://developers.cloudflare.com/workers-ai/models/qwen3-embedding-0.6b) now available on Workers AI

## 2025-10-21

**New voice and LLM models on Workers AI**

- Deepgram Aura 2 brings new text-to-speech capabilities to Workers AI. Check out [`@cf/deepgram/aura-2-en`](https://developers.cloudflare.com/workers-ai/models/aura-2-en/) and [`@cf/deepgram/aura-2-es`](https://developers.cloudflare.com/workers-ai/models/aura-2-es/) on how to use the new models.
- IBM Granite model is also up! This new LLM model is small but mighty, take a look at the docs for more [`@cf/ibm-granite/granite-4.0-h-micro`](https://developers.cloudflare.com/workers-ai/models/granite-4.0-h-micro/)

## 2025-10-02

**Deepgram Flux now available on Workers AI**

- We're excited to be a launch partner with Deepgram and offer their new Speech Recognition model built specifically for enabling voice agents. Check out [Deepgram's blog](https://deepgram.com/flux) for more details on the release.
- Access the model through [`@cf/deepgram/flux`](https://developers.cloudflare.com/workers-ai/models/flux/) and check out the [changelog](https://developers.cloudflare.com/changelog/2025-10-02-deepgram-flux/) for in-depth examples.

## 2025-09-24

**New local models available on Workers AI**

- We've added support for some regional models on Workers AI in support of uplifting local AI labs and AI sovereignty. Check out the [full blog post here](https://blog.cloudflare.com/sovereign-ai-and-choice).
- [`@cf/pfnet/plamo-embedding-1b`](https://developers.cloudflare.com/workers-ai/models/plamo-embedding-1b) creates embeddings from Japanese text.
- [`@cf/aisingapore/gemma-sea-lion-v4-27b-it`](https://developers.cloudflare.com/workers-ai/models/gemma-sea-lion-v4-27b-it) is a fine-tuned model that supports multiple South East Asian languages, including Burmese, English, Indonesian, Khmer, Lao, Malay, Mandarin, Tagalog, Tamil, Thai, and Vietnamese.
- [`@cf/ai4bharat/indictrans2-en-indic-1B`](https://developers.cloudflare.com/workers-ai/models/indictrans2-en-indic-1B) is a translation model that can translate between 22 indic languages, including Bengali, Gujarati, Hindi, Tamil, Sanskrit and even traditionally low-resourced languages like Kashmiri, Manipuri and Sindhi.

## 2025-09-23

**New document formats supported by Markdown conversion utility**

- Our [Markdown conversion utility](https://developers.cloudflare.com/workers-ai/features/markdown-conversion/) now supports converting `.docx` and `.odt` files.

## 2025-09-18

**Model Catalog updates (types, EmbeddingGemma, model deprecation)**

- Workers AI types got updated in the upcoming wrangler release, please use `npm i -D wrangler@latest` to update your packages.
- EmbeddingGemma model accuracy has been improved, we recommend re-indexing data to take advantage of the improved accuracy
- Some older Workers AI models are being deprecated on October 1st, 2025. We reccommend you use the newer models such as [Llama 4](https://developers.cloudflare.com/workers-ai/models/llama-4-scout-17b-16e-instruct/) and [gpt-oss](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b/). The following models are being deprecated:
  - @hf/thebloke/zephyr-7b-beta-awq
  - @hf/thebloke/mistral-7b-instruct-v0.1-awq
  - @hf/thebloke/llama-2-13b-chat-awq
  - @hf/thebloke/openhermes-2.5-mistral-7b-awq
  - @hf/thebloke/neural-chat-7b-v3-1-awq
  - @hf/thebloke/llamaguard-7b-awq
  - @hf/thebloke/deepseek-coder-6.7b-base-awq
  - @hf/thebloke/deepseek-coder-6.7b-instruct-awq
  - @cf/deepseek-ai/deepseek-math-7b-instruct
  - @cf/openchat/openchat-3.5-0106
  - @cf/tiiuae/falcon-7b-instruct
  - @cf/thebloke/discolm-german-7b-v1-awq
  - @cf/qwen/qwen1.5-0.5b-chat
  - @cf/qwen/qwen1.5-7b-chat-awq
  - @cf/qwen/qwen1.5-14b-chat-awq
  - @cf/tinyllama/tinyllama-1.1b-chat-v1.0
  - @cf/qwen/qwen1.5-1.8b-chat
  - @hf/nexusflow/starling-lm-7b-beta
  - @cf/fblgit/una-cybertron-7b-v2-bf16

## 2025-09-05

**Introducing EmbeddingGemma from Google**

- We’re excited to be a launch partner alongside Google to bring their newest embedding model to Workers AI. We're excited to introduce EmbeddingGemma delivers best-in-class performance for its size, enabling RAG and semantic search use cases. Take a look at [`@cf/google/embeddinggemma-300m`](https://developers.cloudflare.com/workers-ai/models/embeddinggemma-300m) for more details. Now available to use for embedding in AI Search too.

## 2025-08-27

**Introducing Partner models to the Workers AI catalog**

- Read the [blog](https://blog.cloudflare.com/workers-ai-partner-models) for more details
- [`@cf/deepgram/aura-1`](https://developers.cloudflare.com/workers-ai/models/aura-1) is a text-to-speech model that allows you to input text and have it come to life in a customizable voice
- [`@cf/deepgram/nova-3`](https://developers.cloudflare.com/workers-ai/models/nova-3) is speech-to-text model that transcribes multilingual audio at a blazingly fast speed
- [`@cf/pipecat-ai/smart-turn-v2`](https://developers.cloudflare.com/workers-ai/models/smart-turn-v2) helps you detect when someone is done speaking
- [`@cf/leonardo/lucid-origin`](https://developers.cloudflare.com/workers-ai/models/lucid-origin) is a text-to-image model that generates images with sharp graphic design, stunning full-HD renders, or highly specific creative direction
- [`@cf/leonardo/phoenix-1.0`](https://developers.cloudflare.com/workers-ai/models/phoenix-1.0) is a text-to-image model with exceptional prompt adherence and coherent text
- WebSocket support added for audio models like `@cf/deepgram/aura-1`, `@cf/deepgram/nova-3`, `@cf/pipecat-ai/smart-turn-v2`

## 2025-08-05

**Adding gpt-oss models to our catalog**

- Check out the [blog](https://blog.cloudflare.com/openai-gpt-oss-on-workers-ai) for more details about the new models
- Take a look at the [`gpt-oss-120b`](https://developers.cloudflare.com/workers-ai/models/gpt-oss-120b) and [`gpt-oss-20b`](https://developers.cloudflare.com/workers-ai/models/gpt-oss-20b) model pages for more information about schemas, pricing, and context windows

## 2025-04-09

**Pricing correction for @cf/myshell-ai/melotts**

- We've updated our documentation to reflect the correct pricing for melotts: $0.0002 per audio minute, which is actually cheaper than initially stated. The documented pricing was incorrect, where it said users would be charged based on input tokens.

## 2025-03-17

**Minor updates to the model schema for llama-3.2-1b-instruct, whisper-large-v3-turbo, llama-guard**

- [llama-3.2-1b-instruct](https://developers.cloudflare.com/workers-ai/models/llama-3.2-1b-instruct/) - updated context window to the accurate 60,000
- [whisper-large-v3-turbo](https://developers.cloudflare.com/workers-ai/models/whisper-large-v3-turbo/) - new hyperparameters available
- [llama-guard-3-8b](https://developers.cloudflare.com/workers-ai/models/llama-guard-3-8b/) - the messages array must alternate between `user` and `assistant` to function correctly

## 2025-02-21

**Workers AI bug fixes**

- We fixed a bug where `max_tokens` defaults were not properly being respected - `max_tokens` now correctly defaults to `256` as displayed on the model pages. Users relying on the previous behaviour may observe this as a breaking change. If you want to generate more tokens, please set the `max_tokens` parameter to what you need.
- We updated model pages to show context windows - which is defined as the tokens used in the prompt + tokens used in the response. If your prompt + response tokens exceed the context window, the request will error. Please set `max_tokens` accordingly depending on your prompt length and the context window length to ensure a successful response.

## 2024-09-26

**Workers AI Birthday Week 2024 announcements**

- Meta Llama 3.2 1B, 3B, and 11B vision is now available on Workers AI
- `@cf/black-forest-labs/flux-1-schnell` is now available on Workers AI
- Workers AI is fast! Powered by new GPUs and optimizations, you can expect faster inference on Llama 3.1, Llama 3.2, and FLUX models.
- No more neurons. Workers AI is moving towards [unit-based pricing](https://developers.cloudflare.com/workers-ai/platform/pricing)
- Model pages get a refresh with better documentation on parameters, pricing, and model capabilities
- Closed beta for our Run Any\* Model feature, [sign up here](https://forms.gle/h7FcaTF4Zo5dzNb68)
- Check out the [product announcements blog post](https://blog.cloudflare.com/workers-ai) for more information
- And the [technical blog post](https://blog.cloudflare.com/workers-ai/making-workers-ai-faster) if you want to learn about how we made Workers AI fast

## 2024-07-23

**Meta Llama 3.1 now available on Workers AI**

Workers AI now suppoorts [Meta Llama 3.1](https://developers.cloudflare.com/workers-ai/models/llama-3.1-8b-instruct/).

## 2024-06-27

**Introducing embedded function calling**

- A new way to do function calling with [Embedded function calling](https://developers.cloudflare.com/workers-ai/function-calling/embedded)
- Published new [`@cloudflare/ai-utils`](https://www.npmjs.com/package/@cloudflare/ai-utils) npm package
- Open-sourced [`ai-utils on Github`](https://github.com/cloudflare/ai-utils)

## 2024-06-19

**Added support for traditional function calling**

- [Function calling](https://developers.cloudflare.com/workers-ai/function-calling/) is now supported on enabled models
- Properties added on [models](https://developers.cloudflare.com/workers-ai/models/) page to show which models support function calling

## 2024-06-18

**Native support for AI Gateways**

Workers AI now natively supports [AI Gateway](https://developers.cloudflare.com/ai-gateway/usage/providers/workersai/#worker).

## 2024-06-11

**Deprecation announcement for \`@cf/meta/llama-2-7b-chat-int8\`**

We will be deprecating `@cf/meta/llama-2-7b-chat-int8` on 2024-06-30.

Replace the model ID in your code with a new model of your choice:

- [`@cf/meta/llama-3-8b-instruct`](https://developers.cloudflare.com/workers-ai/models/llama-3-8b-instruct/) is the newest model in the Llama family (and is currently free for a limited time on Workers AI).
- [`@cf/meta/llama-3-8b-instruct-awq`](https://developers.cloudflare.com/workers-ai/models/llama-3-8b-instruct-awq/) is the new Llama 3 in a similar precision to your currently selected model. This model is also currently free for a limited time.

If you do not switch to a different model by June 30th, we will automatically start returning inference from `@cf/meta/llama-3-8b-instruct-awq`.

## 2024-05-29

**Add new public LoRAs and note on LoRA routing**

- Added documentation on [new public LoRAs](https://developers.cloudflare.com/workers-ai/fine-tunes/public-loras/).
- Noted that you can now run LoRA inference with the base model rather than explicitly calling the `-lora` version

## 2024-05-17

**Add OpenAI compatible API endpoints**

Added OpenAI compatible API endpoints for `/v1/chat/completions` and `/v1/embeddings`. For more details, refer to [Configurations](https://developers.cloudflare.com/workers-ai/configuration/open-ai-compatibility/).

## 2024-04-11

**Add AI native binding**

- Added new AI native binding, you can now run models with `const resp = await env.AI.run(modelName, inputs)`
- Deprecated `@cloudflare/ai` npm package. While existing solutions using the @cloudflare/ai package will continue to work, no new Workers AI features will be supported. Moving to native AI bindings is highly recommended

Was this helpful?

YesNo

## On this page

[![](https://developers.cloudflare.com/_astro/logo.te5VL_aD.svg)Docs](https://developers.cloudflare.com/)

```json
{"@context":"https://schema.org","@type":"BlogPosting","@id":"https://developers.cloudflare.com/workers-ai/changelog/#page","headline":"Changelog","description":"Review recent changes to Cloudflare Workers AI.","url":"https://developers.cloudflare.com/workers-ai/changelog/","inLanguage":"en","image":"https://developers.cloudflare.com/workers-ai/changelog/og.png?v=1d28cd0448d2966e","dateModified":"2026-04-21","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}
```
