From f0dfcbc9f9a09fb958aad4740cda76f7f38c977a Mon Sep 17 00:00:00 2001 From: Alberto Garcia Illera Date: Sat, 21 Feb 2026 12:35:11 -0800 Subject: [PATCH] fix: send empty JSON body in session.create() The OpenCode server's POST /session endpoint requires a JSON request body (Content-Type: application/json), even when no parameters are provided. Without a body, the server returns 400 'Malformed JSON in request body'. Both the sync and async create() methods now send body={} so that the SDK serializes an empty JSON object, matching what the server expects. --- src/opencode_ai/resources/session.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/opencode_ai/resources/session.py b/src/opencode_ai/resources/session.py index 7e50413..0d3ba6f 100644 --- a/src/opencode_ai/resources/session.py +++ b/src/opencode_ai/resources/session.py @@ -63,6 +63,7 @@ def create( """Create a new session""" return self._post( "/session", + body={}, options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ), @@ -508,6 +509,7 @@ async def create( """Create a new session""" return await self._post( "/session", + body={}, options=make_request_options( extra_headers=extra_headers, extra_query=extra_query, extra_body=extra_body, timeout=timeout ),