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.

fix: add billing context to /v1/chat/completions endpoint (#10098)

cthomas315c09fcfcfd
diff --git a/letta/server/rest_api/routers/v1/chat_completions.py b/letta/server/rest_api/routers/v1/chat_completions.py
index 1940de24c..58c755d75 100644
--- a/letta/server/rest_api/routers/v1/chat_completions.py
+++ b/letta/server/rest_api/routers/v1/chat_completions.py
@@ -107,6 +107,7 @@ async def _handle_chat_completion(
agent_id=resolved_agent_id,
actor=actor,
request=letta_request,
+ billing_context=headers.billing_context,
)
else:
raise LettaInvalidArgumentError(
diff --git a/letta/services/streaming_service.py b/letta/services/streaming_service.py
index 26c09d444..0f0261d1a 100644
--- a/letta/services/streaming_service.py
+++ b/letta/services/streaming_service.py
@@ -341,6 +341,7 @@ class StreamingService:
agent_id: str,
actor: User,
request: LettaStreamingRequest,
+ billing_context: "BillingContext | None" = None,
) -> StreamingResponse:
"""
Create OpenAI-compatible chat completions streaming response.
@@ -366,6 +367,7 @@ class StreamingService:
actor=actor,
request=request,
run_type="openai_chat_completions",
+ billing_context=billing_context,
)
# extract the stream iterator from the response