LLM chat completion (Llama 3.1 8B default)
llm_chat[PAID $0.003 USDC per call via x402 on Base; errors are free] One-shot LLM completion on Cloudflare Workers AI with a minimal interface: give prompt (and optionally system, or OpenAI-style messages), get {text, model, finish_reason, usage}. Models: llama-3.1-8b (default), llama-3.2-3b, llama-3.2-1b, mistral-7b, granite-4.0-micro. max_tokens capped at 512, input up to 24000 chars, Llama Guard 3 safety check, 503 "capacity" when the daily budget is used up. Errors are never charged. All params optional: with none it answers a short sample question. For the OpenAI wire format use POST /v1/chat/completions.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| model | No | Model alias (default llama-3.1-8b). | |
| prompt | No | User message. Optional: defaults to a short sample question. | |
| system | No | Optional system instruction. | |
| messages | No | Optional OpenAI-style history (POST JSON). | |
| max_tokens | No | Max output tokens (default/cap 512). | |
| temperature | No | Sampling temperature. |