:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.
Python ab-testingai-analyticsanalyticscdpdata-warehouseexperimentsfeature-flagsjavascriptproduct-analyticspythonreactsession-replaysurveystypescriptweb-analytics
feat(llm-gateway): add GLM 5.3 Flash via Baseten (#90292)
Alessandro Pogliaghiab5d3433470c
diff --git a/products/tasks/backend/constants.py b/products/tasks/backend/constants.pyindex 723da5198c74..0d303eeb52f5 100644--- a/products/tasks/backend/constants.py+++ b/products/tasks/backend/constants.py@@ -79,6 +79,9 @@ DEV_STACK_PREVIEW_PORT = 8020# entitlement is re-checked server-side. Keys are the model ids callers send.MODEL_ACCESS_FLAGS: dict[str, str] = {"moonshotai/kimi-k3": "tasks-kimi-k3",+ "deepseek-ai/deepseek-v4-flash-0731": "posthog-code-deepseek-model",+ "zai-org/glm-5.3": "posthog-code-glm-53-model",+ "zai-org/glm-5.3-flash": "posthog-code-glm-53-flash-model",}diff --git a/products/tasks/backend/temporal/process_task/tests/test_utils.py b/products/tasks/backend/temporal/process_task/tests/test_utils.pyindex 781175bde137..152a0643e75a 100644--- a/products/tasks/backend/temporal/process_task/tests/test_utils.py+++ b/products/tasks/backend/temporal/process_task/tests/test_utils.py@@ -38,11 +38,12 @@ from products.tasks.backend.temporal.process_task.utils import (class TestRuntimeModelCapabilities(SimpleTestCase):def test_glm_5_3_supports_claude_reasoning_efforts(self) -> None:- assert "zai-org/glm-5.3" in get_models_for_runtime_adapter("claude")- assert tuple(effort.value for effort in get_supported_reasoning_efforts("claude", "zai-org/glm-5.3")) == (- "high",- "max",- )+ for model in ("zai-org/glm-5.3", "zai-org/glm-5.3-flash"):+ assert model in get_models_for_runtime_adapter("claude")+ assert tuple(effort.value for effort in get_supported_reasoning_efforts("claude", model)) == (+ "high",+ "max",+ )def test_kimi_is_known_without_selectable_reasoning_effort(self) -> None:assert "moonshotai/kimi-k3" in get_models_for_runtime_adapter("claude")diff --git a/products/tasks/backend/temporal/process_task/utils.py b/products/tasks/backend/temporal/process_task/utils.pyindex d4db558293ae..605435b4e4e4 100644--- a/products/tasks/backend/temporal/process_task/utils.py+++ b/products/tasks/backend/temporal/process_task/utils.py@@ -130,6 +130,10 @@ CLAUDE_REASONING_EFFORTS_BY_MODEL: dict[str, tuple[ReasoningEffort, ...]] = {ReasoningEffort.HIGH,ReasoningEffort.MAX,),+ "zai-org/glm-5.3-flash": (+ ReasoningEffort.HIGH,+ ReasoningEffort.MAX,+ ),"moonshotai/kimi-k3": (),"claude-opus-4-5": (ReasoningEffort.LOW,diff --git a/products/tasks/backend/tests/test_feature_flags.py b/products/tasks/backend/tests/test_feature_flags.pyindex 700f023552c7..3a4c06c151a7 100644--- a/products/tasks/backend/tests/test_feature_flags.py+++ b/products/tasks/backend/tests/test_feature_flags.py@@ -66,8 +66,17 @@ class TestGetModelAccessError:feature_enabled_mock.assert_not_called()- @pytest.mark.parametrize("model", ["moonshotai/kimi-k3", " MoonshotAI/Kimi-K3 "])- def test_gated_model_is_allowed_when_the_flag_is_on(self, model):+ @pytest.mark.parametrize(+ "model, flag_key",+ [+ ("moonshotai/kimi-k3", "tasks-kimi-k3"),+ (" MoonshotAI/Kimi-K3 ", "tasks-kimi-k3"),+ ("deepseek-ai/deepseek-v4-flash-0731", "posthog-code-deepseek-model"),+ ("zai-org/glm-5.3", "posthog-code-glm-53-model"),+ ("zai-org/glm-5.3-flash", "posthog-code-glm-53-flash-model"),+ ],+ )+ def test_gated_model_is_allowed_when_the_flag_is_on(self, model, flag_key):with (override_settings(DEBUG=False),patch(@@ -77,7 +86,7 @@ class TestGetModelAccessError:):assert get_model_access_error(model, distinct_id="d-1") is None- assert feature_enabled_mock.call_args.args[0] == "tasks-kimi-k3"+ assert feature_enabled_mock.call_args.args[0] == flag_keyassert feature_enabled_mock.call_args.kwargs["distinct_id"] == "d-1"@pytest.mark.parametrize(diff --git a/services/llm-gateway/PARITY.md b/services/llm-gateway/PARITY.mdindex 62a78d7aeb08..9af9bd555cb0 100644--- a/services/llm-gateway/PARITY.md+++ b/services/llm-gateway/PARITY.md@@ -48,6 +48,11 @@ Existing Django callers should use `build_openai_client`, `build_async_openai_clFor PostHog Desktop, the Python gateway maps Django credential rejections to generic access denials. Transport, server, and malformed-response failures remain retryable service errors.+Flag-gated open-weight models added to the Python gateway under the freeze stay there for the same reason.+`zai-org/glm-5.3-flash` is Baseten-exclusive, gated by the `posthog-code-glm-53-flash-model` flag, and reachable only by the `posthog_code` and `review_hog` products.+Its callers are PostHog Desktop and PostHog Code, so the model depends on the OAuth application allowlists, the request-selected project validated against OAuth scope and live organization membership, the billing policy, and the per-model access flags named in the first row above.+The Go catalog serves GLM 5.2 only, and Baseten on Go still depends on the provider deployment check below.+### 🔎 Verify before switchingThese are compatibility checks, not automatic blockers:@@ -73,7 +78,7 @@ These are compatibility checks, not automatic blockers:| OpenAI APIs | Chat Completions, Responses, bare Responses alias, and normalized router chat. | Audio transcription and broader LiteLLM translation. || Anthropic APIs | Messages and token counting, including Bedrock-hosted models. | OpenAI models exposed through the Anthropic shape and Python-specific Bedrock opt-in behavior. || Providers | OpenAI, Anthropic, Azure OpenAI, Bedrock, and configured Modal, Fireworks, and Baseten hosts. | OpenRouter and Cloudflare Workers AI. |-| Models | Gateway-owned catalog, canonical IDs and aliases, capability checks, router categories, and OpenRouter-shaped pricing. | Broader LiteLLM model acceptance, Python product allowlists, and product-scoped model pricing. |+| Models | Gateway-owned catalog, canonical IDs and aliases, capability checks, router categories, and OpenRouter-shaped pricing. | Broader LiteLLM model acceptance, Python product allowlists, per-model access flags, and product-scoped model pricing. || Routing and failure behavior | Operator-managed provider plans, health-aware ordering, circuit breakers, hosted-provider failover, and strict provider pinning. | Caller opt-in Bedrock fallback and provider-specific Python routing. || Event metadata | One `X-PostHog-Properties` JSON object plus dedicated product, user, obo, distinct ID, trace ID, and provider headers. | `X-POSTHOG-PROPERTY-*` and `X-POSTHOG-FLAG-*` headers. || Session attribution | `X-PostHog-Session-Id` is recorded as the gateway-owned `$ai_session_id`. | The per-key property header can also emit `$ai_session_id`. |@@ -92,10 +97,10 @@ Run `/migrating-llm-gateway-callers` to inventory and convert a caller.Run `/auditing-llm-gateway-parity` after either gateway changes auth, attribution, billing, endpoints, providers, models, routing, or event metadata. The skill audits implementation sources in both repositories and updates this file without migrating callers.-Last verified on 2026-08-25 against:+Last verified on 2026-08-27 against:-- `PostHog/posthog` working tree compared with master at `c22b95e0009c54388fd1b199d3248f48aba019e2`-- `PostHog/ai-gateway` main at `d7545e0979ff38d7df1ce73779253897c99c3c46`+- `PostHog/posthog` working tree compared with master at `88997b515b337b2482814df60c132f60d5de5be4`+- `PostHog/ai-gateway` main at `37ee8bca725a13bca71e40b36f916765f625f939`## Referencesdiff --git a/services/llm-gateway/README.md b/services/llm-gateway/README.mdindex 48184fd0d461..18b23b393059 100644--- a/services/llm-gateway/README.md+++ b/services/llm-gateway/README.md@@ -219,6 +219,8 @@ The gateway exposes models consistently across Anthropic Messages, chat/completiDeliberately not `tasks-glm-baseten-inference`: that one only moves GLM 5.2 traffic onto Baseten, so sharing it would grant 5.3 by proxy the moment 5.2 routing changed.GLM 5.3 has no open weights released yet, so the flag is not created: the access gate fails closed, keeping the model blocked server-side and hidden in every picker.Do not create the flag until Baseten lists the model and the deployment slug, context window, and contract rate in `model_cost_overrides.py` / `model_registry.py` are confirmed against `inference.baseten.co/v1/models`: the rate is pinned, so a wrong placeholder bills at the wrong price with no automatic correction.+- **GLM 5.3 Flash** (`zai-org/glm-5.3-flash`) runs only on Baseten and is available to ReviewHog and PostHog Desktop behind its own `posthog-code-glm-53-flash-model` flag.+ Contract rate and 1M context window come from the Baseten listing and are pinned in `model_cost_overrides.py` / `model_registry.py`.- **DeepSeek V4 Flash** (`deepseek-ai/deepseek-v4-flash-0731`) runs only on Baseten and is available to ReviewHog and PostHog Desktop (client-gated by the `posthog-code-deepseek-model` flag).Provider configuration:diff --git a/services/llm-gateway/src/llm_gateway/baseten.py b/services/llm-gateway/src/llm_gateway/baseten.pyindex 19933fab72f2..91d39af1d56f 100644--- a/services/llm-gateway/src/llm_gateway/baseten.py+++ b/services/llm-gateway/src/llm_gateway/baseten.py@@ -22,15 +22,20 @@ BASETEN_DEEPSEEK_METRIC_MODEL = "baseten/deepseek-ai/deepseek-v4-flash-0731"BASETEN_GLM53_PUBLIC_MODEL = "zai-org/glm-5.3"BASETEN_GLM53_MODEL = "zai-org/GLM-5.3"BASETEN_GLM53_METRIC_MODEL = "baseten/zai-org/glm-5.3"+BASETEN_GLM53_FLASH_PUBLIC_MODEL = "zai-org/glm-5.3-flash"+BASETEN_GLM53_FLASH_MODEL = "zai-org/GLM-5.3-Flash"+BASETEN_GLM53_FLASH_METRIC_MODEL = "baseten/zai-org/glm-5.3-flash"BASETEN_MODELS = {BASETEN_PUBLIC_MODEL: BASETEN_GLM_MODEL,BASETEN_DEEPSEEK_PUBLIC_MODEL: BASETEN_DEEPSEEK_MODEL,BASETEN_GLM53_PUBLIC_MODEL: BASETEN_GLM53_MODEL,+ BASETEN_GLM53_FLASH_PUBLIC_MODEL: BASETEN_GLM53_FLASH_MODEL,}# Models with no Cloudflare/Modal fallback — always routed to Baseten.BASETEN_EXCLUSIVE_COST_MODELS: Final[dict[str, str]] = {BASETEN_DEEPSEEK_PUBLIC_MODEL: BASETEN_DEEPSEEK_METRIC_MODEL,BASETEN_GLM53_PUBLIC_MODEL: BASETEN_GLM53_METRIC_MODEL,+ BASETEN_GLM53_FLASH_PUBLIC_MODEL: BASETEN_GLM53_FLASH_METRIC_MODEL,}BASETEN_EXCLUSIVE_MODELS: frozenset[str] = frozenset(BASETEN_EXCLUSIVE_COST_MODELS)diff --git a/services/llm-gateway/src/llm_gateway/inference_routing.py b/services/llm-gateway/src/llm_gateway/inference_routing.pyindex 99d3d144b672..59f488aa03d5 100644--- a/services/llm-gateway/src/llm_gateway/inference_routing.py+++ b/services/llm-gateway/src/llm_gateway/inference_routing.py@@ -29,6 +29,7 @@ from llm_gateway.api.handler import (from llm_gateway.auth.models import AuthenticatedUserfrom llm_gateway.baseten import (BASETEN_EXCLUSIVE_MODELS,+ BASETEN_GLM53_FLASH_PUBLIC_MODEL,BASETEN_GLM53_PUBLIC_MODEL,BASETEN_PUBLIC_MODEL,ensure_baseten_configured,@@ -64,7 +65,9 @@ GLM_REASONING_EFFORTS: frozenset[str] = frozenset({"high", "max"})# GLM models across all backends: these need the Claude-runtime reasoning rewrite on the# Anthropic surface regardless of which provider serves them.-GLM_MODELS: frozenset[str] = frozenset({BASETEN_PUBLIC_MODEL, BASETEN_GLM53_PUBLIC_MODEL})+GLM_MODELS: frozenset[str] = frozenset(+ {BASETEN_PUBLIC_MODEL, BASETEN_GLM53_PUBLIC_MODEL, BASETEN_GLM53_FLASH_PUBLIC_MODEL}+)def is_inference_routed_model(model: str) -> bool:diff --git a/services/llm-gateway/src/llm_gateway/products/config.py b/services/llm-gateway/src/llm_gateway/products/config.pyindex ccceb46dc41e..0f29bd8591fb 100644--- a/services/llm-gateway/src/llm_gateway/products/config.py+++ b/services/llm-gateway/src/llm_gateway/products/config.py@@ -6,7 +6,11 @@ from typing import Finalfrom fastapi import HTTPException-from llm_gateway.baseten import BASETEN_DEEPSEEK_PUBLIC_MODEL, BASETEN_GLM53_PUBLIC_MODEL+from llm_gateway.baseten import (+ BASETEN_DEEPSEEK_PUBLIC_MODEL,+ BASETEN_GLM53_FLASH_PUBLIC_MODEL,+ BASETEN_GLM53_PUBLIC_MODEL,+)from llm_gateway.bedrock import BEDROCK_MODEL_IDS, get_bedrock_model_access_candidates, get_bedrock_region_namefrom llm_gateway.config import get_settings@@ -92,6 +96,7 @@ _POSTHOG_CODE_AGENT_MODELS: Final[frozenset[str]] = frozenset("gpt-5-mini","@cf/zai-org/glm-5.2","zai-org/glm-5.3",+ "zai-org/glm-5.3-flash","moonshotai/kimi-k3",})@@ -104,6 +109,7 @@ RESTRICTED_MODEL_PRODUCTS: Final[dict[str, frozenset[str]]] = {# Evaluated by ReviewHog; exposed in PostHog Code behind the posthog-code-deepseek-model flag.BASETEN_DEEPSEEK_PUBLIC_MODEL: frozenset({"posthog_code", "review_hog"}),BASETEN_GLM53_PUBLIC_MODEL: frozenset({"posthog_code", "review_hog"}),+ BASETEN_GLM53_FLASH_PUBLIC_MODEL: frozenset({"posthog_code", "review_hog"}),}PRODUCTS: Final[dict[str, ProductConfig]] = {@@ -261,6 +267,7 @@ PRODUCTS: Final[dict[str, ProductConfig]] = {{"@cf/zai-org/glm-5.2","zai-org/glm-5.3",+ "zai-org/glm-5.3-flash","deepseek-ai/deepseek-v4-flash-0731","claude-sonnet-5","claude-opus-4-8",@@ -465,6 +472,7 @@ MODEL_ACCESS_FLAGS: Final[dict[str, str]] = {"moonshotai/kimi-k3": "tasks-kimi-k3","deepseek-ai/deepseek-v4-flash-0731": "posthog-code-deepseek-model","zai-org/glm-5.3": "posthog-code-glm-53-model",+ "zai-org/glm-5.3-flash": "posthog-code-glm-53-flash-model",}diff --git a/services/llm-gateway/src/llm_gateway/rate_limiting/cost_refresh.py b/services/llm-gateway/src/llm_gateway/rate_limiting/cost_refresh.pyindex 84f5b125440b..61c9aac269cc 100644--- a/services/llm-gateway/src/llm_gateway/rate_limiting/cost_refresh.py+++ b/services/llm-gateway/src/llm_gateway/rate_limiting/cost_refresh.py@@ -11,6 +11,8 @@ from litellm.litellm_core_utils.get_model_cost_map import get_model_cost_mapfrom llm_gateway.baseten import (BASETEN_DEEPSEEK_METRIC_MODEL,BASETEN_DEEPSEEK_MODEL,+ BASETEN_GLM53_FLASH_METRIC_MODEL,+ BASETEN_GLM53_FLASH_MODEL,BASETEN_GLM53_METRIC_MODEL,BASETEN_GLM53_MODEL,BASETEN_METRIC_MODEL,@@ -36,6 +38,7 @@ COST_ALIASES: dict[str, tuple[str, str]] = {"openai/zai-org/GLM-5.2": (BASETEN_METRIC_MODEL, "openai"),f"openai/{BASETEN_DEEPSEEK_MODEL}": (BASETEN_DEEPSEEK_METRIC_MODEL, "openai"),f"openai/{BASETEN_GLM53_MODEL}": (BASETEN_GLM53_METRIC_MODEL, "openai"),+ f"openai/{BASETEN_GLM53_FLASH_MODEL}": (BASETEN_GLM53_FLASH_METRIC_MODEL, "openai"),"openai/moonshotai/kimi-k3": ("moonshotai/kimi-k3", "openai"),}@@ -49,6 +52,7 @@ ALIAS_METRIC_LABELS: dict[str, tuple[str, str]] = {"openai/zai-org/GLM-5.2": ("baseten", BASETEN_METRIC_MODEL),f"openai/{BASETEN_DEEPSEEK_MODEL}": ("baseten", BASETEN_DEEPSEEK_METRIC_MODEL),f"openai/{BASETEN_GLM53_MODEL}": ("baseten", BASETEN_GLM53_METRIC_MODEL),+ f"openai/{BASETEN_GLM53_FLASH_MODEL}": ("baseten", BASETEN_GLM53_FLASH_METRIC_MODEL),"openai/moonshotai/kimi-k3": ("modal", "moonshotai/kimi-k3"),}diff --git a/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_overrides.py b/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_overrides.pyindex a5b19f0c85a1..5c229c6f1d0a 100644--- a/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_overrides.py+++ b/services/llm-gateway/src/llm_gateway/rate_limiting/model_cost_overrides.py@@ -2,7 +2,12 @@ from __future__ import annotationsfrom typing import TYPE_CHECKING, Final, cast-from llm_gateway.baseten import BASETEN_DEEPSEEK_METRIC_MODEL, BASETEN_GLM53_METRIC_MODEL, BASETEN_METRIC_MODEL+from llm_gateway.baseten import (+ BASETEN_DEEPSEEK_METRIC_MODEL,+ BASETEN_GLM53_FLASH_METRIC_MODEL,+ BASETEN_GLM53_METRIC_MODEL,+ BASETEN_METRIC_MODEL,+)if TYPE_CHECKING:from llm_gateway.rate_limiting.model_cost_service import ModelCost@@ -45,6 +50,15 @@ BASETEN_GLM53_COST: Final[ModelCost] = {"supports_prompt_caching": True,}+BASETEN_GLM53_FLASH_COST: Final[ModelCost] = {+ "litellm_provider": "baseten",+ "mode": "chat",+ "input_cost_per_token": 1.5e-07,+ "output_cost_per_token": 5e-07,+ "cache_read_input_token_cost": 3e-08,+ "supports_prompt_caching": True,+}+BASETEN_DEEPSEEK_COST: Final[ModelCost] = {"litellm_provider": "baseten","mode": "chat",@@ -58,6 +72,7 @@ MODEL_COST_OVERRIDES: Final[dict[str, ModelCost]] = {BASETEN_METRIC_MODEL: cast("ModelCost", dict(BASETEN_GLM_COST)),BASETEN_DEEPSEEK_METRIC_MODEL: cast("ModelCost", dict(BASETEN_DEEPSEEK_COST)),BASETEN_GLM53_METRIC_MODEL: cast("ModelCost", dict(BASETEN_GLM53_COST)),+ BASETEN_GLM53_FLASH_METRIC_MODEL: cast("ModelCost", dict(BASETEN_GLM53_FLASH_COST)),"moonshotai/kimi-k3": cast("ModelCost", dict(KIMI_K3_COST)),"claude-fable-5": {"litellm_provider": "anthropic",@@ -112,7 +127,7 @@ MODEL_COST_OVERRIDES: Final[dict[str, ModelCost]] = {# Provider-specific contract prices must not be replaced by a same-named LiteLLM entry.PINNED_MODEL_COST_OVERRIDES: Final[frozenset[str]] = frozenset(- {BASETEN_METRIC_MODEL, BASETEN_DEEPSEEK_METRIC_MODEL, BASETEN_GLM53_METRIC_MODEL}+ {BASETEN_METRIC_MODEL, BASETEN_DEEPSEEK_METRIC_MODEL, BASETEN_GLM53_METRIC_MODEL, BASETEN_GLM53_FLASH_METRIC_MODEL})diff --git a/services/llm-gateway/src/llm_gateway/services/model_registry.py b/services/llm-gateway/src/llm_gateway/services/model_registry.pyindex 0170ef3efe11..804d3459d329 100644--- a/services/llm-gateway/src/llm_gateway/services/model_registry.py+++ b/services/llm-gateway/src/llm_gateway/services/model_registry.py@@ -8,6 +8,7 @@ from llm_gateway.baseten import (BASETEN_DEEPSEEK_PUBLIC_MODEL,BASETEN_EXCLUSIVE_COST_MODELS,BASETEN_EXCLUSIVE_MODELS,+ BASETEN_GLM53_FLASH_PUBLIC_MODEL,BASETEN_GLM53_PUBLIC_MODEL,is_baseten_configured,)@@ -34,6 +35,7 @@ _BASETEN_CONTEXT_WINDOWS: Final[dict[str, int]] = {BASETEN_DEEPSEEK_PUBLIC_MODEL: 1_048_000,# Placeholder pending confirmation against the Baseten deployment.BASETEN_GLM53_PUBLIC_MODEL: 200_000,+ BASETEN_GLM53_FLASH_PUBLIC_MODEL: 1_000_000,}diff --git a/services/llm-gateway/tests/test_baseten.py b/services/llm-gateway/tests/test_baseten.pyindex f8a051b9258a..590e608c2cfe 100644--- a/services/llm-gateway/tests/test_baseten.py+++ b/services/llm-gateway/tests/test_baseten.py@@ -20,6 +20,8 @@ DEEPSEEK_MODEL = "deepseek-ai/deepseek-v4-flash-0731"BASETEN_DEEPSEEK_LITELLM_MODEL = "openai/deepseek-ai/DeepSeek-V4-Flash-0731"GLM53_MODEL = "zai-org/glm-5.3"BASETEN_GLM53_LITELLM_MODEL = "openai/zai-org/GLM-5.3"+GLM53_FLASH_MODEL = "zai-org/glm-5.3-flash"+BASETEN_GLM53_FLASH_LITELLM_MODEL = "openai/zai-org/GLM-5.3-Flash"@pytest.mark.parametrize(@@ -28,6 +30,7 @@ BASETEN_GLM53_LITELLM_MODEL = "openai/zai-org/GLM-5.3"(GLM_MODEL, BASETEN_MODEL, "baseten/zai-org/glm-5.2", 1.4e-06, 4.4e-06, 1.4e-07),(DEEPSEEK_MODEL, BASETEN_DEEPSEEK_LITELLM_MODEL, f"baseten/{DEEPSEEK_MODEL}", 1.3e-07, 2.6e-07, 2.8e-08),(GLM53_MODEL, BASETEN_GLM53_LITELLM_MODEL, f"baseten/{GLM53_MODEL}", 1.4e-06, 4.4e-06, 1.4e-07),+ (GLM53_FLASH_MODEL, BASETEN_GLM53_FLASH_LITELLM_MODEL, f"baseten/{GLM53_FLASH_MODEL}", 1.5e-07, 5e-07, 3e-08),],)def test_inject_baseten_params_maps_model_and_pins_api_key(diff --git a/services/llm-gateway/tests/test_dependencies.py b/services/llm-gateway/tests/test_dependencies.pyindex 9ed16f4e8da0..4f236f2a2a92 100644--- a/services/llm-gateway/tests/test_dependencies.py+++ b/services/llm-gateway/tests/test_dependencies.py@@ -11,7 +11,11 @@ from llm_gateway.auth.authenticators import OAuthAccessTokenAuthenticatorfrom llm_gateway.auth.cache import AuthCache, reset_auth_cachefrom llm_gateway.auth.models import AuthenticatedUserfrom llm_gateway.auth.service import AuthService, InvalidProjectScopeError, UnauthorizedProjectScopeError-from llm_gateway.baseten import BASETEN_DEEPSEEK_PUBLIC_MODEL, BASETEN_GLM53_PUBLIC_MODEL+from llm_gateway.baseten import (+ BASETEN_DEEPSEEK_PUBLIC_MODEL,+ BASETEN_GLM53_FLASH_PUBLIC_MODEL,+ BASETEN_GLM53_PUBLIC_MODEL,+)from llm_gateway.config import get_settingsfrom llm_gateway.dependencies import (_extract_end_user_id_from_body,@@ -476,6 +480,7 @@ class TestBasetenExclusiveModelGateWiring:[(BASETEN_DEEPSEEK_PUBLIC_MODEL, "posthog-code-deepseek-model", "/posthog_code/v1/messages"),(BASETEN_GLM53_PUBLIC_MODEL, "posthog-code-glm-53-model", "/posthog_code/v1/messages"),+ (BASETEN_GLM53_FLASH_PUBLIC_MODEL, "posthog-code-glm-53-flash-model", "/posthog_code/v1/messages"),],)@pytest.mark.parametrize("flag_result", [False, None])@@ -501,7 +506,9 @@ class TestBasetenExclusiveModelGateWiring:assert flag.await_args.args[0] == access_flag@pytest.mark.asyncio- @pytest.mark.parametrize("model", [BASETEN_DEEPSEEK_PUBLIC_MODEL, BASETEN_GLM53_PUBLIC_MODEL])+ @pytest.mark.parametrize(+ "model", [BASETEN_DEEPSEEK_PUBLIC_MODEL, BASETEN_GLM53_PUBLIC_MODEL, BASETEN_GLM53_FLASH_PUBLIC_MODEL]+ )async def test_baseten_exclusive_model_allowed_when_flag_enabled(self, model: str) -> None:request = _make_request({"model": model, "messages": []}, path="/posthog_code/v1/messages")user = _make_user(auth_method="oauth_access_token", user_id=7)diff --git a/services/llm-gateway/tests/test_inference_routing.py b/services/llm-gateway/tests/test_inference_routing.pyindex 8672c3124d20..796b100510a0 100644--- a/services/llm-gateway/tests/test_inference_routing.py+++ b/services/llm-gateway/tests/test_inference_routing.py@@ -23,6 +23,7 @@ from llm_gateway.request_context import RequestContext, set_request_contextGLM_MODEL = "@cf/zai-org/glm-5.2"GLM53_MODEL = "zai-org/glm-5.3"+GLM53_FLASH_MODEL = "zai-org/glm-5.3-flash"DEEPSEEK_MODEL = "deepseek-ai/deepseek-v4-flash-0731"KIMI_MODEL = "@cf/moonshotai/kimi-k2.6"PRODUCT = "posthog_code"@@ -181,7 +182,7 @@ async def test_baseten_flag_routes_each_surface(send_fn: Any, endpoint: str) ->evaluate.assert_awaited_once_with("tasks-glm-baseten-inference", "d-1")[email protected]("model", [DEEPSEEK_MODEL, GLM53_MODEL])[email protected]("model", [DEEPSEEK_MODEL, GLM53_MODEL, GLM53_FLASH_MODEL])@pytest.mark.parametrize(("send_fn", "endpoint"), [(row[0], f"baseten_{row[2].removeprefix('cloudflare_')}") for row in SURFACES])@@ -224,11 +225,12 @@ async def test_deepseek_does_not_apply_glm_anthropic_normalization() -> None:assert handle.call_args.kwargs["request_data"] == request-async def test_baseten_exclusive_glm_still_applies_anthropic_normalization() -> None:[email protected]("model", [GLM53_MODEL, GLM53_FLASH_MODEL])+async def test_baseten_exclusive_glm_still_applies_anthropic_normalization(model: str) -> None:# A Baseten-exclusive GLM is still a GLM: the Claude-runtime reasoning rewrite must apply.handle = AsyncMock(return_value={"ok": True})request = {- "model": GLM53_MODEL,+ "model": model,"messages": [{"role": "user", "content": "hi"}],"output_config": {"effort": "high"},}diff --git a/services/llm-gateway/tests/test_model_cost_overrides.py b/services/llm-gateway/tests/test_model_cost_overrides.pyindex d3e7eb4f207a..c6f0bfe91fc4 100644--- a/services/llm-gateway/tests/test_model_cost_overrides.py+++ b/services/llm-gateway/tests/test_model_cost_overrides.py@@ -62,6 +62,7 @@ class TestApplyModelCostOverrides:"baseten/zai-org/glm-5.2","baseten/deepseek-ai/deepseek-v4-flash-0731","baseten/zai-org/glm-5.3",+ "baseten/zai-org/glm-5.3-flash",}def test_returns_same_object_in_place(self) -> None:diff --git a/services/llm-gateway/tests/test_model_registry.py b/services/llm-gateway/tests/test_model_registry.pyindex 1a887fe4b455..a2a78eea6651 100644--- a/services/llm-gateway/tests/test_model_registry.py+++ b/services/llm-gateway/tests/test_model_registry.py@@ -386,6 +386,7 @@ class TestBasetenModelAdvertising:[("deepseek-ai/deepseek-v4-flash-0731", 1_048_000, ("review_hog", "posthog_code")),("zai-org/glm-5.3", 200_000, ("review_hog", "posthog_code")),+ ("zai-org/glm-5.3-flash", 1_000_000, ("review_hog", "posthog_code")),],)def test_baseten_exclusive_models_advertised_per_product(diff --git a/services/llm-gateway/tests/test_product_config.py b/services/llm-gateway/tests/test_product_config.pyindex 1b01b28bf353..ff986968ebde 100644--- a/services/llm-gateway/tests/test_product_config.py+++ b/services/llm-gateway/tests/test_product_config.py@@ -91,6 +91,8 @@ class TestCheckProductAccess:),("llm_gateway", "personal_api_key", None, "zai-org/glm-5.3", False, "not allowed"),("review_hog", "personal_api_key", None, "zai-org/glm-5.3", True, None),+ ("llm_gateway", "personal_api_key", None, "zai-org/glm-5.3-flash", False, "not allowed"),+ ("review_hog", "personal_api_key", None, "zai-org/glm-5.3-flash", True, None),("posthog_code","oauth_access_token",@@ -227,14 +229,18 @@ class TestCheckProductAccess:assert allowed is Trueassert error is None- @pytest.mark.parametrize("model", ["deepseek-ai/deepseek-v4-flash-0731", "zai-org/glm-5.3"])+ @pytest.mark.parametrize(+ "model", ["deepseek-ai/deepseek-v4-flash-0731", "zai-org/glm-5.3", "zai-org/glm-5.3-flash"]+ )def test_slack_app_rejects_restricted_models_despite_shared_allowlist(self, model: str):allowed, error = check_product_access("slack_app", "oauth_access_token", POSTHOG_CODE_US_APP_ID, model)assert allowed is Falseassert error is not Noneassert "not allowed" in error- @pytest.mark.parametrize("model", [" deepseek-ai/deepseek-v4-flash-0731 ", " zai-org/glm-5.3 "])+ @pytest.mark.parametrize(+ "model", [" deepseek-ai/deepseek-v4-flash-0731 ", " zai-org/glm-5.3 ", " zai-org/glm-5.3-flash "]+ )def test_whitespace_cannot_bypass_restricted_model_products(self, model: str):allowed, error = check_product_access("llm_gateway", "personal_api_key", None, model)assert allowed is False@@ -714,6 +720,8 @@ class TestModelAccessFlag:("DeepSeek-AI/DeepSeek-V4-Flash-0731", "deepseek-ai/deepseek-v4-flash-0731"),("zai-org/glm-5.3", "zai-org/glm-5.3"),("ZAI-Org/GLM-5.3", "zai-org/glm-5.3"),+ ("zai-org/glm-5.3-flash", "zai-org/glm-5.3-flash"),+ ("ZAI-Org/GLM-5.3-Flash", "zai-org/glm-5.3-flash"),],)def test_gated_model_requires_its_own_flag(self, model: str, gated: str):@@ -739,6 +747,7 @@ class TestModelAccessFlag:"moonshotai/kimi-k3","deepseek-ai/deepseek-v4-flash-0731","zai-org/glm-5.3",+ "zai-org/glm-5.3-flash",}for gated_model in MODEL_ACCESS_FLAGS:suffixed = f"{gated_model}x"