chat_completion
Send a chat message list to Cloudflare Workers AI and get a complete assistant reply for summarization, translation, Q&A, classification, or code generation.
Instructions
Run an LLM chat completion using Cloudflare Workers AI. Use this tool when you need direct LLM inference with an explicit message list (system/user/assistant roles) — for example summarization, translation, Q&A, classification, or code generation. The request is sent to the Workers AI OpenAI-compatible endpoint and the full assistant reply is returned as a single text block together with the model id and finish reason. No streaming is performed. Requires CLOUDFLARE_ACCOUNT_ID and CLOUDFLARE_API_TOKEN environment variables; costs are billed to your Cloudflare account (free tier available).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | Yes | Workers AI chat model id. Available models: @cf/meta/llama-3.3-70b-instruct-fp8-fast (default, strong generalist), @cf/meta/infire-llama-3.1-8b-instruct (small and cheap), @cf/meta/llama-4-scout-17b-16e-instruct, @cf/qwen/qwen2.5-coder-32b-instruct (coding), @cf/deepseek-ai/deepseek-r1-distill-qwen-32b (reasoning). Call list_models for the full catalog. | |
| messages | Yes | Chat messages in chronological order. Use role system for instructions, user for the human input, assistant for prior model replies when continuing a conversation. | |
| max_tokens | No | Maximum number of tokens to generate. Default 512. Lower values return faster and cheaper; higher values allow longer replies. | |
| temperature | No | Sampling temperature between 0 and 2. Default 0.7. Lower values produce more deterministic output; higher values increase creativity and variety. |