Skip to main content

CLF AI Gateway

https://clfaigateway.dev/docs

CLF AI Gateway is an OpenAI-compatible gateway that serves open-weight models. It is an independent service and is not affiliated with Cloudflare; for Cloudflare's own inference product see Cloudflare Workers AI

tip

Set model=clf_ai_gateway/<model> to route a request through CLF AI Gateway. The current model list is at https://clfaigateway.dev/models and from GET /v1/models. The clf_ai_gateway provider works Since v1.109.0.

API Key​

import os

os.environ["CLF_AI_GATEWAY_API_KEY"] = "sk-gw-..."
os.environ["CLF_AI_GATEWAY_API_BASE"] = "https://api.clfaigateway.dev/v1" # optional, this is the default

CLF_AI_GATEWAY_API_BASE only needs to be set when you are pointing LiteLLM at a different endpoint. Leaving it unset uses https://api.clfaigateway.dev/v1

Sample Usage​

from litellm import completion
import os

os.environ["CLF_AI_GATEWAY_API_KEY"] = "sk-gw-..."

response = completion(
model="clf_ai_gateway/glm-5.3",
messages=[{"role": "user", "content": "What character was Wall-e in love with?"}],
)
print(response)

Sample Usage - Streaming​

from litellm import completion
import os

os.environ["CLF_AI_GATEWAY_API_KEY"] = "sk-gw-..."

response = completion(
model="clf_ai_gateway/glm-5.3",
messages=[{"role": "user", "content": "What character was Wall-e in love with?"}],
stream=True,
)

for chunk in response:
print(chunk)

Reasoning​

Every model on the gateway is a reasoning model, so reasoning_effort is accepted on all of them. The levels each model takes differ, and LiteLLM reads them from the model map rather than assuming a single set. The Supported Models table lists them.

from litellm import completion
import os

os.environ["CLF_AI_GATEWAY_API_KEY"] = "sk-gw-..."

response = completion(
model="clf_ai_gateway/glm-5.3",
messages=[{"role": "user", "content": "How many r's are in strawberry?"}],
reasoning_effort="high",
)
print(response)

Reasoning tokens are counted inside completion_tokens, so they are billed at the output price rather than separately.

A level the model does not list is sent as is, so the gateway's 400 error reaches you. With drop_params on, LiteLLM drops that level and the request runs without one. A Responses-style dict such as {"effort": "low", "summary": "auto"} is sent as its effort level. A dict without an effort level, such as {"summary": "auto"}, gets a 400 error from LiteLLM, and drop_params drops it instead.

An Anthropic /v1/messages request with a thinking budget of 4096 tokens or more becomes reasoning_effort="high". qwen3.8-27b does not take high, so send that model a smaller budget or turn on drop_params.

Usage with LiteLLM Proxy Server​

  1. Add the model to your config.yaml
model_list:
- model_name: my-model
litellm_params:
model: clf_ai_gateway/glm-5.3
api_key: os.environ/CLF_AI_GATEWAY_API_KEY
  1. Start the proxy
$ litellm --config /path/to/config.yaml
  1. Send a request
import openai

client = openai.OpenAI(
api_key="litellm-proxy-key",
base_url="http://0.0.0.0:4000",
)

response = client.chat.completions.create(
model="my-model",
messages=[{"role": "user", "content": "What character was Wall-e in love with?"}],
)

print(response)

Supported Models​

All of these support tool calling, JSON mode, and reasoning.

ModelContext windowVisionreasoning_effort levels
clf_ai_gateway/glm-5.31,048,576nolow, medium, high, max
clf_ai_gateway/glm-5.3-flash1,048,576yeslow, medium, high, xhigh, max
clf_ai_gateway/glm-5.2262,144nolow, medium, high, xhigh, max
clf_ai_gateway/glm-4.7-flash131,072nolow, medium, high
clf_ai_gateway/kimi-k2.7-code262,144yeslow, medium, high
clf_ai_gateway/kimi-k2.6262,144yesnone, low, medium, high
clf_ai_gateway/deepseek-v4-pro1,048,576nolow, medium, high, xhigh, max
clf_ai_gateway/deepseek-v4-flash1,048,576nolow, medium, high, xhigh, max
clf_ai_gateway/deepseek-v4.1-flash1,048,576yesnone, low, medium, high, xhigh, max
clf_ai_gateway/qwen3.8-27b262,144yeslow, medium, xhigh

A gateway model that is not in this table works too, but LiteLLM cannot track its cost and refuses reasoning_effort for it. On the proxy, set model_info: {supports_reasoning: true} and its prices on the deployment to fix both.

Supported Parameters​

ParameterTypeDescription
frequency_penaltynumberPenalizes new tokens based on their frequency in the text
logit_biasobjectChanges how likely the given tokens are to appear
logprobsbooleanWhether to return the log probabilities of the output tokens
max_completion_tokensintegerMaximum number of tokens to generate
max_tokensintegerMaximum number of tokens to generate
nintegerNumber of completions to generate
parallel_tool_callsbooleanWhether the model may call several tools at once
presence_penaltynumberPenalizes tokens based on whether they appear in the text so far
reasoning_effortstringHow much the model reasons before answering
response_formatobjectFormat of the response, e.g. {"type": "json_object"}
seedintegerSampling seed for deterministic results
service_tierstringProcessing tier for the request
stopstring/arraySequences where the API stops generating tokens
storebooleanWhether the gateway stores the completion
streambooleanWhether to stream the response
stream_optionsobjectOptions for streaming, e.g. {"include_usage": true}
temperaturenumberControls randomness
tool_choicestring/objectControls which tool, if any, the model calls
toolsarrayList of tools the model can use
top_logprobsintegerNumber of most likely tokens to return at each position, with logprobs
top_pnumberControls nucleus sampling
userstringUser identifier

The gateway answers 400 unknown_parameter for a field outside its API, such as functions, function_call, prompt_cache_key, or safety_identifier. LiteLLM does not send these fields. Without drop_params, LiteLLM returns a 400 error for them, and with drop_params on it drops them. Codex sends prompt_cache_key on every turn, so turn on drop_params for a CLF AI Gateway model you use from Codex.

Prompt Caching​

The gateway caches recognized prompt prefixes automatically. Cached input tokens come back in prompt_tokens_details.cached_tokens and are billed at the model's cached input price, which LiteLLM reads from the model map for cost tracking

LiteLLM Enterprise
SSO/SAML, audit logs, spend tracking, multi-team management, and guardrails, built for production.
Learn more →