$requestLine, 'host' => $headers['host'] ?? '', 'proxy_authorization' => $headers['proxy-authorization'] ?? '', 'body' => $body, ], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES)); } // Ответ похож на /chat/completions, чтобы AiClient принял его без правок. $payload = json_encode([ 'choices' => [['message' => ['role' => 'assistant', 'content' => 'ответ через прокси']]], 'usage' => ['prompt_tokens' => 5, 'completion_tokens' => 3], ], JSON_UNESCAPED_UNICODE); fwrite( $connection, 'HTTP/1.1 200 OK' . "\r\n" . 'Content-Type: application/json' . "\r\n" . 'Content-Length: ' . strlen((string) $payload) . "\r\n" . 'Connection: close' . "\r\n\r\n" . $payload, ); fclose($connection); }