---
title: "Cloudflare Workers AI - Edge AI Inference Platform"
description: "Run AI inference globally with one API call. 50+ models, serverless pricing, OpenAI-compatible API, and inference in 200+ cities worldwide."
url: "https://www.cloudflare.com/products/workers-ai"
---

# Workers AI

> Workers AI lets you run AI inference globally with one API call. No GPUs to manage, no capacity planning. Just intelligent machine learning models  running where they're needed, on Cloudflare's global network.

## Key Features

- 100+ AI models available
- LLMs: Llama 3, Mistral, Gemma
- Image: Stable Diffusion, FLUX
- Audio: Whisper, TTS
- Embeddings: BGE, multilingual models
- LoRA fine-tuning support
- Streaming responses

## Benefits

### Serverless pricing

Pay-per-inference pricing with no idle costs. No guessing what.

### Rich model catalog

50+ models running close to users in 200+ cities

### Widely compatible

One API call, works with any OpenAI SDK or task type

## Use Cases

### Image generation

Execute image generation, manipulation, and creative workflows without managing GPU infrastructure. Perfect for content platforms, social apps, and creative tools.

### Speech-to-text, in real-time

Transcribe, analyze, and generate audio content without specialized infrastructure. Built for voice agents, note-taking apps, and media processing.

### Embeddings

Create intelligent search, recommendations, and context-aware features using vector embeddings. Seamlessly integrates with Vectorize AI Search for complete AI workflows.

### LLMs

Perform a wide range of natural language tasks. Use large language models for text generation, classification, question answering, and other complex language-based operations through a simple API.

## Code Examples

### Build AI applications by calling any LLM

Call any LLM directly from your Worker with a simple API.

```typescript
const response = await env.AI.run("@cf/moonshotai/kimi-k2-6", { messages: [
    { role: "system", content: "You are a friendly assistant" },
    { role: "user", content: "What is the origin of the phrase Hello, World" },
  ]}
);
```

### Call LLMs via REST API

Use the REST API to call any LLM from any platform or language.

```curl
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" }]}'
```

### Generate images instantaneously

Generate images from your Worker using AI models.

```typescript
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 bengal cat vibe coding to music',
      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>;
```

### Generate images via REST API

Use the REST API to generate images from any platform.

```curl
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" }'
```

## Resources

- [Full Documentation](https://developers.cloudflare.com/workers-ai): Complete technical documentation
- [Get Started](https://dash.cloudflare.com/sign-up): Sign up and start building
- [Pricing](/plans.md): See pricing details

## Related Products

- [Agents](/products/agents.md): Build stateful AI agents
- [AI Gateway](/products/ai-gateway.md): AI observability
- [AI Search](/products/ai-search.md): Instant retrieval
- [Vectorize](/products/vectorize.md): Vector database

---

*This is a markdown version of [https://www.cloudflare.com/products/workers-ai](https://www.cloudflare.com/products/workers-ai) for AI/LLM consumption.*
