LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
    • Overview
    • Caches
    • Callbacks
    • Documents
    • Document loaders
    • Embeddings
    • Exceptions
    • Language models
    • Serialization
    • Output parsers
    • Prompts
    • Rate limiters
    • Retrievers
    • Runnables
    • Utilities
    • Vector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    โŒ˜I

    Chat LangChain

    What can I help with?

    Enter to sendยทShift+Enter new line

    Menu

    OverviewCachesCallbacksDocumentsDocument loadersEmbeddingsExceptionsLanguage modelsSerializationOutput parsersPromptsRate limitersRetrieversRunnablesUtilitiesVector stores
    MCP Adapters
    Standard Tests
    Text Splitters
    Language
    Theme
    Pythonlangchain-coremessagescontentRefusalContentBlock
    Classโ—Since v1.7

    RefusalContentBlock

    Copy
    RefusalContentBlock()

    Bases

    TypedDict

    Constructors

    Attributes

    View source on GitHub
    constructor
    __init__
    NameType
    typeLiteral['refusal']
    refusalstr
    idNotRequired[str]
    indexNotRequired[int | str]
    extrasNotRequired[dict[str, Any]]
    attribute
    type: Literal['refusal']

    Type of the content block. Used for discrimination.

    attribute
    refusal: str

    Human-readable refusal message, or an empty string if none was provided.

    attribute
    id: NotRequired[str]

    Unique identifier for this content block.

    attribute
    index: NotRequired[int | str]

    Index of block in aggregate response. Used during streaming.

    attribute
    extras: NotRequired[dict[str, Any]]

    Provider-specific metadata, e.g. Anthropic's refusal category.

    An explicit refusal reported by the model provider.

    Providers report refusals differently: OpenAI returns refusal content, while Anthropic reports a refusal stop reason on the response. Both are represented as this block so callers can detect a refusal without provider-specific code. Refusals the model writes as ordinary text are not detected.