arse(payload);
                        headers['Content-Type'] = 'application/json';
                    } catch (e) {
                        throw new Error('Invalid JSON in request body: ' + e.message);
                    }
                }

                // Check if streaming is requested
                const isStreaming = requestBody && requestBody.stream === true;

                const startTime = Date.now();

                if (isStreaming) {
                    // Handle streaming response
  