Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.
feat: add zai coding provider (#10064)
Ari Webbc1d829f3f87d
diff --git a/fern/openapi.json b/fern/openapi.jsonindex 1c80d96a8..5b24a5ed7 100644--- a/fern/openapi.json+++ b/fern/openapi.json@@ -39241,6 +39241,7 @@"deepseek","xai","zai",+ "zai_coding","baseten","fireworks","openrouter",@@ -42018,6 +42019,7 @@"deepseek","xai","zai",+ "zai_coding","openrouter","chatgpt_oauth"],@@ -43749,7 +43751,8 @@"sglang","openrouter","xai",- "zai"+ "zai",+ "zai_coding"],"title": "ProviderType"},diff --git a/letta/adapters/simple_llm_stream_adapter.py b/letta/adapters/simple_llm_stream_adapter.pyindex 901810b6d..4aba6b5d5 100644--- a/letta/adapters/simple_llm_stream_adapter.py+++ b/letta/adapters/simple_llm_stream_adapter.py@@ -90,6 +90,7 @@ class SimpleLLMStreamAdapter(LettaLLMStreamAdapter):ProviderType.deepseek,ProviderType.openrouter,ProviderType.zai,+ ProviderType.zai_coding,ProviderType.baseten,ProviderType.fireworks,ProviderType.chatgpt_oauth,diff --git a/letta/constants.py b/letta/constants.pyindex cd2a9f08d..08ca90a57 100644--- a/letta/constants.py+++ b/letta/constants.py@@ -25,7 +25,8 @@ PROVIDER_ORDER = {"xai": 12,"lmstudio": 13,"zai": 14,- "openrouter": 15,+ "zai_coding": 15,+ "openrouter": 16,}ADMIN_PREFIX = "/v1/admin"diff --git a/letta/llm_api/llm_client.py b/letta/llm_api/llm_client.pyindex d1ee5a415..239d9e4b3 100644--- a/letta/llm_api/llm_client.py+++ b/letta/llm_api/llm_client.py@@ -79,7 +79,7 @@ class LLMClient:put_inner_thoughts_first=put_inner_thoughts_first,actor=actor,)- case ProviderType.zai:+ case ProviderType.zai | ProviderType.zai_coding:from letta.llm_api.zai_client import ZAIClientreturn ZAIClient(diff --git a/letta/schemas/enums.py b/letta/schemas/enums.pyindex 09db64e2b..94b0f82be 100644--- a/letta/schemas/enums.py+++ b/letta/schemas/enums.py@@ -75,6 +75,7 @@ class ProviderType(str, Enum):openrouter = "openrouter"xai = "xai"zai = "zai"+ zai_coding = "zai_coding"class AgentType(str, Enum):diff --git a/letta/schemas/llm_config.py b/letta/schemas/llm_config.pyindex 3e74b7b71..6ec9f3c69 100644--- a/letta/schemas/llm_config.py+++ b/letta/schemas/llm_config.py@@ -52,6 +52,7 @@ class LLMConfig(BaseModel):"deepseek","xai","zai",+ "zai_coding","baseten","fireworks","openrouter",@@ -431,7 +432,7 @@ class LLMConfig(BaseModel):max_output_tokens=self.max_tokens or 4096,temperature=self.temperature,)- elif self.model_endpoint_type == "zai":+ elif self.model_endpoint_type in ("zai", "zai_coding"):from letta.schemas.model import ZAIThinkingthinking_type = "enabled" if self.enable_reasoner else "disabled"@@ -516,7 +517,7 @@ class LLMConfig(BaseModel):@classmethoddef is_zai_reasoning_model(cls, config: "LLMConfig") -> bool:- return config.model_endpoint_type == "zai" and (+ return config.model_endpoint_type in ("zai", "zai_coding") and (config.model.startswith("glm-4.5")or config.model.startswith("glm-4.6")or config.model.startswith("glm-4.7")diff --git a/letta/schemas/model.py b/letta/schemas/model.pyindex d143b9d3c..e5cc78067 100644--- a/letta/schemas/model.py+++ b/letta/schemas/model.py@@ -49,6 +49,7 @@ class Model(LLMConfig, ModelBase):"deepseek","xai","zai",+ "zai_coding","openrouter","chatgpt_oauth",] = Field(..., description="Deprecated: Use 'provider_type' field instead. The endpoint type for the model.", deprecated=True)@@ -137,6 +138,7 @@ class Model(LLMConfig, ModelBase):ProviderType.azure: AzureModelSettings,ProviderType.xai: XAIModelSettings,ProviderType.zai: ZAIModelSettings,+ ProviderType.zai_coding: ZAIModelSettings,ProviderType.groq: GroqModelSettings,ProviderType.deepseek: DeepseekModelSettings,ProviderType.together: TogetherModelSettings,diff --git a/letta/schemas/providers/__init__.py b/letta/schemas/providers/__init__.pyindex 40e0e3339..4335d1f9b 100644--- a/letta/schemas/providers/__init__.py+++ b/letta/schemas/providers/__init__.py@@ -21,7 +21,7 @@ from .sglang import SGLangProviderfrom .together import TogetherProviderfrom .vllm import VLLMProviderfrom .xai import XAIProvider-from .zai import ZAIProvider+from .zai import ZAICodingProvider, ZAIProvider__all__ = ["AnthropicProvider",@@ -49,5 +49,6 @@ __all__ = ["TogetherProvider","VLLMProvider","XAIProvider",+ "ZAICodingProvider","ZAIProvider",]diff --git a/letta/schemas/providers/base.py b/letta/schemas/providers/base.pyindex d527d4d55..2773faada 100644--- a/letta/schemas/providers/base.py+++ b/letta/schemas/providers/base.py@@ -199,6 +199,7 @@ class Provider(ProviderBase):TogetherProvider,VLLMProvider,XAIProvider,+ ZAICodingProvider,ZAIProvider,)@@ -240,6 +241,8 @@ class Provider(ProviderBase):return XAIProvider(**self.model_dump(exclude_none=True))case ProviderType.zai:return ZAIProvider(**self.model_dump(exclude_none=True))+ case ProviderType.zai_coding:+ return ZAICodingProvider(**self.model_dump(exclude_none=True))case ProviderType.lmstudio_openai:return LMStudioOpenAIProvider(**self.model_dump(exclude_none=True))case ProviderType.bedrock:diff --git a/letta/schemas/providers/zai.py b/letta/schemas/providers/zai.pyindex 1ff308726..b97bca653 100644--- a/letta/schemas/providers/zai.py+++ b/letta/schemas/providers/zai.py@@ -72,3 +72,10 @@ class ZAIProvider(OpenAIProvider):)return configs+++class ZAICodingProvider(ZAIProvider):+ """Z.ai Coding Plan provider - uses coding-specific endpoint."""++ provider_type: Literal[ProviderType.zai_coding] = Field(ProviderType.zai_coding, description="The type of the provider.")+ base_url: str = Field("https://api.z.ai/api/coding/paas/v4/", description="Base URL for the Z.ai Coding API.")diff --git a/letta/services/streaming_service.py b/letta/services/streaming_service.pyindex faac656c8..26c09d444 100644--- a/letta/services/streaming_service.py+++ b/letta/services/streaming_service.py@@ -689,6 +689,7 @@ class StreamingService:"bedrock","deepseek","zai",+ "zai_coding","chatgpt_oauth","minimax","openrouter",