Cloudflare AI Models
Cloudflare Workers AI hosts language, vision, image-generation, embedding, decision, and extraction models on Cloudflare's global network. AvalAI provides access with an AvalAI API key and public cf.* model IDs. Choose the endpoint for the task: conversational models, typed decision models, and extraction models use different request and response schemas.
Eight New Models: Extraction, Decisions, and Open Models
Reviewed: October 24, 2026. These eight models are available from AvalAI tier 0. The tables record AvalAI's public IDs, token limits, and prices; linked Cloudflare pages describe the upstream models. Send the AvalAI ID, not the Workers AI identifier, in your AvalAI request's model field.
| AvalAI model ID | Purpose and official model source | Context / maximum input tokens |
|---|---|---|
cf.clairic | Typed extraction (preview) | 65536 |
cf.clef | 27B typed decision model | 65536 |
cf.clef-flash | Fast 9B typed decision model | 24576 |
cf.clef-omni | Multimodal decisions, 30B / 3B active | 64000 |
cf.phonellm-mini-alpha-2 | Text dialogue for voice agents | 262140 |
cf.apertus-v1.5-8b | 8B multilingual open model | 262144 |
cf.eurollm-9b-it | 9B multilingual instruction model | 32768 |
cf.moondream3.1-9b-a2b | Vision-language model, 9B / 2B active | 32768 |
Keep cf.moondream3.1-9b-a2b lowercase in AvalAI requests; Cloudflare’s model page spells the upstream name moondream3.1-9B-A2B. Context figures describe the cataloged capacity, not a guaranteed output budget. State, instructions, question or field schemas, and supported media consume request capacity. AvalAI's EuroLLM catalog lists 32768 tokens, while Cloudflare's model page lists 32000; the table uses the AvalAI limit. The Apertus limit comes from AvalAI's rate-limit catalog and agrees with Cloudflare's 262144-token context.
Pricing
Prices are USD per 1 million tokens, with input, cached input, and output billed separately:
| AvalAI model ID | Input | Cached input | Output |
|---|---|---|---|
cf.clairic | $0.10 | $0.00 | $0.00 |
cf.clef | $0.24 | $0.00 | $0.00 |
cf.clef-flash | $0.038 | $0.00 | $0.00 |
cf.clef-omni | $0.15 | $0.00 | $0.00 |
cf.phonellm-mini-alpha-2 | $0.06 | $0.006 | $0.24 |
cf.apertus-v1.5-8b | $0.10 | $0.01 | $0.20 |
cf.eurollm-9b-it | $0.10 | $0.01 | $0.20 |
cf.moondream3.1-9b-a2b | $0.30 | $0.03 | $1.00 |
Zero output pricing for Clairic and Clef means that their typed answers have no output-token charge; the input is still billable. For example, a total of 100,000 uncached billable input tokens across requests costs $0.01 with Clairic or $0.0038 with Clef-flash; this is an aggregate billing example, not a single-request size. Use the endpoint's reported usage, including schema and media work where applicable, to reconcile a request. A cached-input price applies to tokens actually accounted for as cached; it does not establish cache hits, a cache lifetime, or support for cache-control parameters. See pricing and response headers.
Clairic: Typed Extraction
cf.clairic is Cloudflare's preview extraction model. Define named fields with explicit types, supply source text, and read typed answers rather than generated conversation text. Its native schema supports nine field types: text, number, date, time, datetime, duration, list, estimate, and forecast, with confidence or distribution information appropriate to the field type. An unsupported or missing fact may produce value: null; a plausible guess does not replace that null value.
Use POST /v1/extraction through AvalAI. Clairic is not a Chat Completions or Clef decision model. The Extraction API reference documents state, fields, optional image inputs, and the keyed answers envelope. The extraction-model guide explains source spans, uncertainty, missing values, and application validation. Cloudflare describes embedded image support upstream; use the reference's format and limits rather than passing Chat Completions image_url content or assuming remote URLs are accepted.
Clef: Typed Multimodal Decisions
The Clef family evaluates evidence against explicit questions and returns choices, scores, or yes/no probabilities:
cf.clefis the 27B-parameter model for typed judgments over text, structured state, and upstream image inputs.cf.clef-flashis the fast 9B-parameter alternative with a smaller context and lower input price.cf.clef-omniuses a 30B-parameter mixture-of-experts backbone with 3B active parameters. Its native schema adds embedded audio and video to text, structured state, and images.
All three use /v1/decisions and /v1/systemone in AvalAI. The Decisions reference uses input and an array of questions; the System One reference uses state and a question map with native noul, choice, and score types. The response envelopes also differ. These models do not use /v1/chat/completions, /v1/responses, /v1/messages, or /v1/extraction.
Cloudflare's descriptions mention video for Clef and Clef-flash, but their raw native schemas expose images and do not define videos. Reserve audio/video claims for Clef-omni. Native media fields are not automatically valid Decisions fields, and upstream media support does not establish an executed AvalAI media request. Follow the System One media-scope notes for formats, size limits, and verification boundaries. Keep downstream actions subject to your application's permissions and validation; a model judgment does not authorize an action.
PhoneLLM, Apertus, EuroLLM, and Moondream
These four models use /v1/chat/completions for the documented conversational workflows:
cf.phonellm-mini-alpha-2is Daily's open text model tuned for voice-agent dialogue. Cloudflare describes it as based on Nemotron Nano 30B capabilities, with thinking disabled. AvalAI's catalog enables function calling for this ID. Voice-agent tuning describes its dialogue behavior; it does not establish speech recognition, audio input, or speech output. Use separate speech components for those parts of a voice pipeline.cf.apertus-v1.5-8bis Swiss AI's 8B multilingual model, developed with fully open training data. Cloudflare advertises vision and function calling upstream, but AvalAI's catalog disables function calling for this ID. This page documents text chat; do not infer AvalAI vision or tool support from the upstream badges.cf.eurollm-9b-itis the 9B instruction-tuned EuroLLM model. Cloudflare reports training on 4 trillion tokens drawn from multilingual web, parallel, and curated high-quality data. Use it for multilingual dialogue and text tasks, with the AvalAI context limit shown above.cf.moondream3.1-9b-a2bis a vision-language model with 9B total and 2B active parameters. Cloudflare describes visual reasoning, OCR, object detection, and pointing. AvalAI exposes the model through the Chat Completions vision format; see the vision guide. Cloudflare's nativetask: query/caption/point/detect,image,target, andreasoningfields belong to its native skill API and are not established AvalAI Chat Completions parameters or response shapes.
Text Chat Example with PhoneLLM
Read AVALAI_API_KEY from your server environment. For the Python and Node.js versions, install the corresponding openai SDK in your application's environment; the JavaScript example is a Node.js ES module. All three clients below send the same JSON request. They use a 60-second timeout and make one attempt; the SDK examples disable automatic retries.
curl --fail-with-body --connect-timeout 10 --max-time 60 \
https://api.avalai.ir/v1/chat/completions \
-H "Authorization: Bearer $AVALAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "cf.phonellm-mini-alpha-2",
"messages": [
{"role": "system", "content": "Return one short sentence suitable for a voice assistant."},
{"role": "user", "content": "Confirm that my appointment is booked for Tuesday at 10 AM."}
],
"max_tokens": 256
}'import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
timeout=60.0,
max_retries=0,
)
response = client.chat.completions.create(
model="cf.phonellm-mini-alpha-2",
messages=[
{
"role": "system",
"content": "Return one short sentence suitable for a voice assistant.",
},
{
"role": "user",
"content": "Confirm that my appointment is booked for Tuesday at 10 AM.",
},
],
max_tokens=256,
)
print(response.choices[0].message.content)import OpenAI from "openai";
const client = new OpenAI({
apiKey: process.env.AVALAI_API_KEY,
baseURL: "https://api.avalai.ir/v1",
timeout: 60000,
maxRetries: 0,
});
const response = await client.chat.completions.create({
model: "cf.phonellm-mini-alpha-2",
messages: [
{ role: "system", content: "Return one short sentence suitable for a voice assistant." },
{ role: "user", content: "Confirm that my appointment is booked for Tuesday at 10 AM." },
],
max_tokens: 256,
});
console.log(response.choices[0].message.content);The following is a complete illustrative Chat Completions response, with invented text, identifiers, and token counts. It is not a captured AvalAI result or a billing receipt. The hypothetical estimated_cost uses the listed PhoneLLM rates, the sample token counts, and an illustrative exchange rate of 270000 toman per USD:
{
"id": "chatcmpl-example",
"object": "chat.completion",
"created": 1792843200,
"model": "cf.phonellm-mini-alpha-2",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Your appointment is booked for Tuesday at 10 AM."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 33,
"completion_tokens": 12,
"total_tokens": 45
},
"estimated_cost": {
"unit": "0.0000048600",
"irt": 1.31,
"exchange_rate": 270000
}
}Read text from choices[0].message.content and inspect finish_reason and actual usage. The appointment message is synthetic test input; a generated confirmation does not verify a booking in your application. Change only model to cf.apertus-v1.5-8b or cf.eurollm-9b-it for a text-only comparison, then evaluate the response in your own workflow. For images with Moondream, use the vision message structure instead. For Clairic or Clef, choose their dedicated endpoint and schema rather than changing this example's model ID.
On an HTTP error, inspect the returned error body and retain avalai-request-id when present. Correct invalid fields or a mismatched model/endpoint before retrying; authentication and exhausted quota require intervention. This example adds no retry loop. See the error-handling guide for troubleshooting. The requests and client code are schema-based examples; live model responses, optional features, and SDK execution require separate validation with your account.
Available Models
Cloudflare AI models span multiple categories and providers, from compact text models to larger reasoning systems. The following sections cover other model families; use the task-specific endpoint guidance above for the eight new IDs.
Meta Llama Models
Cloudflare hosts a comprehensive collection of Meta's Llama models, from the latest Llama 4 Scout to various versions of Llama 3.x series.
| Model | Parameters | Specialization | Context Window |
|---|---|---|---|
cf.llama-4-scout-17b-16e-instruct | 17B (16 experts) | Multimodal, Text & Image | 128K |
cf.llama-3.3-70b-instruct-fp8-fast | 70B (FP8) | Fast inference, General purpose | 128K |
cf.llama-3.1-8b-instruct-fast | 8B | Fast multilingual dialogue | 128K |
cf.llama-3.1-8b-instruct-awq | 8B (int4) | Efficient inference | 128K |
cf.llama-3.1-8b-instruct-fp8 | 8B (FP8) | Balanced performance | 128K |
cf.llama-3.1-8b-instruct | 8B | Standard dialogue | 128K |
cf.llama-3.1-70b-instruct | 70B | Complex reasoning | 128K |
cf.llama-3.2-1b-instruct | 1B | Compact dialogue | 128K |
cf.llama-3.2-3b-instruct | 3B | Agentic tasks | 128K |
cf.meta-llama-3-8b-instruct | 8B | Improved reasoning | 8K |
cf.llama-3-8b-instruct-awq | 8B (int4) | Efficient deployment | 8K |
cf.llama-3-8b-instruct | 8B | Standard instruction | 8K |
cf.llama-guard-3-8b | 8B | Content safety | 8K |
Llama 4 Scout - Multimodal Excellence
The newest addition to the Llama family, featuring native multimodal capabilities:
from openai import OpenAI
client = OpenAI(api_key="your-avalai-api-key", base_url="https://api.avalai.ir/v1")
# Text and image understanding
completion = client.chat.completions.create(
model="cf.llama-4-scout-17b-16e-instruct",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What's in this image?"},
{
"type": "image_url",
"image_url": {"url": "data:image/jpeg;base64,..."},
},
],
}
],
)Responses API version This version uses `gpt-5.5` because `cf.llama-4-scout-17b-16e-instruct` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
response = client.responses.create(
model="gpt-5.6-luna",
input=[
{
"role": "user",
"content": [
{"type": "input_text", "text": "Describe this image."},
{"type": "input_image", "image_url": "https://example.com/image.png"},
],
}
],
)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
Google Gemma Models
Google's Gemma models offer excellent performance with multilingual capabilities and LoRA support.
| Model | Parameters | Specialization | Context Window |
|---|---|---|---|
cf.gemma-3-12b-it | 12B | Multimodal, 140+ languages | 128K |
cf.gemma-7b-it-lora | 7B | LoRA fine-tuning | 8K |
cf.gemma-2b-it-lora | 2B | Compact LoRA | 8K |
cf.gemma-7b-it | 7B | General instruction | 8K |
Gemma 3 - Advanced Multimodal
# Gemma 3 with extended context
completion = client.chat.completions.create(
model="cf.gemma-3-12b-it",
messages=[
{
"role": "user",
"content": "Analyze this document and provide a comprehensive summary.",
}
],
max_tokens=2048,
)Responses API version This version uses `gpt-5.5` because `cf.gemma-3-12b-it` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
response = client.responses.create(
model="gpt-5.6-luna",
input=[
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Analyze this document and provide a comprehensive summary.",
},
{"type": "input_file", "file_id": "file_abc123"},
],
}
],
)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
Mistral AI Models
Mistral's latest models with enhanced vision understanding and extended context capabilities.
| Model | Parameters | Specialization | Context Window |
|---|---|---|---|
cf.mistral-small-3.1-24b-instruct | 24B | Vision + Text, Function calling | 128K |
Mistral Small 3.1 - Vision Enhanced
# Function calling with vision
completion = client.chat.completions.create(
model="cf.mistral-small-3.1-24b-instruct",
messages=[
{"role": "user", "content": "Analyze this chart and extract the key metrics"}
],
tools=[
{
"type": "function",
"function": {
"name": "extract_metrics",
"description": "Extract numerical metrics from data",
"parameters": {
"type": "object",
"properties": {
"metrics": {"type": "array", "items": {"type": "number"}}
},
},
},
}
],
)Responses API version This version uses `gpt-5.5` because `cf.mistral-small-3.1-24b-instruct` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
tools = [
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location.",
"parameters": {
"type": "object",
"properties": {"location": {"type": "string"}},
"required": ["location"],
"additionalProperties": False,
},
}
]
response = client.responses.create(
model="gpt-5.6-luna",
input="Analyze this chart and extract the key metrics",
tools=tools,
)
for item in response.output:
if item.type == "function_call":
print(item.name, item.arguments)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
Qwen Models
Alibaba's Qwen models specialized for reasoning, code generation, and embeddings.
| Model | Parameters | Specialization | Context Window |
|---|---|---|---|
cf.qwq-32b | 32B | Advanced reasoning | 32K |
cf.qwen2.5-coder-32b-instruct | 32B | Code generation | 128K |
cf.qwen3-30b-a3b-fp8 | 30B (FP8) | Chat, balanced performance | 128K |
cf.qwen3-embedding-0.6b | 0.6B | Text embeddings | N/A |
QwQ - Reasoning Model
# Advanced reasoning tasks
completion = client.chat.completions.create(
model="cf.qwq-32b",
messages=[
{
"role": "user",
"content": "Solve this complex math problem step by step: If a train travels 120 km in 2 hours, and then increases its speed by 20%, how long will it take to travel the next 180 km?",
}
],
temperature=0.1, # Lower temperature for reasoning tasks
)Responses API version This version uses `gpt-5.5` because `cf.qwq-32b` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
response = client.responses.create(
model="gpt-5.6-luna",
instructions="You are a helpful assistant.",
input="Solve this complex math problem step by step: If a train travels 120 km in 2 hours, and then increases its speed by 20%, how long will it take to travel the next 180 km?",
)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
Qwen2.5-Coder - Programming Specialist
# Code generation and explanation
completion = client.chat.completions.create(
model="cf.qwen2.5-coder-32b-instruct",
messages=[
{
"role": "user",
"content": "Write a Python function to implement a binary search tree with insert, search, and delete operations.",
}
],
)Responses API version This version uses `gpt-5.5` because `cf.qwen2.5-coder-32b-instruct` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
response = client.responses.create(
model="gpt-5.6-luna",
instructions="You are a helpful assistant.",
input="Write a Python function to implement a binary search tree with insert, search, and delete operations.",
)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
DeepSeek Models
DeepSeek's distilled reasoning models offering competitive performance.
| Model | Parameters | Specialization | Context Window |
|---|---|---|---|
cf.deepseek-r1-distill-qwen-32b | 32B | Reasoning, outperforms o1-mini | 128K |
OpenAI Open Source Models
OpenAI's open-weight models available on Cloudflare's edge network.
| Model | Parameters | Specialization | Context Window |
|---|---|---|---|
cf.gpt-oss-120b | 120B | Large-scale reasoning | 128K |
cf.gpt-oss-20b | 20B | Efficient general purpose | 128K |
NVIDIA Nemotron Models
NVIDIA's latest Nemotron models with hybrid LatentMoE architecture.
| Model | Parameters | Specialization | Context Window |
|---|---|---|---|
cf.nemotron-3-120b-a12b | 120B (12B active) | Agentic workflows, long-context reasoning | 1M |
Nemotron-3-120B-A12B - Agentic Excellence
NVIDIA's Nemotron-3-Super-120B-A12B is a large language model designed to deliver strong agentic, reasoning, and conversational capabilities. It employs a hybrid LatentMoE architecture utilizing interleaved Mamba-2 and MoE layers with Multi-Token Prediction (MTP) for faster text generation.
| Feature | Details |
|---|---|
| Total Parameters | 120B (12B active) |
| Architecture | LatentMoE - Mamba-2 + MoE + Attention hybrid |
| Context window | 1,000,000 tokens |
| Input pricing | $0.50 / 1M tokens |
| Cached input pricing | $0.05 / 1M tokens (90% cost reduction) |
| Output pricing | $1.50 / 1M tokens |
| Supported languages | English, French, German, Italian, Japanese, Spanish, Chinese |
| Best for | Agentic workflows, long-context reasoning, high-volume workloads, IT ticket automation |
Key Features:
- 1M Context Window: Industry-leading context length for extensive documents
- Configurable Reasoning: Enable or disable reasoning mode via chat template
- Multi-Token Prediction: MTP layers for faster text generation
- Tool Use & RAG: Excellent for tool calling and retrieval-augmented generation
- Cost-Effective: Only 12B active parameters for exceptional efficiency
Benchmark Highlights:
- SWE-Bench (OpenHands): 60.47%
- AIME 2025: 90.21%
- HMMT Feb 2025 (with tools): 94.73%
- LiveCodeBench: 81.19%
from openai import OpenAI
client = OpenAI(api_key="your-avalai-api-key", base_url="https://api.avalai.ir/v1")
# Long-context reasoning with Nemotron
completion = client.chat.completions.create(
model="cf.nemotron-3-120b-a12b",
messages=[
{
"role": "user",
"content": "Analyze this extensive codebase and suggest architectural improvements for better scalability.",
}
],
temperature=1.0, # Recommended setting for Nemotron
top_p=0.95,
)
print(completion.choices[0].message.content)Responses API version This version uses `gpt-5.5` because `cf.nemotron-3-120b-a12b` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
response = client.responses.create(
model="gpt-5.6-luna",
instructions="You are a helpful assistant.",
input="Analyze this extensive codebase and suggest architectural improvements for better scalability.",
)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
IBM Granite Models
IBM's Granite models for enterprise applications.
| Model | Parameters | Specialization | Context Window |
|---|---|---|---|
cf.granite-4.0-h-micro | Micro | Efficient enterprise chat | 128K |
Image Generation Models
Cloudflare AI offers powerful image generation models via the v1/images/generations endpoint.
| Model | Description | Base Price (1MP) |
|---|---|---|
cf.flux-2-klein-9b | FLUX 2 Klein 9B parameter model | $0.015/image |
cf.flux-2-klein-4b | FLUX 2 Klein 4B compact model | $0.010/image |
cf.flux-2-dev | FLUX 2 Development model | $0.010/image |
cf.lucid-origin | Lucid Origin image generation | $0.015/image |
cf.phoenix-1.0 | Phoenix 1.0 image generation | $0.015/image |
Image Generation Example
from openai import OpenAI
client = OpenAI(api_key="your-avalai-api-key", base_url="https://api.avalai.ir/v1")
# Generate an image with FLUX 2 Klein
response = client.images.generate(
model="cf.flux-2-klein-9b",
prompt="A futuristic cityscape at sunset with flying cars",
n=1,
size="1024x1024",
)
print(response.data[0].url)Embedding Models
Cloudflare AI provides embedding models for semantic search and text analysis via the v1/embeddings endpoint.
| Model | Owner | Description | Input Price ($/1M tokens) |
|---|---|---|---|
cf.qwen3-embedding-0.6b | Alibaba | Qwen3 Embedding 0.6B | $0.012 |
cf.plamo-embedding-1b | PFN | PLaMo Embedding 1B | $0.019 |
cf.embeddinggemma-300m | EmbeddingGemma 300M | $0.012 |
Embedding Example
from openai import OpenAI
client = OpenAI(api_key="your-avalai-api-key", base_url="https://api.avalai.ir/v1")
# Generate embeddings
response = client.embeddings.create(
model="cf.qwen3-embedding-0.6b",
input="Machine learning enables computers to learn from data.",
)
embedding = response.data[0].embedding
print(f"Embedding dimension: {len(embedding)}")Key Parameters
The following parameters apply to conversational models that support them through Chat Completions. Defaults and limits vary by model; the table is not a contract for every Cloudflare model. Clairic and Clef use the fields in their dedicated endpoint references:
| Parameter | Description | Default | Range |
|---|---|---|---|
temperature | Controls randomness | 0.7 | 0.0-2.0 |
max_tokens | Maximum response length | 2048 | 1-4096 |
top_p | Nucleus sampling | 1.0 | 0.0-1.0 |
frequency_penalty | Reduces repetition | 0.0 | -2.0-2.0 |
presence_penalty | Encourages new topics | 0.0 | -2.0-2.0 |
API Endpoints
Cloudflare models are available through multiple AvalAI endpoints depending on model type:
- Chat Completions:
/v1/chat/completionsfor enabled conversational and vision models, including PhoneLLM, Apertus, EuroLLM, and Moondream above. - Extraction:
/v1/extractionforcf.clairic. - Decisions:
/v1/decisionsand native/v1/systemoneforcf.clef,cf.clef-flash, andcf.clef-omni. - Responses:
/v1/responsesonly for models enabled for that route; support is model-specific and may be partial. - Embeddings:
/v1/embeddingsfor embedding models. - Image Generation:
/v1/images/generationsfor image-generation models. - Messages:
/v1/messagesonly for models enabled for that route; support is model-specific and may be partial.
The new Clairic and Clef IDs are excluded from Chat Completions, Responses, and Messages. This launch does not announce Responses or Messages support for the four new conversational models. The existing Responses adaptation examples below select a different enabled model; they do not establish Responses support for the Cloudflare ID in the paired chat example.
Example Usage
Basic Text Generation
from openai import OpenAI
client = OpenAI(api_key="your-avalai-api-key", base_url="https://api.avalai.ir/v1")
completion = client.chat.completions.create(
model="cf.llama-3.1-8b-instruct",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Explain quantum computing in simple terms."},
],
temperature=0.7,
max_tokens=1024,
)
print(completion.choices[0].message.content)Responses API version This version uses `gpt-5.5` because `cf.llama-3.1-8b-instruct` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
response = client.responses.create(
model="gpt-5.6-luna",
instructions="You are a helpful assistant.",
input="Explain quantum computing in simple terms.",
)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
Streaming Responses
# Streaming for real-time responses
stream = client.chat.completions.create(
model="cf.llama-3.3-70b-instruct-fp8-fast",
messages=[
{"role": "user", "content": "Write a short story about AI and humanity."}
],
stream=True,
)
for chunk in stream:
if chunk.choices[0].delta.content is not None:
print(chunk.choices[0].delta.content, end="")Responses API version This version uses `gpt-5.5` because `cf.llama-3.3-70b-instruct-fp8-fast` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
response = client.responses.create(
model="gpt-5.6-luna",
instructions="You are a helpful assistant.",
input="Write a short story about AI and humanity.",
)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
Function Calling
# Function calling with supported models
completion = client.chat.completions.create(
model="cf.mistral-small-3.1-24b-instruct",
messages=[{"role": "user", "content": "What's the weather like in Paris?"}],
tools=[
{
"type": "function",
"function": {
"name": "get_weather",
"description": "Get current weather for a city",
"parameters": {
"type": "object",
"properties": {
"city": {"type": "string", "description": "City name"}
},
"required": ["city"],
},
},
}
],
)Responses API version This version uses `gpt-5.5` because `cf.mistral-small-3.1-24b-instruct` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
tools = [
{
"type": "function",
"name": "get_current_weather",
"description": "Get the current weather in a given location.",
"parameters": {
"type": "object",
"properties": {"location": {"type": "string"}},
"required": ["location"],
"additionalProperties": False,
},
}
]
response = client.responses.create(
model="gpt-5.6-luna",
input="What",
tools=tools,
)
for item in response.output:
if item.type == "function_call":
print(item.name, item.arguments)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
Best Practices
Model Selection
- For speed: Use FP8 or AWQ quantized models like
cf.llama-3.3-70b-instruct-fp8-fast - For reasoning: Choose
cf.qwq-32borcf.deepseek-r1-distill-qwen-32b - For code: Use
cf.qwen2.5-coder-32b-instruct - For multimodal: Select
cf.llama-4-scout-17b-16e-instructorcf.gemma-3-12b-it - For efficiency: Try compact models like
cf.llama-3.2-1b-instruct
Performance Optimization
- Use appropriate quantization: FP8 models offer good balance of speed and quality
- Leverage edge deployment: Models run on Cloudflare's global network for low latency
- Context management: Budget state, instructions, supported media, and output against the selected model’s limits; the new models have different contexts as listed above
- Streaming: Enable streaming for better user experience in interactive applications
Content Safety
Implement cf.llama-guard-3-8bfor content moderation:
# Content safety check
safety_check = client.chat.completions.create(
model="cf.llama-guard-3-8b",
messages=[{"role": "user", "content": "User message to check for safety"}],
)Responses API version This version uses `gpt-5.5` because `cf.llama-guard-3-8b` may not be enabled for `/v1/responses` in the current AvalAI model data.
Use this version when the selected model supports /v1/responses. messages moves to input, and the final text is read from response.output_text.
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["AVALAI_API_KEY"],
base_url="https://api.avalai.ir/v1",
)
response = client.responses.create(
model="gpt-5.6-luna",
instructions="You are a helpful assistant.",
input="User message to check for safety",
)
print(response.output_text)messages→input- system message →
instructionsor adeveloperitem choices[0].message.content→response.output_text- for tools and multimodal output, inspect
response.outputby itemtype.
Using Cloudflare Models via AvalAI
Cloudflare models use AvalAI authentication, with the endpoint and request format selected for each task. Enabled conversational models use Chat Completions; Clairic uses Extraction, and Clef uses Decisions or native System One. Reuse an existing client only when it implements the selected endpoint's schema.
Authentication
client = OpenAI(
api_key="your-avalai-api-key", # Your AvalAI API key
base_url="https://api.avalai.ir/v1", # AvalAI endpoint
)Rate Limits
Cloudflare models follow AvalAI's standard rate limiting policies. Check your tier limits in the Rate Limits Guide.