$this->requestId, 'gateway_user_id' => $this->userId, // Changed from user_id 'provider' => $this->provider, 'model' => $this->model, 'request_payload' => $this->requestPayload, 'response_payload' => $this->responsePayload, 'prompt_tokens' => $this->promptTokens, 'completion_tokens' => $this->completionTokens, 'total_tokens' => $this->totalTokens, 'response_time_ms' => $this->responseTimeMs, 'cost' => $this->totalCost, // UsageLog has single 'cost' field 'status' => $this->status, 'error_message' => $this->errorMessage, 'ip_address' => $this->ipAddress, 'user_agent' => $this->userAgent, 'timestamp' => now(), // UsageLog uses 'timestamp' instead of created_at ]); } catch (\Exception $e) { Log::error('Failed to log LLM request to UsageLog', [ 'error' => $e->getMessage(), 'gateway_user_id' => $this->userId, 'provider' => $this->provider, 'model' => $this->model, 'request_id' => $this->requestId, ]); throw $e; } } public function failed(\Throwable $exception): void { Log::critical('LogLlmRequest job failed after all retries', [ 'gateway_user_id' => $this->userId, 'provider' => $this->provider, 'model' => $this->model, 'request_id' => $this->requestId, 'error' => $exception->getMessage(), ]); } }