{"slug": "switch-ai-models-at-runtime-on-telnyx-edge-compute", "title": "Switch AI Models at Runtime on Telnyx Edge Compute", "summary": "Telnyx has released a new example application, multi-model-inference-switcher, that allows developers to switch AI models at runtime on its Edge Compute platform without redeploying code. The TypeScript app uses Telnyx KV Storage to store the active model, which is read on each chat request, enabling instant model changes via UI or API. The example supports models like moonshotai/Kimi-K2.6, zai-org/GLM-5.2, and meta-llama/Llama-3.3-70B-Instruct.", "body_md": "Most AI examples hardcode the model name.\n\nThat is fine until you actually want to compare models.\n\nIf every model change requires a code edit and redeploy, experimenting gets annoying fast. The `multi-model-inference-switcher`\n\nexample turns model choice into runtime configuration instead.\n\nCode: [https://github.com/team-telnyx/telnyx-code-examples/tree/main/multi-model-inference-switcher](https://github.com/team-telnyx/telnyx-code-examples/tree/main/multi-model-inference-switcher)\n\nThis is a TypeScript app running on Telnyx Edge Compute with the Agent SDK.\n\nIt gives you:\n\n`active-model`\n\nflagThe active model is read from Telnyx KV Storage every time `/chat`\n\nis called. When you switch the model from the UI or API, the next message uses the new model immediately.\n\nNo redeploy.\n\n``` php\nGET /\n  -> admin UI\n\nPOST /model\n  -> validate model\n  -> write active-model to KV\n\nPOST /chat\n  -> read active-model from KV\n  -> SwitcherAgent.process(text, model)\n  -> Telnyx AI Inference\n  -> return reply + model\n```\n\nThe sample includes these models:\n\n`moonshotai/Kimi-K2.6`\n\n`zai-org/GLM-5.2`\n\n`meta-llama/Llama-3.3-70B-Instruct`\n\nModel choice is product behavior.\n\nChanging the model can affect:\n\nSo it helps to make the active model observable and switchable without mixing that decision into application deploys.\n\nSwitch the active model:\n\n```\ncurl -X POST https://multi-model-inference-switcher-<id>.telnyxcompute.com/model \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"model\":\"zai-org/GLM-5.2\"}'\n```\n\nSend a chat message:\n\n```\ncurl -X POST https://multi-model-inference-switcher-<id>.telnyxcompute.com/chat \\\n  -H \"Content-Type: application/json\" \\\n  -d '{\"text\":\"Explain feature flags for AI models.\"}'\n```\n\nExample response:\n\n``` js\n{\n  \"reply\": \"Feature flags let you change behavior at runtime...\",\n  \"model\": \"zai-org/GLM-5.2\"\n}\n```\n\nInspect history and usage:\n\n```\ncurl https://multi-model-inference-switcher-<id>.telnyxcompute.com/history\n```\n\nThe `SwitcherAgent`\n\nuses:\n\nThe inference call looks like:\n\n```\nthis.env.TELNYX.ai.openai.chat.createCompletion({\n  model,\n  messages,\n  max_tokens: 2000,\n  temperature: 0.7,\n});\n```\n\nThe key part is that `model`\n\ncomes from KV, not a hardcoded constant.\n\n```\ngit clone https://github.com/team-telnyx/telnyx-code-examples.git\ncd telnyx-code-examples/multi-model-inference-switcher\nnpm install\n```\n\nCreate and seed KV:\n\n```\ntelnyx-edge storage kv create --name \"switcher-flag\"\ntelnyx-edge storage kv key put <kv-id> active-model moonshotai/Kimi-K2.6\n```\n\nSet your namespace ID in `telnyx.toml`\n\n, add your secret, and deploy:\n\n```\ntelnyx-edge secrets add TELNYX_API_KEY <YOUR_API_KEY>\ntelnyx-edge ship\n```\n\nBefore exposing this publicly, add:\n\n`/model`\n\nThe small idea here is powerful: keep your app deployed, but make model selection something you can operate.\n\nResources:", "url": "https://wpnews.pro/news/switch-ai-models-at-runtime-on-telnyx-edge-compute", "canonical_source": "https://dev.to/sonam_50a41a4ced7e6b4f3fa/switch-ai-models-at-runtime-on-telnyx-edge-compute-2ncf", "published_at": "2026-08-20 22:13:11+00:00", "updated_at": "2026-08-20 22:44:02.532157+00:00", "lang": "en", "topics": ["developer-tools", "ai-infrastructure", "ai-products"], "entities": ["Telnyx", "Telnyx Edge Compute", "Telnyx Agent SDK", "Telnyx KV Storage", "moonshotai/Kimi-K2.6", "zai-org/GLM-5.2", "meta-llama/Llama-3.3-70B-Instruct"], "alternates": {"html": "https://wpnews.pro/news/switch-ai-models-at-runtime-on-telnyx-edge-compute", "markdown": "https://wpnews.pro/news/switch-ai-models-at-runtime-on-telnyx-edge-compute.md", "text": "https://wpnews.pro/news/switch-ai-models-at-runtime-on-telnyx-edge-compute.txt", "jsonld": "https://wpnews.pro/news/switch-ai-models-at-runtime-on-telnyx-edge-compute.jsonld"}}