You are browsing documentation for an older version. See the latest documentation here.

AI Audit Log Reference

Kong AI Gateway provides a standardized logging format for AI plugins, enabling the emission of analytics events and facilitating the aggregation of AI usage analytics across various providers.

Log Formats

Each AI plugin returns a set of tokens.

All log entries include the following attributes:

  1. "ai": {
  2. "payload": { "request": "[$optional_payload_request_]" },
  3. "[$plugin_name_1]": {
  4. "payload": { "response": "[$optional_payload_response]" },
  5. "usage": {
  6. "prompt_token": 28,
  7. "total_tokens": 48,
  8. "completion_token": 20,
  9. "cost": 0.0038
  10. },
  11. "meta": {
  12. "request_model": "command",
  13. "provider_name": "cohere",
  14. "response_model": "command",
  15. "plugin_id": "546c3856-24b3-469a-bd6c-f6083babd2cd"
  16. }
  17. },
  18. "[$plugin_name_2]": {
  19. "payload": { "response": "[$optional_payload_response]" },
  20. "usage": {
  21. "prompt_token": 89,
  22. "total_tokens": 145,
  23. "completion_token": 56,
  24. "cost": 0.0012
  25. },
  26. "meta": {
  27. "request_model": "gpt-35-turbo",
  28. "provider_name": "azure",
  29. "response_model": "gpt-35-turbo",
  30. "plugin_id": "5df193be-47a3-4f1b-8c37-37e31af0568b"
  31. }
  32. }
  33. }

Log Details

Each log entry includes the following details:

PropertyDescription
ai.payload.requestThe request payload.
ai.[$plugin_name].payload.responseThe response payload.
ai.[$plugin_name].usage.prompt_tokenNumber of tokens used for prompting.
ai.[$plugin_name].usage.completion_tokenNumber of tokens used for completion.
ai.[$plugin_name].usage.total_tokensTotal number of tokens used.
ai.[$plugin_name].usage.costThe total cost of the request (input and output cost).
ai.[$plugin_name].meta.request_modelModel used for the AI request.
ai.[$plugin_name].meta.provider_nameName of the AI service provider.
ai.[$plugin_name].meta.response_modelModel used for the AI response.
ai.[$plugin_name].meta.plugin_idUnique identifier of the plugin.