Skip to content

armgit / letta

Public Imported from GitHub
0

Platform for stateful agents: AI with advanced memory that can learn and self-improve over time.

feat: add gpt 5.4 fast (#9842)

Ari Webbf3592a09325e
diff --git a/letta/constants.py b/letta/constants.py
index 778b3548b..e5e21004b 100644
--- a/letta/constants.py
+++ b/letta/constants.py
@@ -282,6 +282,7 @@ LLM_MAX_CONTEXT_WINDOW = {
"gpt-5.3-codex": 272000,
# gpt-5.4
"gpt-5.4": 1050000,
+ "gpt-5.4-fast": 1050000,
"gpt-5.4-2026-03-05": 1050000,
# reasoners
"o1": 200000,
diff --git a/letta/llm_api/openai_client.py b/letta/llm_api/openai_client.py
index 7ed209a89..22896b457 100644
--- a/letta/llm_api/openai_client.py
+++ b/letta/llm_api/openai_client.py
@@ -393,6 +393,11 @@ class OpenAIClient(LLMClientBase):
parallel_tool_calls=llm_config.parallel_tool_calls if tools and supports_parallel_tool_calling(model) else False,
)
+ # Handle "fast" model variants → real model + priority service tier
+ if data.model.endswith("-fast"):
+ data.model = data.model.removesuffix("-fast")
+ data.service_tier = "priority"
+
# Handle text configuration (verbosity and response format)
text_config_kwargs = {}
@@ -564,6 +569,11 @@ class OpenAIClient(LLMClientBase):
temperature=llm_config.temperature if supports_temperature_param(model) else 1.0,
)
+ # Handle "fast" model variants → real model + priority service tier
+ if data.model.endswith("-fast"):
+ data.model = data.model.removesuffix("-fast")
+ data.service_tier = "priority"
+
# Add verbosity control for GPT-5 models
if supports_verbosity_control(model) and llm_config.verbosity:
data.verbosity = llm_config.verbosity
diff --git a/letta/schemas/openai/chat_completion_request.py b/letta/schemas/openai/chat_completion_request.py
index 8eb2ce9ef..227296049 100644
--- a/letta/schemas/openai/chat_completion_request.py
+++ b/letta/schemas/openai/chat_completion_request.py
@@ -143,6 +143,7 @@ class ChatCompletionRequest(BaseModel):
temperature: Optional[float] = 1
top_p: Optional[float] = 1
user: Optional[str] = None # unique ID of the end-user (for monitoring)
+ service_tier: Optional[str] = None
prompt_cache_retention: Optional[Literal["in_memory", "24h"]] = None
parallel_tool_calls: Optional[bool] = None
instructions: Optional[str] = None
diff --git a/letta/schemas/openai/chat_completions.py b/letta/schemas/openai/chat_completions.py
index 2e666ccc2..2158f2325 100644
--- a/letta/schemas/openai/chat_completions.py
+++ b/letta/schemas/openai/chat_completions.py
@@ -114,6 +114,7 @@ class ChatCompletionRequest(BaseModel):
temperature: Optional[float] = 1
top_p: Optional[float] = 1
user: Optional[str] = None # unique ID of the end-user (for monitoring)
+ service_tier: Optional[str] = None
# function-calling related
tools: Optional[List[Tool]] = None
diff --git a/letta/schemas/providers/openai.py b/letta/schemas/providers/openai.py
index 93e9e38f8..52b947020 100644
--- a/letta/schemas/providers/openai.py
+++ b/letta/schemas/providers/openai.py
@@ -217,6 +217,19 @@ class OpenAIProvider(Provider):
config = self._set_model_parameter_tuned_defaults(model_name, config)
configs.append(config)
+ # Add synthetic fast variants (e.g. gpt-5.4-fast with service_tier="priority")
+ fast_configs = []
+ for config in configs:
+ if config.model == "gpt-5.4":
+ fast_config = config.model_copy(
+ update={
+ "model": "gpt-5.4-fast",
+ "handle": self.get_handle("gpt-5.4-fast"),
+ }
+ )
+ fast_configs.append(fast_config)
+ configs.extend(fast_configs)
+
# for OpenAI, sort in reverse order
if self.base_url == "https://api.openai.com/v1":
configs.sort(key=lambda x: x.model, reverse=True)