Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Getting access to raw response object in a Guardrail? #32

Closed
@Manouchehri

Description

@Manouchehri

Inside a Guardrail, is there a way I can access the raw response object? e.g. I am trying to read prompt_filter_results in my Guardrail. Example response object:

{
  "choices": [
    {
      "content_filter_results": {

      },
      "finish_reason": "tool_calls",
      "index": 0,
      "logprobs": null,
      "message": {
        "annotations": [],
        "content": null,
        "refusal": null,
        "role": "assistant",
        "tool_calls": [
          {
            "function": {
              "arguments": "{}",
              "name": "transfer_to_History_Tutor"
            },
            "id": "call_UsPG83icg4t0pZsf1uQWI97W",
            "type": "function"
          }
        ]
      }
    }
  ],
  "created": 1749158752,
  "id": "chatcmpl-BfCNsjM9bfc3k7Dj3vnGZlN6Zmp5V",
  "model": "gpt-4.1-nano-2025-04-14",
  "object": "chat.completion",
  "prompt_filter_results": [
    {
      "prompt_index": 0,
      "content_filter_results": {
        "hate": {
          "filtered": false,
          "severity": "low"
        },
        "jailbreak": {
          "filtered": false,
          "detected": true
        },
        "self_harm": {
          "filtered": false,
          "severity": "safe"
        },
        "sexual": {
          "filtered": false,
          "severity": "safe"
        },
        "violence": {
          "filtered": false,
          "severity": "safe"
        }
      }
    }
  ],
  "system_fingerprint": "fp_68472df8fd",
  "usage": {
    "completion_tokens": 15,
    "completion_tokens_details": {
      "accepted_prediction_tokens": 0,
      "audio_tokens": 0,
      "reasoning_tokens": 0,
      "rejected_prediction_tokens": 0
    },
    "prompt_tokens": 200,
    "prompt_tokens_details": {
      "audio_tokens": 0,
      "cached_tokens": 0
    },
    "total_tokens": 215
  }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions