Inference gateway
The Platform Agent talks to an LLM through a Completions API proxy so provider choice is a config toggle. There are shipping options for both hosted and local models, plus a replay layer.
Choosing a provider
Section titled “Choosing a provider”| You want | Use | Why |
|---|---|---|
| Fastest path with a hosted frontier model | LiteLLM → Gemini (default) | One API key, no GPU node pool, no cluster egress beyond the LiteLLM pod. |
| Provider redundancy or A/B | LiteLLM → Gemini + Anthropic + OpenAI | LiteLLM handles the router config; agent config is unchanged. |
| Inference billed to your own GCP project | LiteLLM → Vertex AI / Model Garden | Workload Identity by default instead of an API key (or a SA key Secret); Gemini plus Model Garden publishers. See below. |
| Free local prototyping with a consumer subscription | LiteLLM → ChatGPT subscription (OAuth device flow) | See examples/litellm-chatgpt-subscription/. |
| Model traffic kept off hosted model providers | LiteLLM → your OpenAI-compatible server (openai_compatible) |
vLLM, TGI or an internal gateway, in the cluster or on your network. Google APIs stay required. See below. |
| Model traffic through your SAP tenant, or another LiteLLM provider | LiteLLM → SAP AI Core (sap), or the provider’s slug |
Credentials in a Secret you create, named with --litellm-env-secret; an OpenAI-compatible gateway behind OAuth2 client credentials uses the same Secret. See below. |
| Deterministic demos / cheap tests | Any of the above + inference-replay proxy | Caches responses in a PVC; replays on cache hit. |
LiteLLM (hosted models)
Section titled “LiteLLM (hosted models)”LiteLLM is an OpenAI-Completions-compatible proxy in front of every major model provider. The kube-agents Helm chart deploys it with the API key you provide (the dev copy is make -C k8s-operator deploy-litellm).
What ships
Section titled “What ships”examples/litellm-gemini/— Gemini-only default. UsesGEMINI_API_KEY.examples/litellm-chatgpt-subscription/— proxies to a personal ChatGPT subscription via OAuth device flow. Useful for demos where you don’t want a per-token cost.
To switch providers, edit the LiteLLM config.yaml (mounted from a ConfigMap) and set the corresponding API key secret. The Platform Agent config doesn’t change — it always talks to a Service named inference-gateway.
Setting the default model
Section titled “Setting the default model”The agent always requests a single logical model, model-default. LiteLLM maps that alias to a real provider model in its config.yaml:
model_list: - model_name: model-default litellm_params: model: ${MODEL_PROVIDER}/${MODEL_DEFAULT_NAME}Two things have to name that alias, not one. The profile config covers Chat, which resolves the model on every message; sessions created through the agent’s HTTP API instead take a model resolved once at gateway startup, and that path reads API_SERVER_MODEL_NAME. The operator sets both from the same constant so they cannot drift — if they do, Chat keeps working while every API-created session (autonomous event triage, for one) dies asking LiteLLM for a model it does not serve.
The two substituted values come from the install (MODEL_PROVIDER and MODEL_DEFAULT_NAME, saved in install.env and carried into the chart values). Supported providers and their shipping defaults:
MODEL_PROVIDER |
Default MODEL_DEFAULT_NAME |
Notes |
|---|---|---|
gemini (default) |
gemini-3.8-flash |
Uses GEMINI_API_KEY. |
anthropic |
claude-opus-5 |
Uses ANTHROPIC_API_KEY. |
openai |
gpt-5.4 |
Uses OPENAI_API_KEY. |
vertex_ai |
gemini-3.8-flash |
Workload Identity by default (or a SA key Secret). See below. |
openai_compatible |
none; required | Optional OPENAI_COMPATIBLE_API_KEY. The base URL is required too. See below. |
sap |
anthropic--claude-4.5-sonnet |
OAuth2 client credentials from a Secret you create. See below. |
| any other LiteLLM slug | none; required | azure, bedrock, databricks, …; credentials from the same Secret. See below. |
Any model string the chosen provider accepts is valid — there is no allow-list in the harness. For example, examples/litellm-gemini/ pins gemini-3.1-flash-lite.
For a Claude model (anthropic, vertex_ai with a claude- model name, or sap with an anthropic-- model name) the chart adds additional_drop_params: ["temperature", "top_p", "top_k"] under every alias. Claude Opus 5 refuses all three with a 400, and a caller can send them without knowing which model sits behind model-default, so the gateway removes them from every request before it reaches the provider. A caller therefore cannot set sampling on a Claude model behind any of these three providers. The kustomize dev copy does not render the key.
To change the default on an installed system, re-run the installer with --menu (e.g. ./install.sh --menu or $HOME/kube-agents/install.sh --menu) and use the model-provider entry followed by Save & Apply — one terraform apply rewrites the LiteLLM ConfigMap and rolls the gateway. On a dev cluster, set the variables and redeploy the dev copy:
export MODEL_PROVIDER=geminiexport MODEL_DEFAULT_NAME=gemini-3.8-flashmake -C k8s-operator deploy-litellmEither way the agent picks up the new model on its next request without any change to its own config.
Setting the output-token budget
Section titled “Setting the output-token budget”MODEL_MAX_TOKENS is the number of output tokens the gateway asks the provider for on a request that names none. Set it in install.env or with --model-max-tokens=N; it reaches the chart as litellm.maxTokens and the Terraform example as model_max_tokens, and the chart renders it as max_tokens under every model_list alias. With MODEL_PROVIDER=gemini and MODEL_MAX_TOKENS=8192 the first alias reads:
model_list: - model_name: model-default litellm_params: model: gemini/gemini-3.8-flash max_tokens: 8192The chart is the only path that renders it: the kustomize dev copy above (make -C k8s-operator deploy-litellm) carries no max_tokens. On an installed system, set the key in install.env and re-run upgrade.sh, or use install.sh --menu and Save & Apply, which regenerates from install.env; there is no menu entry for it.
At the default of 0 nothing is rendered and the gateway config is what it was. The hosted providers above need no value: the agent’s requests carry their own max_tokens, and a provider with its own output limit answers a value above it with an error rather than a truncated reply. A self-hosted backend such as vLLM, SGLang, TGI or llama.cpp admits a request only if the prompt and max_tokens together fit its served window. A request that asks for more output than the window holds is refused before the model runs. Set the value below that window, leaving the prompt the room it needs.
The gateway supplies the value as a fallback default when a request omits max_tokens: LiteLLM lets a client-supplied max_tokens win over the one in litellm_params. The agent image pinned today (Hermes v2026.9.14) does not send max_tokens on agent turns, so this value is the one the agent’s requests get, the same as a direct call to the gateway’s /v1/chat/completions that omits the field. Images built on v2026.8.19 and earlier sent their own max_tokens on every request; on those the client’s value won for agent turns and only a request that omitted the field took the configured one.
On non-adaptive Anthropic Claude models, LiteLLM maps fallback.reasoningEffort (low, medium, high) to thinking.budget_tokens (1024, 2048, 4096), and Anthropic requires max_tokens > thinking.budget_tokens. When setting litellm.maxTokens alongside fallback.reasoningEffort on a Claude model, set maxTokens strictly above that effort budget (for example, > 4096 for high).
Setting a spend ceiling
Section titled “Setting a spend ceiling”LITELLM_BUDGET_USD is the most the gateway spends, in US dollars as LiteLLM’s cost map prices each response, in every window of LITELLM_BUDGET_PERIOD (a LiteLLM duration: a whole number and s, m, h, d, w or mo; the default is 1d). Set both in install.env (there is no flag) and re-run upgrade.sh; they reach the Terraform example as litellm_budget and the chart as litellm.budget.usd and litellm.budget.period. On a direct Helm install set them through a values file or --set-json litellm.budget.usd=25: --set passes a decimal as a string, which the schema refuses.
At the default of 0 nothing is rendered and the gateway config is what it was. On, the amount is at least 0.01: the installer, the Terraform example and the chart’s schema all refuse less, before any apply, because a smaller amount splits into per-replica shares the chart cannot render.
The chart renders the ceiling as LiteLLM’s provider budget for the one provider every alias routes to, with the amount split evenly across litellm.replicaCount. With MODEL_PROVIDER=vertex_ai, LITELLM_BUDGET_USD=10 and the default two replicas the config reads:
router_settings: provider_budget_config: vertex_ai: budget_limit: 5.0000 time_period: "1d"LiteLLM counts spend per gateway process, in memory, and the chart runs no Redis to share the count, so each replica holds one share. Uneven traffic can make one replica refuse before the install has spent the whole amount. The ceiling is a bound on a runaway, not a ledger. LiteLLM checks the share before a call and charges the call’s cost after the call completes. Every call in flight when a share is crossed therefore completes and is charged, so a replica can end a window over its share by the cost of those calls. The Platform Agent runs several workers, and a streamed turn lasts minutes.
A rolling update adds a third pod with a share of its own while it lasts, and a gateway restart or rollout starts that pod’s count over.
A replica whose share is spent refuses every model call until its window ends. The first window of a gateway process starts when the pod starts, not at its first spend; once a window has expired, the next spend opens the next one. The caller gets HTTP 429 with No deployments available - crossed budget: Exceeded budget for provider vertex_ai: <spend> >= <limit>, and the gateway logs the same line. The agent’s turn fails as it does on a rate limit; nothing on the PlatformAgent reports the state yet.
Each gateway pod exports the remaining share as litellm_provider_remaining_budget_metric{api_provider="vertex_ai"} on its /metrics, which the chart’s PodMonitoring collects. The series appears at the pod’s first routing decision and is set on every one: the share less the spend charged so far, at or below 0 while the replica refuses, negative by the in-flight overshoot. sum it over the gateway pods for the install’s remaining budget. The per-key and per-team budget series keep reading inf: they describe LiteLLM virtual keys, which this install does not use.
A model that LiteLLM’s cost map does not price costs 0 on every call, so litellm_spend_metric does not move and the ceiling is never reached. Check that the series moves on your model before you rely on the ceiling. A ceiling whose per-replica share would round to 0.0000 fails the render, because LiteLLM reads a budget_limit of 0 as no limit; raise the amount or lower litellm.replicaCount. Why the ceiling is split rather than shared, and what is still to come on the PlatformAgent: docs/designs/gateway-spend-cap.md.
Caller authentication
Section titled “Caller authentication”The gateway checks the key each caller sends. The chart runs LiteLLM with a master key, which it generates into the litellm-master-key Secret on first install and keeps across upgrades (litellm.masterKey.generate: false turns that off for offline renders such as Argo CD). Only the gateway container reads that Secret, and the master key is what reaches LiteLLM’s admin routes. Every other caller goes through a LiteLLM custom_auth hook that the chart mounts beside the gateway’s config.yaml (charts/kube-agents/files/litellm_caller_auth.py):
- A key whose SHA-256 is listed in the
litellm-caller-keysSecret is admitted as the caller class the entry names. LiteLLM reports the class as theapi_key_aliasandteamlabels on its spend and token metrics, and the key’s digest, never the key, ashashed_api_key. - A call with no key, or with a placeholder the install’s own clients send (
none,a2a-playground, and the agent runtime’sno-key-required), is admitted as the classkeyless. So is the unexpanded${LITELLM_API_KEY}, which the agent can send for a moment while its pod rolls onto its own key. - A key listed under the reserved class
gateway-probereachesGET /v1/modelsand nothing else. It lets a readiness check confirm that a gateway pod has loaded the current map without sending any caller’s key. - Any other key is refused with HTTP 401.
An admitted caller other than the admin reaches the inference routes only: /v1/chat/completions, /chat/completions, /v1/messages, /v1/messages/count_tokens, /v1/models, /models, /model/info, /v1/model/info and /health, and the Gemini-format generation calls /v1beta/models/<model>:generateContent, :streamGenerateContent and :countTokens. Any other route answers 401. The probes (/health/liveliness, /health/readiness) take no key, and /metrics stays open to the managed Prometheus scrape (litellm_settings.require_auth_for_metrics_endpoint: false).
litellm-caller-keys holds one key, keys.json: a JSON object from a key’s lowercase hex SHA-256 to its class name, digests only. The gateway mounts it as a directory and re-reads the file when it changes, so adding or removing a key needs no restart.
While the Secret is absent the gateway knows no caller key. A call with no key or a placeholder is still admitted as keyless. A caller that sends its class’s key is refused until the operator writes the map again on its next pass. The gateway’s NetworkPolicy still decides which pods reach it at all. The kustomize dev base mounts the same hook and reads litellm-master-key only if you created it; without it, nothing reaches the admin routes.
Which key each caller sends
Section titled “Which key each caller sends”The operator mints one key per caller class and gives a class’s callers its key once the gateway serves it. When a pass finds InferenceKeysServed True, the operator marks each class’s key Secret, and from the next pass it renders that class’s callers with a reference to the Secret:
| Caller | Class | How it sends the key |
|---|---|---|
The agent pod’s platform-agent container and the hermes-bridge sidecar the operator renders |
agent |
Env LITELLM_API_KEY from <agent>-inference-key-agent. The managed config’s model.api_key reads ${LITELLM_API_KEY}. |
| The curator | curator |
Env LITELLM_API_KEY from <agent>-inference-key-curator. |
| AgentProfile workers: warm pools, Jobs and scheduled runs | tier-<tier> |
Env ANTHROPIC_API_KEY from <agent>-inference-key-tier-<tier> in the profile namespace. ANTHROPIC_BASE_URL stays set. |
A2A session pods, the shell sandbox, Hindsight and the web console send no key and are admitted as keyless.
Each caller restarts once when it gains its key. It keeps the key when the condition later goes False or Unknown, as it does when a new tier’s key joins the map or the gateway pods roll: an unchanged key stays in every later map. A key the operator rewrites, such as a repaired malformed one, loses its mark, and its callers go back to the placeholder until the map holding the new key is served. Each move restarts the caller once.
The references aren’t optional. A caller whose key Secret is deleted fails to start rather than start as another class; the operator creates a new key and the caller goes back to the placeholder until that key is served. Pods already running on a key whose Secret was deleted from outside the operator are refused until they’re replaced. While the agent pod restarts, the old pod may already read the new config without the env, and sends ${LITELLM_API_KEY} unexpanded; the gateway admits that literal as keyless.
Fallback alias and parameter dropping
Section titled “Fallback alias and parameter dropping”Two chart blocks, both off by default, add a fallback alias and router retry limits when a primary call fails. At their defaults nothing is rendered, so the gateway config and its rollout checksum are what they were.
litellm.fallback.reasoningEffort (low, medium or high) adds a fallback alias for the same model at its own reasoning effort, named litellm.fallback.modelName or <model>-<effort> by default. "minimal" is omitted because Vertex AI Gemini 3.x Flash rejects thinkingLevel: "minimal" with HTTP 400 and Claude maps it to a 1024-token thinking budget. It also renders a router_settings.fallbacks entry that routes each primary alias (model-default, hermes-agent and the model name) to the fallback once primary retries are spent.
litellm.fallback.timeoutSeconds and numRetries render router_settings.timeout and num_retries (both default to 0, omitting the keys).
litellm.fallback.retryAfterSeconds renders router_settings.retry_after, the shortest pause before each retry. LiteLLM’s own pause starts at half a second and is clamped to eight, so a per-minute quota’s 429 is retried inside the same closed minute. A value above eight also raises that clamp (MAX_RETRY_DELAY on the gateway). It needs numRetries above 0; the render fails without it. The retries are a silent hold on the caller’s stream, numRetries + 1 pauses long. The render refuses a pair whose hold plus 60 s for the first chunk crosses the agents’ 120 s stale-stream bound, past which the agent drops the stream and never sees the 429. Measured on Vertex gemini-3.5-flash, a 600-second request cap covered 99.96% of streams while 300 seconds covers 99.57%.
The render fails if litellm.fallback.modelName is set without litellm.fallback.reasoningEffort or matches a primary alias name. With fallback.reasoningEffort: low and gemini-3.8-flash on Vertex AI the result reads:
model_list: - model_name: model-default litellm_params: model: vertex_ai/gemini-3.8-flash thinking: { "type": "enabled" } # hermes-agent and gemini-3.8-flash: the same - model_name: "gemini-3.8-flash-low" litellm_params: model: vertex_ai/gemini-3.8-flash reasoning_effort: "low"litellm_settings: drop_params: true callbacks: [ "prometheus", "litellm_thinking_replay_callback.proxy_handler_instance", "litellm_cache_control_strip_callback.proxy_handler_instance", ]router_settings: fallbacks: - model-default: ["gemini-3.8-flash-low"] # one entry per primary aliasThe primary aliases keep the thinking key that a Gemini 2.5 or 3.x model gets (Gemini’s thoughts). The fallback alias never gets it: it carries its own reasoning_effort, and the two on one alias fail every Gemini 3.x request.
litellm.dropParams: true (or setting litellm.fallback.reasoningEffort) renders drop_params: true, which tells LiteLLM to drop a parameter the provider does not accept rather than fail the request (for example, temperature != 1.0 when Anthropic Claude thinking is enabled). It drops silently. LiteLLM decides whether a model takes reasoning_effort from its model cost map, so on a model the map does not list, the effort can vanish from every request with no error. Check the model is in the map before you rely on the two together.
A fallback is not silent. The gateway’s reply carries x-litellm-attempted-fallbacks (how many fallbacks it tried), x-litellm-model-group (the alias that answered) and x-litellm-attempted-retries. With LiteLLM’s log level at INFO the pod also logs Falling back to model_group = <alias> and Successful fallback b/w models.; the chart does not raise the level.
Setting the reasoning effort
Section titled “Setting the reasoning effort”litellm.reasoningEffort is the reasoning effort the gateway asks the model for on a request that names none: low, medium or high. The chart renders it as reasoning_effort under every model_list alias. With litellm.modelProvider=vertex_ai and litellm.reasoningEffort=high the first alias reads:
model_list: - model_name: model-default litellm_params: model: vertex_ai/gemini-3.8-flash reasoning_effort: "high"LiteLLM translates the value for each provider. On Gemini 3.x, through gemini or vertex_ai, it becomes thinkingConfig.thinkingLevel on the request to Google. On Claude it becomes adaptive thinking with that effort, and OpenAI and openai_compatible servers receive reasoning_effort as written. A model that LiteLLM does not treat as a reasoning model, such as gemini-2.0-flash, fails every request with UnsupportedParamsError, so leave the value empty for one.
A vLLM server passes the value to the model’s chat template, which decides what each level means. GLM-5.3’s template, for example, recognizes only low and high. Anything else, medium included, runs at max, its default and slowest level, with no error. vLLM’s Gemma 4 template has no effort field: every value is ignored, and thinking is a server-side template setting. Check the served model’s template before relying on a level.
At the default, empty, no reasoning_effort is rendered and the model thinks at its own default level; a Gemini 2.5 or 3.x model keeps the thinking key described in Gemini’s thoughts. The value is a default the gateway supplies, the same as max_tokens above: LiteLLM lets a request’s own reasoning_effort win over the one in litellm_params. The operator reports the value an install is configured with in status.inference.reasoningEffort (CRD reference), absent at the default.
The chart is the only path that renders it. The kustomize dev copy carries no reasoning_effort, and neither install.env nor the Terraform example has a variable for it. Set it through the Terraform example’s extra_helm_values ({ litellm = { reasoningEffort = "high" } }) or with --set litellm.reasoningEffort=high on a direct Helm install.
Prompt caching
Section titled “Prompt caching”Agent turns are mostly re-sent context: the same system prompt, skills, and conversation tail go up again on every tool call. Anthropic-family models bill that at full price unless the request marks where the reusable prefix ends, and the marks have to be in the request. So when the default model is an Anthropic-family one (MODEL_PROVIDER=anthropic, vertex_ai with a claude- model, or the openrouter provider slug with an anthropic/claude- model), the gateway adds them, via cache_control_injection_points in its config.yaml:
router_settings: default_litellm_params: cache_control_injection_points: - location: message role: system control: type: ephemeral ttl: 1h - location: message index: -3 - location: message index: -1The agent cannot do this itself, and that is the point of putting it here. It asks for model-default over the Completions API, so the harness never learns what is behind the alias. (Each profile’s turn context does get the backing model name from the model_identity plugin, but only so it can answer users who ask; the harness does not read it.)
The harness also only emits its own cache markers when it recognises a Claude-named model — so on an Anthropic backend it caches nothing. Teaching it otherwise would mean naming the model in the agent config, which is exactly the coupling the gateway exists to prevent. A 45-call agent session measured 3.5M input tokens and zero cache reads before this block; the first cron tick after it re-ran the same 83k-token prompt as a cache write, and subsequent ticks read it back.
The system prompt takes the 1h tier because it is the largest static span, every profile and cron tick shares it, and a read refreshes the TTL. So a half-hourly cron schedule keeps it warm instead of missing a 5-minute window every time. The two rolling points ride the conversation tail on the default 5-minute tier. Anthropic allows four breakpoints per request; LiteLLM counts any the caller supplied and never overwrites them, so a client with its own layout still wins.
Any other model gets no breakpoints. On Gemini, LiteLLM turns these markers into Vertex explicit context caching: before every model call it lists the project’s cached contents, and it creates a new cache whenever the cached prefix is new. A create that Vertex is slow to finish fails the whole turn: in one case it surfaced as a 401 after a stall of more than ten minutes. Gemini’s implicit caching needs no markers and still serves a repeated prefix from cache.
The chart reads the same provider and model name as the sampling-key drop above, with two differences. A Claude model behind sap gets the drop and no breakpoints. A Claude model behind openrouter gets the breakpoints and no drop, because OpenRouter accepts the sampling keys. That covers OpenRouter’s latest aliases too, such as ~anthropic/claude-opus-latest. Switching MODEL_PROVIDER re-renders both. The kustomize dev copy adds them for MODEL_PROVIDER=anthropic only, in its anthropic overlay; vertex_ai with a claude- model and openrouter with an anthropic/claude- one get them only through the chart.
A caller can also bring its own markers: a client such as Claude Code marks its prompt-cache breakpoints itself, without knowing which model is behind model-default. On a Gemini model LiteLLM would turn those markers into the same explicit-caching create, and gemini-4-argon, which has no explicit caching, answers every such request 400. The chart loads a pre-call hook that removes a caller’s cache_control markers from a request bound for a Gemini model and leaves a request to any other model as sent. The gateway log records each request it changed, as kube_agents.litellm_cache_control_strip INFO cache markers: dropped N cache_control marker(s) bound for a Gemini model. The kustomize dev copy does not load it.
Implicit caching lives on the Vertex replica that served the request. Without a session_id, Vertex picks the replica from the system prompt and the first message. A conversation’s later turns read its own earlier ones, but the first turn of a new conversation lands somewhere new. It pays full price for a system prompt and tool list that another conversation sent moments before.
Setting litellm.vertex.sessionAffinity.enabled=true on a vertex_ai install adds a pre-call hook that sends each Gemini conversation a session_id. The id is the same on every turn and on every gateway replica, and conversations with the same prompt share it. A new conversation therefore lands on a replica that another used in the last few minutes, while it is still warm. slots (default 2) is how many ids one prompt is spread across; 1 puts every concurrent conversation of a profile on one replica, which queues.
Vertex honours session_id only on a project with session routing enabled (its LLM_SESSION_ID label), and elsewhere accepts the field and ignores it. A session_id the caller sets in extra_body is kept. The hook runs after redaction, so the id never comes from text redaction removed; with redaction on, set SESSION_KV_SALT so its pseudonyms, and the ids, match across gateway replicas. The gateway log says session affinity: sending session_id on the first request it stamps, and session affinity: new conversation on each conversation’s first request, with short digests of the prompt and tool list the id came from and never their text. The value is chart-only: the kustomize dev copy has no equivalent, and terraform/examples/full-install reaches it through extra_helm_values.
The LLM_SESSION_ID label is granted per project on request, with no documented customer process, and the gateway logs the same lines whether or not a project has it. The value is unsupported: it carries no compatibility promise and may change meaning, change default or be removed between releases, so an install that sets it re-checks it at every upgrade.
Gemini’s thoughts
Section titled “Gemini’s thoughts”Gemini thinks before it answers whether or not a request asks it to, but it returns those thoughts only when the request sets thinkingConfig.includeThoughts. With it off, Gemini 3.x has been seen writing its reasoning into the answer instead, under a first line thought, where nothing downstream can tell it from the answer. To give the thoughts a channel of their own, for a Gemini 2.5 or 3.x model through gemini or vertex_ai the chart renders thinking under every model_list alias:
model_list: - model_name: model-default litellm_params: model: vertex_ai/gemini-3.8-flash thinking: { "type": "enabled" }LiteLLM maps it to includeThoughts alone, with no thinkingLevel or thinkingBudget, so the model thinks as deeply as it did before and its thought summaries come back as reasoning_content beside the answer. The agent keeps them out of its replies. The agent’s API answers with the reply text alone, and the Slack and Google Chat gateways never display reasoning. The agent image never uses the reasoning as a reply, which the harness would otherwise do for a turn that ends with reasoning and no answer, or a safety refusal that gives no explanation. /reasoning show answers that display is turned off, and a show_reasoning setting in the agent’s config has no effect.
No other model gets the key. LiteLLM refuses it on a model it does not treat as a reasoning model, such as gemini-2.0-flash, and on Claude it would turn thinking on. Setting litellm.reasoningEffort replaces it: LiteLLM asks for the thoughts with that value too, and refuses the two together on Gemini 3.x. A request that names its own reasoning_effort overrides it the same way. The kustomize dev copy does not render the key.
Replayed thinking on Gemini
Section titled “Replayed thinking on Gemini”A client that turns thinking on, as Claude Code does, sends each earlier turn’s thinking back in the next request. LiteLLM releases before v1.106.0 passed that thinking to a Gemini model as ordinary text rather than as a thought. Gemini then read its earlier thought summaries as things it said and opened its next answers with more of them: a bold step title and a line such as “I will now draft the report”. No prompt reached that text. The release the install pins (Container images) carries the upstream fix.
Both the chart and the kustomize base still load a pre-call hook that drops replayed thinking blocks from earlier assistant turns before the request goes to a Gemini model. It removes more than the upstream fix does. Thinking still streams back, and requests to any other model, Claude above all, go out as sent. The gateway log records each request it changed, as kube_agents.litellm_thinking_replay INFO thinking replay: dropped N replayed thinking block(s) bound for a Gemini model.
Redaction at the gateway
Section titled “Redaction at the gateway”Everything the agent observes on a cluster goes up in the next request: pod IPs, cluster and project names, and whatever credential material a command printed. The gateway is the one point every provider request transits, so it is where redaction runs.
litellm.redaction.enabled=true in the chart values mounts the shared redactor module (a copy of the chat plugins’ AuditRedactor, kept identical by a test) and a LiteLLM pre-call hook beside config.yaml.
Before LiteLLM calls the provider, the hook rewrites every top-level field of the request except generation settings and the gateway’s own bookkeeping. That covers:
- the conversation, in any shape the gateway serves: chat and Anthropic
messages, and Geminicontentsunder/v1beta/models/...; - the system text, tool definitions, embeddings
inputand a completionprompt; - any newer field.
Each field is walked whole, so a value is redacted wherever it sits: a tool’s input, what a tool returned, or an assistant message’s other fields. A tool call’s arguments held as JSON in a string are decoded first. A key name such as password then counts as it does in a mapping, and the arguments stay valid JSON.
A tool’s output that is a whole JSON object or array is decoded the same way, so the structure rules apply to it too: key names, a Secret’s data, and env pairs. That covers a chat tool message’s string content, an Anthropic tool result, a Responses function call output and the top-level strings in a Gemini function response (up to 64), plus whole JSON nested up to two levels inside one. The text rules run first, over the output as it came, and what is decoded is their result, so decoding only adds to what is masked.
Output over 256 KiB, more than 64 levels deep, with a repeated key or that isn’t whole JSON is matched as text only. At most 32 nested strings of one output are decoded. Output no rule changed goes on as it came. A changed one keeps its indent width and separators; numbers, escapes and other spacing are normalised.
A few fields are left as they came. They are kept only where the provider APIs put them: content parts, a tool result’s own content list, the system blocks and Gemini parts. That includes the parts of a Responses input item or function call output, and the parts inside a Gemini function response. Beyond those parts, nothing inside a tool’s input or output is kept. The kept fields are:
- in the assistant’s own turn, a thinking block’s text and signature, which the provider checks against each other. The model wrote that text from input the hook had already redacted;
- redacted thinking and a thought signature, in the same turn;
- provider-encrypted content, which the provider checks byte for byte. That is a Responses reasoning item’s
encrypted_content, and in the assistant’s turn a web search result’sencrypted_content, thereasoning_detailsdata and signature, and thethought_signatureLiteLLM carries on the message and its tool calls; - binary payloads of a listed type (common images, PDF, audio and video) that decode as base64 and start the way their media type does. A payload of any other type is refused.
A request the hook cannot walk is refused with 400, since the same request is refused every time and a caller shouldn’t retry it. That is one with no conversation, input or prompt, a messages or contents that is not a list of objects, or anything at one of the payload positions above that is not binary base64. JSON nested too deeply for the hook to follow is refused the same way: tool-call arguments too deep to decode, or any value too deep to walk.
Content the provider holds from elsewhere, such as a cached-content or uploaded-file reference, is not something this hook sees.
The rendered default config does not change while the value is off.
Three layers run, in this order:
-
The built-in credential patterns, always on. They match:
- GCP API keys and OAuth tokens, PEM private keys, bearer and basic auth values;
- GitHub, OpenAI, Anthropic and Slack tokens, AWS access key IDs, JWTs;
- the password in a URL (
scheme://user:password@host, unless it holds,,;, a quote or an unencoded/,?or#; a JSON escape such as\u0026counts as one character); - secret-shaped key/value pairs (a block scalar’s lines included), and container env entries whose name is secret-shaped (in YAML and in JSON);
- Kubernetes Secret
data:blocks and thedata/stringDataobjects of JSON that holds a Secret; - e-mail addresses other than service-account principals.
These are masked (
[REDACTED_SECRET],[REDACTED_PRIVATE_KEY],[REDACTED_EMAIL]). Atrue,false,nullornonevalue, or an env reference such as$(DB_PASSWORD), is left as it is under a secret-shaped name, soautomountServiceAccountToken: falsestill reads as a boolean. JSON held inside a JSON string, such as thekubectl.kubernetes.io/last-applied-configurationannotation inkubectl get -o json, is decoded and redacted the same way. -
IP literals, IPv4 and IPv6, under
litellm.redaction.ip.action: pseudonym(the default) replaces each with[ip:<12 hex>];maskreplaces each with[REDACTED_IP];"off"leaves them alone, and it has to be quoted because YAML reads the bare word as a boolean, which the render refuses.allowCidrslists the networks the model must still see, such as127.0.0.0/8or a service range. -
Operator rules under
litellm.redaction.rules. Each has aname(a letter or digit, then letters, digits,_,.,-) and exactly one ofliteral(an exact string) orpattern(a Python regular expression), both non-empty. Itsactionismask(default) orpseudonym([<name>:<12 hex>]). A mask marker is the name upper-cased with punctuation folded to_, so thecluster-namerule below masks as[REDACTED_CLUSTER_NAME].
litellm: redaction: enabled: true ip: action: pseudonym allowCidrs: ["127.0.0.0/8"] rules: - name: cluster-name literal: prod-eu-1 action: pseudonym - name: project pattern: "my-proj-[0-9]+"Through install.sh, set LITELLM_REDACTION_ENABLED=true in install.env or pass --litellm-redaction. LITELLM_REDACTION_IP_ACTION (--litellm-redaction-ip-action) and LITELLM_REDACTION_IP_ALLOW_CIDRS (--litellm-redaction-ip-allow-cidrs, comma- or space-separated) set the IP layer, and LITELLM_REDACTION_RULES holds the rules as a JSON array in single quotes, with no flag. The same settings as above:
LITELLM_REDACTION_ENABLED=trueLITELLM_REDACTION_IP_ALLOW_CIDRS=127.0.0.0/8LITELLM_REDACTION_RULES='[{"name":"cluster-name","literal":"prod-eu-1","action":"pseudonym"},{"name":"project","pattern":"my-proj-[0-9]+"}]'They reach the Terraform example as its litellm_redaction variable (enabled, ip_action, allow_cidrs, rules), which renders the chart values above only while enabled is true; a litellm.redaction key in extra_helm_values still wins. On an installed system, set the keys in install.env and re-run upgrade.sh, or use install.sh --menu and Save & Apply; there is no menu entry for them. The kustomize dev copy (make -C k8s-operator deploy-litellm) carries no redaction: install through the chart or install.sh to have it.
A pseudonym is the first twelve hex characters of an HMAC-SHA256 over the value, keyed by SESSION_KV_SALT from the credentials Secret (the same mechanism that pseudonymises chat identities). The same value maps to the same token in every request while the salt holds, so the model can still tell two pods apart and correlate an address across turns; nothing maps a token back. Without the salt the gateway still redacts, with a per-pod salt the redactor warns about, so tokens stop matching across replicas and restarts.
Pseudonymisation is not reversible, and that limits what the agent can do with a pseudonymised value. The model never sees 10.0.0.5; it sees [ip:3fa9c2d1e0b4], and a kubectl command or a chat answer it writes from that token names an address that does not exist, so the tool call fails or the answer is useless. Pseudonymise identifiers the agent only needs to reason about; keep the ones it must act on in allowCidrs, use off, or accept that those tasks degrade. Masking has the same limit without the correlation.
What this covers is the request body on its way to the provider. It does not touch responses, so an identifier the model already knows from an earlier, unredacted turn can still come back.
The same switch reaches the agent pod. The chart projects this rule file there at a fixed path. The image applies the IP and operator-rule layers, after its own credential masking, to what the agent writes to its volume: agent.log, the terminal-output cache, the worker transcript, the session store (state.db) and the kanban board. Security and IAM lists what that covers and what it does not.
Each process reads the file once at start. A changed rule file reaches the gateway on its next roll. In the agent pod a long-lived process keeps the rules it started with while each new worker process reads the current file, so roll the pod to move them all. The image parses the file with the grammar it shipped with, so keep the chart and the agent image at one version when this switch is on. It does not touch chat egress.
A rule that fails to load stops the gateway pod at startup rather than forwarding requests it has not redacted. The render fails on a name, action or source it does not accept. An exception inside the hook, including a refused request shape, fails that request. Each redacted request writes one line of substitution counts by rule name to the gateway pod’s log, never the payload.
Pass-through trajectory logging
Section titled “Pass-through trajectory logging”For offline evaluation, fine-tuning, latency analysis, and audit trails, litellm.traceLogEnabled=true enables pass-through JSONL trajectory capture at the gateway.
When enabled, the chart mounts llm_trace_logger.py and the shared redactor.py module beside config.yaml and registers llm_trace_logger.proxy_handler_instance under litellm_settings.callbacks. It passes LITELLM_TRACE_LOG_PATH (default: /tmp/litellm_traces.jsonl) plus SESSION_KV_SALT to the container. The path must reside under /tmp/ because the gateway container runs with readOnlyRootFilesystem: true and only mounts an emptyDir at /tmp.
Before any record is written to disk, AuditRedactor runs over api_base, messages, tools, response, and error. It masks built-in credential patterns, Kubernetes Secret data:/stringData: payloads, secret-shaped keys, and e-mail addresses, and it pseudonymises IP literals (plus any operator rules from redaction.yaml when litellm.redaction.enabled is also on). With litellm.redaction.enabled on, IP literals follow litellm.redaction.ip instead: "off" writes them verbatim, mask masks them, and addresses in allowCidrs pass through. Because redaction.enabled only rewrites outbound requests, running AuditRedactor inside the trajectory logger ensures assistant responses and reasoning traces are also scrubbed before hitting /tmp.
Every completed or failed LLM invocation appends one JSON object containing:
timestamp: UTC ISO 8601 timestamp.status:"success"or"failure".model_alias: The requested model alias (e.g.model-default).custom_llm_provider: Upstream provider (vertex_ai,hosted_vllm,gemini, etc.).api_base: Backend URL (if configured, with URL userinfo passwords masked).reasoning_effort: Requested reasoning effort (e.g.high,medium,low).latency_ms: Round-trip invocation latency in milliseconds.messages: Redacted input messages and tool outputs.tools: Redacted tool schemas provided to the model.response: Redacted upstream response payload, includingchoices,usage, andreasoning_content.error: Redacted error message if the call failed.truncated: Present only on a record that was over1 MiBserialised: names the payload fields dropped (messages,tools,response) and the size the whole record had. The metadata fields above stay.
To bound disk consumption on the gateway pod’s /tmp emptyDir, the logger rotates the trace file at 5 MiB across 3 numbered backups (.1–.3) under an exclusive flock on <path>.lock. It caps one record at 1 MiB as described above, clips every caller-chosen string, and refuses to append a line that would carry a file past its cap (the once-per-path warning records it), so the on-pod trail holds at most 20 MiB. Each record is serialised, redacted and written on one writer thread, off the proxy’s event loop and in order, so a slow write holds neither other requests nor the readiness probe, and records never contend for the file.
litellm.traceLogPath must be a normalised path under /tmp/: a . or .. component, or a doubled or trailing slash, is refused at render time. The logger is strictly pass-through: it never mutates live request or response payloads in place. Write exceptions emit a once-per-path WARNING to stderr (kube_agents.llm_trace_logger) so logging I/O issues are observable in pod logs without failing model calls. When litellm.traceLogEnabled is false (default), the callback is omitted and the default ConfigMap checksum remains byte-identical.
Vertex AI and Model Garden
Section titled “Vertex AI and Model Garden”MODEL_PROVIDER=vertex_ai routes model-default to Vertex AI in your own GCP project — the same first-party Gemini models, plus every Model Garden publisher model your project has access to (Anthropic Claude, Llama, Mistral, and the rest). Requests stay inside your project’s billing and data boundary, and by default (when using Workload Identity rather than litellm.vertex.credentialsSecretRef) no model API key or static GCP key exists in the cluster. That boundary is the project, which governs billing, credentials and data, and it says nothing about geography. The default location is the global endpoint, which makes no promise about the region a request is processed in; see the location bullet below.
Two things differ from the API-key providers:
-
Authentication is Workload Identity by default. The gateway gets its own service-account pair rather than an API key — see Security & IAM. Unless a chart install opts into
litellm.vertex.credentialsSecretRef(below), there is no entry inplatform-agent-secretsfor Vertex. -
The endpoint is a project and a location.
VERTEX_PROJECT_IDandVERTEX_LOCATIONbecomeVERTEXAI_PROJECTandVERTEXAI_LOCATIONon the gateway pod. The project defaults to the install’s. The location defaults toglobalininstall.sh, Terraform, and the chart — not the cluster’s region, which need not serve the model you asked for and on a zonal cluster is not a valid Vertex location at all. (The kustomize dev path substitutesVERTEX_LOCATIONwith no fallback, so export it there.)Set
VERTEX_LOCATIONto a region when you have a data-residency requirement, when org policy blocks the global endpoint, or when the model is a Model Garden partner model served only from specific regions. Google’s locations page lists which locations serve which model, and its data-residency page covers what the global endpoint does not guarantee. -
A serving project you cannot administer. With
VERTEX_PROJECT_IDpointing at another project, the install enablesaiplatform.googleapis.comthere and grants the gateway’s service accountroles/aiplatform.useron it, which needs IAM rights on that project. SetVERTEX_MANAGE_SERVING_PROJECT=false(--vertex-manage-serving-project=false) when you do not have them: the install still creates the service account and its Workload Identity binding in your project, and you enable the API and make the grant by hand. Choose it at the first install; flipping it later on an install that already manages the two revokes the grant unless you remove them from Terraform state first (the composition’s README has the command). Security and IAM covers what that does to the identity’s lifecycle.
MODEL_DEFAULT_NAME is the Vertex publisher model ID, which is not always the same string the provider’s own API uses — Model Garden Claude models, for instance, carry an @-suffixed version (claude-sonnet-4-5@20250929). Check the model’s Model Garden card for the exact ID; a wrong one surfaces as a 404 from the gateway rather than a provisioning error.
curl -fsSL https://raw.githubusercontent.com/gke-labs/kube-agents/<RELEASE_VERSION>/install.sh | bash -s -- \ --model-provider=vertex_ai \ --model-default-name=gemini-3.8-flash \ --vertex-project-id=my-gcp-project \ --vertex-location=us-east4 # both optional: project defaults to the install's, location to "global"A re-run against an existing install reconciles the switch in one terraform apply — the gateway’s IAM pair, its KSA, and the rolled ConfigMap land together.
Where Workload Identity is not available, the chart can read a service-account key and the project from a Secret instead. litellm.vertex.credentialsSecretRef: {name, key} mounts that key read-only at /var/run/secrets/vertex/sa.json and sets GOOGLE_APPLICATION_CREDENTIALS to it, which Google’s client libraries prefer over the KSA’s Workload Identity binding. litellm.vertex.projectSecretRef: {name, key} sets VERTEXAI_PROJECT from the Secret so the project id does not appear in the pod spec, standing in for projectId.
Both fields are chart-only and read only with modelProvider: vertex_ai; the render fails if either is set for another provider or omits name or key. Mint the key for a dedicated service account holding only roles/aiplatform.user on the serving project (see Security & IAM), rotate it in the Secret, and prefer Workload Identity wherever the cluster supports it. Changing either Secret does not roll the gateway: run kubectl rollout restart deployment/litellm -n kubeagents-system after rotating it so the process reloads VERTEXAI_PROJECT and the key file.
To override the Vertex AI endpoint host through the gateway environment Secret, set VERTEXAI_API_BASE in the Secret to the endpoint’s host. Pair --litellm-env-secret (LITELLM_ENV_SECRET_NAME / litellm.envFromSecret) with --vertex-project-id (VERTEX_PROJECT_ID / litellm.vertex.projectId) and --vertex-location (VERTEX_LOCATION / litellm.vertex.location). The host must resolve to a public address: the gateway’s NetworkPolicy allows HTTPS to public addresses only, and no setting opens a private range for vertex_ai.
kubectl create secret generic vertex-endpoint -n kubeagents-system \ --from-literal=VERTEXAI_API_BASE=https://vertex-gateway.example.com
curl -fsSL https://raw.githubusercontent.com/gke-labs/kube-agents/<RELEASE_VERSION>/install.sh | bash -s -- \ --model-provider=vertex_ai \ --model-default-name=gemini-3.8-flash \ --vertex-project-id=my-serving-project \ --vertex-location=us-east4 \ --litellm-env-secret=vertex-endpointWhen a model entry in config.yaml has no api_base, LiteLLM reads VERTEXAI_API_BASE from the environment and appends /v1/projects/<VERTEXAI_PROJECT>/locations/<VERTEXAI_LOCATION>/... to a host-only base, so the chart’s project and location still apply. (GOOGLE_CLOUD_UNIVERSE_DOMAIN does not set LiteLLM’s Vertex AI URL.) litellm.envFromSecret mounts its keys via envFrom and does not render api_base in config.yaml. Because Kubernetes resolves explicit container env entries after envFrom, the VERTEXAI_PROJECT and VERTEXAI_LOCATION entries rendered by the chart always override those keys in litellm.envFromSecret. Set the serving project and model location through the installer flags or litellm.vertex.projectId (or litellm.vertex.projectSecretRef) and litellm.vertex.location rather than inside the Secret.
To render a custom Vertex AI api_base on each model_list entry in config.yaml, set platformAgent.harness.universeDomain to a domain other than googleapis.com (install.sh has no flag for universeDomain, so set it via Helm or TF_VAR_extra_helm_values). The chart then renders api_base as https://aiplatform.<universeDomain> when litellm.vertex.location is global, or https://<location>-aiplatform.<universeDomain> for a regional location, and that rendered api_base wins over VERTEXAI_API_BASE. It also sets GOOGLE_CLOUD_UNIVERSE_DOMAIN directly in container env, overriding any GOOGLE_CLOUD_UNIVERSE_DOMAIN key in litellm.envFromSecret:
helm upgrade --install kube-agents ./charts/kube-agents -n kubeagents-system \ --set platformAgent.harness.clusterName=my-cluster \ --set platformAgent.harness.location=us-central1 \ --set platformAgent.harness.projectId=my-gcp-project \ --set platformAgent.harness.universeDomain=universe.example.com \ --set litellm.modelProvider=vertex_ai \ --set litellm.modelDefaultName=gemini-3.8-flash \ --set litellm.vertex.projectId=my-serving-project \ --set litellm.vertex.location=us-east4A credentials Secret for the gateway
Section titled “A credentials Secret for the gateway”LITELLM_ENV_SECRET_NAME (--litellm-env-secret, chart value litellm.envFromSecret, Terraform litellm_env_secret_name) names a Secret in the agent’s namespace that the gateway container reads whole as environment variables. You create it with kubectl; the install only names it, so the credentials never pass through install.env, terraform.tfvars or Terraform state, and upgrade.sh never rewrites them. The mount is optional: the pod starts without the Secret, and the first model call, not the rollout, reports a missing credential. It carries credentials for the two provider shapes below and for an OAuth2 gateway, as well as custom environment variables on vertex_ai, such as the endpoint override above.
A variable the chart sets directly in container env — keys from platform-agent-secrets (GEMINI_API_KEY, HOSTED_VLLM_API_KEY and the others), VERTEXAI_PROJECT and VERTEXAI_LOCATION on vertex_ai, and GOOGLE_CLOUD_UNIVERSE_DOMAIN when platformAgent.harness.universeDomain is non-default — wins over the same name in this Secret. Changing the Secret does not roll the gateway: run kubectl rollout restart deployment/litellm -n kubeagents-system after rotating it.
SAP AI Core
Section titled “SAP AI Core”MODEL_PROVIDER=sap routes model-default through SAP AI Core’s orchestration service, for an organization whose model traffic has to go through its SAP tenant. SAP AI Core takes no static key: it issues a JSON service key. LiteLLM’s sap/ driver exchanges the client id and secret in it at your tenant’s token URL for a short-lived bearer token, caches it and renews it before it expires. The driver reads the service key from AICORE_SERVICE_KEY and the resource group that holds your orchestration deployment from AICORE_RESOURCE_GROUP, so the Secret carries those two keys:
kubectl create secret generic sap-aicore -n kubeagents-system \ --from-file=AICORE_SERVICE_KEY=./aicore-service-key.json \ --from-literal=AICORE_RESOURCE_GROUP=default
curl -fsSL https://raw.githubusercontent.com/gke-labs/kube-agents/<RELEASE_VERSION>/install.sh | bash -s -- \ --model-provider=sap \ --litellm-env-secret=sap-aicoreThe service key is the JSON the SAP BTP cockpit gives you when you create a service key for the SAP AI Core instance. The driver also accepts the four discrete values AICORE_CLIENT_ID, AICORE_CLIENT_SECRET, AICORE_AUTH_URL and AICORE_BASE_URL in place of the service key; it reads the first source that has a value and does not merge them, so give one shape, not both. Before the first model call the gateway looks up your tenant’s most recent deployment of the orchestration scenario in that resource group and sends every request there, so one must exist.
Model names follow SAP’s <publisher>--<model> form; the default is anthropic--claude-4.5-sonnet, and MODEL_DEFAULT_NAME picks another. A Claude model behind SAP has its sampling keys dropped like any other Claude model (above); prompt caching stays off, since the cache_control markers have not been shown to pass SAP’s orchestration API. The token URL and the AI API URL are public SAP endpoints on port 443, which the gateway’s NetworkPolicy already allows.
Other LiteLLM providers
Section titled “Other LiteLLM providers”Any other LiteLLM provider works the same way. Set MODEL_PROVIDER to the provider’s slug (azure, bedrock, databricks, …; lowercase letters, digits and underscores) and MODEL_DEFAULT_NAME to the model, which is required because the install has no default for it. Put the variables that driver reads from the environment in the Secret. Nothing else is derived: the gateway’s NetworkPolicy reaches public endpoints on 443 and nothing private, the provider’s own cost table applies, and the installer offers the entry as the sixth choice of its provider menu.
OpenRouter is one such slug: MODEL_PROVIDER=openrouter, MODEL_DEFAULT_NAME set to OpenRouter’s <vendor>/<model> name, and OPENROUTER_API_KEY in the Secret. It is the one slug the chart derives anything for: a model whose name starts with anthropic/claude- gets the prompt-caching breakpoints.
OpenAI-compatible endpoints (self-hosted or private)
Section titled “OpenAI-compatible endpoints (self-hosted or private)”MODEL_PROVIDER=openai_compatible routes model-default to any server that speaks the OpenAI chat-completions API: vLLM, TGI or an internal gateway, in the cluster or on your own network. LiteLLM stays in front of it, so the agent and Hindsight keep calling inference-gateway and their config does not change. The provider has no defaults. The model name and the server’s base URL are both required, and the render fails without either.
In the chart values:
litellm: modelProvider: openai_compatible modelDefaultName: google/gemma-3-27b-it # the model name the server serves openaiCompatible: apiBase: http://llm-service.models.svc.cluster.local/v1 targetPort: 8000apiBase is the server’s base URL with its /v1 path, http:// or https://. modelDefaultName is the name the server answers to; vLLM serves the model it loaded under its Hugging Face ID unless it was started with --served-model-name.
install.sh and the Terraform example carry the same settings. The installer checks them against the chart’s rules before it creates anything, and its interactive provider menu and the --menu panel offer the provider as a fifth entry:
install.env key |
Flag | Chart value |
|---|---|---|
OPENAI_COMPATIBLE_API_BASE |
--openai-compatible-api-base |
litellm.openaiCompatible.apiBase |
OPENAI_COMPATIBLE_TARGET_PORT |
--openai-compatible-target-port |
litellm.openaiCompatible.targetPort |
OPENAI_COMPATIBLE_EGRESS_CIDRS |
--openai-compatible-egress-cidrs |
litellm.openaiCompatible.egressCIDRs (comma-separated in the installer) |
OPENAI_COMPATIBLE_CA_SECRET_NAME |
--openai-compatible-ca-secret-name |
litellm.openaiCompatible.caBundleSecretRef.name (the key is always ca.crt) |
OPENAI_COMPATIBLE_API_KEY |
--openai-compatible-api-key |
key OPENAI_COMPATIBLE_API_KEY in platform-agent-secrets |
LITELLM_ENV_SECRET_NAME |
--litellm-env-secret |
litellm.envFromSecret (the OAuth2 client credentials, below) |
The Terraform example’s variables are the same names in lower case (openai_compatible_api_base and so on), with model_provider = "openai_compatible" and model_default_name. The install above, through the installer:
curl -fsSL https://raw.githubusercontent.com/gke-labs/kube-agents/<RELEASE_VERSION>/install.sh | bash -s -- \ --model-provider=openai_compatible \ --model-default-name=google/gemma-3-27b-it \ --openai-compatible-api-base=http://llm-service.models.svc.cluster.local/v1 \ --openai-compatible-target-port=8000The API key
Section titled “The API key”The key is optional. The gateway reads it from OPENAI_COMPATIBLE_API_KEY in the credentials Secret (platform-agent-secrets) and sends it as a bearer token. Without it, requests carry the placeholder Bearer fake-api-key, which a server that checks no key ignores. With this provider the gateway pod gets none of the Gemini, OpenAI or Anthropic keys, so no request to your server can carry one of them.
OAuth2 client credentials
Section titled “OAuth2 client credentials”An enterprise AI gateway often takes no static key: it issues a client id and a client secret, which are exchanged at an OAuth2 token endpoint (client_credentials grant) for a bearer token that expires after minutes or hours. Put the three values in the credentials Secret and name it with --litellm-env-secret:
kubectl create secret generic ai-gateway-oauth -n kubeagents-system \ --from-literal=OPENAI_COMPATIBLE_OAUTH_TOKEN_URL=https://login.example.com/oauth/token \ --from-literal=OPENAI_COMPATIBLE_OAUTH_CLIENT_ID=<client id> \ --from-literal=OPENAI_COMPATIBLE_OAUTH_CLIENT_SECRET=<client secret>
curl -fsSL https://raw.githubusercontent.com/gke-labs/kube-agents/<RELEASE_VERSION>/install.sh | bash -s -- \ --model-provider=openai_compatible \ --model-default-name=<model> \ --openai-compatible-api-base=https://ai-gateway.example.com/v1 \ --litellm-env-secret=ai-gateway-oauthWith that Secret named, the chart ships a pre-call hook into the gateway (litellm_oauth2_callback.py, beside config.yaml). While OPENAI_COMPATIBLE_OAUTH_TOKEN_URL is set, it fetches a token before the first request and sends it as the bearer on every request bound for the server. It renews the token 60 seconds before the expiry the token endpoint stated (a response that states none is treated as 5 minutes, so it renews after 4). It fetches one token at a time, and the gateway’s log records each fetch and renewal. A failed exchange fails the request that needed it with the token endpoint’s status, and the next request tries again.
Two optional keys: OPENAI_COMPATIBLE_OAUTH_SCOPE is sent as scope, and OPENAI_COMPATIBLE_OAUTH_CLIENT_AUTH=post puts the client id and secret in the form body for a token endpoint that does not take them as HTTP basic authentication, the default. Without the token URL the hook is idle and OPENAI_COMPATIBLE_API_KEY, if set, is the bearer as before.
The token request leaves the pod under the same egress rules as the model requests, which open the server’s address and port and nothing else private. So the token endpoint has to be reachable where the server is: a public address on 443, an address inside OPENAI_COMPATIBLE_EGRESS_CIDRS on the same port as the base URL, or, for an in-cluster server, its namespace on OPENAI_COMPATIBLE_TARGET_PORT.
For a server behind a private CA, the hook trusts that bundle beside the system roots when it calls the token URL, so the token endpoint can sit on the same private CA or on a public one. A gateway that is SAP AI Core itself does not need this: MODEL_PROVIDER=sap carries the exchange in LiteLLM’s own driver.
How the gateway calls the server
Section titled “How the gateway calls the server”Each alias renders as LiteLLM’s hosted_vllm provider. Despite the name, that is LiteLLM’s handler for any OpenAI-compatible server:
model_list: - model_name: model-default litellm_params: model: hosted_vllm/google/gemma-3-27b-it api_base: http://llm-service.models.svc.cluster.local/v1LiteLLM’s openai/ handler would fit the API too, but it falls back to the OPENAI_API_KEY environment variable when an entry has no key, which either sends an OpenAI key to your server or fails every request. It also ignores a per-entry ssl_verify, so a private CA would have to replace the trust store for every provider at once. hosted_vllm/ reads only HOSTED_VLLM_API_KEY, which the chart fills from the Secret key above, and honours ssl_verify on its own entries. It also strips strict from tool schemas and drops replayed reasoning content from earlier turns before the request leaves.
The gateway pod also sets LITELLM_LOCAL_MODEL_COST_MAP=True for this provider, so LiteLLM uses the model-price table bundled in its image instead of fetching one from GitHub at startup.
A server behind a private CA
Section titled “A server behind a private CA”litellm.openaiCompatible.caBundleSecretRef names a Secret in the release namespace that holds the PEM bundle signing the server’s certificate (under key, default ca.crt). The chart mounts that key read-only into the gateway pod at /etc/litellm/openai-compatible-ca/ and points ssl_verify on this provider’s entries at it. The bundle replaces the public roots for those entries, so it must hold every CA the server’s chain needs. Nothing else trusts it: no other entry, no other pod, and no global SSL_CERT_FILE; the one addition is the OAuth2 hook, which trusts it beside the system roots for the token URL. Through the installer, create the Secret first and pass its name:
kubectl create secret generic model-server-ca -n kubeagents-system --from-file=ca.crt=./ca.pemEgress to the server
Section titled “Egress to the server”The gateway’s NetworkPolicy (litellm-policy) allows DNS, HTTPS to public addresses, the metadata server and the telemetry collector, and none of the places a private server usually lives. The chart adds one egress rule, derived from apiBase:
-
An in-cluster Service (
<svc>,<svc>.<ns>.svcor<svc>.<ns>.svc.cluster.local; a bare<svc>means the release namespace). A host with exactly two labels, such asopenrouter.ai, is a hostname, not<svc>.<ns>, and follows the rules below; write an in-cluster Service as<svc>.<ns>.svc.The rule admits that namespace on
targetPort, which is required in this form: NetworkPolicy matches traffic after the Service has translated it to the pod’s port, so the Service port in the URL is not enough. The rule names the namespace, not the server’s pods, so every pod in that namespace becomes reachable from the gateway ontargetPort. Run the model server in a namespace of its own rather than the release namespace, which holds the agent and the gateway. If the server’s namespace has its own ingress policy, that policy has to admit the gateway’s namespace. -
A private address outside the cluster, such as an internal load balancer or an on-premises server over Interconnect or VPN. List its ranges in
egressCIDRs; the rule admits those CIDRs on the URL’s port, or 443 forhttpsand 80 forhttpwhen the URL names none. NetworkPolicy matches addresses and never DNS names, so a hostname needs the ranges it resolves to. Each entry is a CIDR no wider than/12(IPv4) or/48(IPv6), at most 50 of them. A range that reaches link-local or metadata addresses (169.254.0.0/16,fe80::/10, the metadata server’sfd20:ce::/48) is refused, as is an IPv4-mapped IPv6 block.egressCIDRsis ignored for an in-cluster Service. -
A public HTTPS endpoint on port 443 needs no rule: the gateway’s existing 443 rule already reaches public addresses. A hostname on 443 that resolves to a private address does not ride that rule, because it excludes private ranges; give it
egressCIDRs. The chart’s static copy of that rule excludes10.0.0.0/8,172.16.0.0/12and192.168.0.0/16, and the operator’s copy also excludes100.64.0.0/10and169.254.0.0/16.
Any other URL with egressCIDRs empty fails the render with a message that names litellm.openaiCompatible.egressCIDRs.
Use https for a server outside the cluster. Over http, prompts, which can carry cluster data, and OPENAI_COMPATIBLE_API_KEY cross the network unencrypted; the chart accepts it, and both install.sh and the chart’s install notes (shown by helm install and helm upgrade) print a warning.
On a default install the operator owns litellm-policy, so the chart hands the rule to it as the kubeagents.x-k8s.io/litellm-upstream-egress annotation on the PlatformAgent (PlatformAgent CRD). The operator checks the value again, and on an invalid one logs Ignoring invalid annotation value and adds no rule rather than failing the reconcile; if the gateway cannot reach the server, look there first. With the operator off, the chart’s own copy of the policy carries the same rule.
Context window
Section titled “Context window”A self-hosted server refuses a request whose prompt and max_tokens do not fit its served window. Set litellm.maxTokens (MODEL_MAX_TOKENS) below that window and serve a window large enough for the agent’s prompt; Setting the output-token budget has the details.
What it does not cover
Section titled “What it does not cover”- The kustomize dev copy (
make -C k8s-operator deploy-litellm) does not carry the provider, the credentials Secret or the OAuth2 hook, and the admin console’s provider catalog does not list it. Install throughinstall.sh, the Terraform example or the chart. - The installer does not deploy a model server. The vLLM example is one you apply yourself.
- A self-hosted model does not make the install offline. The agent still needs Google APIs, and some of its tools reach the internet on their own. Security and IAM lists each destination, which ones are required, and how to turn off the rest. A fully disconnected cluster is not supported.
vLLM (local models)
Section titled “vLLM (local models)”vLLM serves open models with continuous batching, chunked prefill, and prefix caching for high throughput on GPU node pools.
What ships
Section titled “What ships”examples/vllm-gemma/— Gemma 4 26B-A4B through vLLM’s OpenAI-compatible server on two L4 GPUs, with a 128k-token context. Requires an accelerator node pool; the README gives the command. It runs in the release namespace, unlike the advice above; its README says what that means for the gateway’s egress rule.
To put the gateway in front of it, point litellm.openaiCompatible.apiBase at its Service, as OpenAI-compatible endpoints describes; the example’s README gives the values.
Inference replay
Section titled “Inference replay”examples/inference-replay/ is a small proxy that sits between the Platform Agent and LiteLLM. Requests are keyed by a SHA-256 hash of the canonicalized request body (messages plus params); hits return the cached response, misses forward to LiteLLM and cache the reply.
-
mode: off(default) — passthrough. Every request forwards. -
mode: on— cache hits return; misses forward and cache. -
Toggle at runtime:
Terminal window kubectl patch configmap inference-replay-config -n <ns> --type merge \-p '{"data":{"mode":"on"}}'
The proxy uses a PersistentVolumeClaim for the cache so replays survive pod restarts.
When to use it
Section titled “When to use it”- Demos where you want repeatable output for the same inputs.
- CI tests against the agent’s tool loop where LLM cost or non-determinism would be a problem.
- Cost containment during development.
Deploy it with make -C k8s-operator deploy-inference-replay — it is a development tool, never part of the installer.
What the agent doesn’t care about
Section titled “What the agent doesn’t care about”The Platform Agent’s config (agents/platform/config.yaml) doesn’t mention the LLM provider. Provider selection is entirely at the LiteLLM / vLLM layer — the agent always talks to the inference-gateway Service, and the install decides what that Service resolves to. When the replay proxy is deployed, the inference-gateway Service is repointed at the replay proxy and the original gateway pods are re-exposed through a new inference-gateway-upstream Service that the proxy forwards cache misses to. That means:
- Swapping Gemini for Anthropic is a LiteLLM
ConfigMapchange. - So is prompt caching — the breakpoints are injected gateway-side, because only the gateway knows which model they are for.
- Turning on replay is a
make -C k8s-operator deploy-inference-replayon a dev cluster. - Neither touches the agent’s persona, skills, or governance layer.
Where to go next
Section titled “Where to go next”- Reference → Examples — the inference example bundles walked through.
- Deploy → Network policies and Service — where the LiteLLM Deployment’s dev copy lives on disk.
- Concepts → Observability — LLM telemetry export.