FG
🤖 AI & LLMsAnthropic

Unexpected failure when `None` is passed for optional API endpoints, due to `NotGiven` class

Freshalmost 2 years ago
Mar 14, 20260 views
Confidence Score86%
86%

Problem

I was surprised to see an error when creating a response like so [code block] It works if I omit the system kwarg entirely. But it's generally intuitive to use None for higher-order functions where kwargs are optional, but it fails here. I've not seen this kind of type before, and would've hoped that None would be available, too: [code block]

Error Output

error when creating a response like so

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
Moderate Confidence Fix
84% confidence100% success rate2 verificationsLast verified Mar 14, 2026

Solution: Unexpected failure when `None` is passed for optional API endpoints, due to `NotGiven` class

Low Risk

Thanks for bringing this up. Upon further discussion, we've decided that we want to continue to have `None` mean sending `null` in the API, and since the API does not accept `system: null` right now, you won't be able to pass `system=None`. However, we did release `NOT_GIVEN` as an exported property in v0.19.2, so you can at least still write an if-else expression.

84

Trust Score

2 verifications

100% success
  1. 1

    Thanks for bringing this up. Upon further discussion, we've decided that we want

    Thanks for bringing this up. Upon further discussion, we've decided that we want to continue to have `None` mean sending `null` in the API, and since the API does not accept `system: null` right now, you won't be able to pass `system=None`.

  2. 2

    However, we did release `NOT_GIVEN` as an exported property in v0.19.2, so you c

    However, we did release `NOT_GIVEN` as an exported property in v0.19.2, so you can at least still write an if-else expression.

Validation

Resolved in anthropics/anthropic-sdk-python GitHub issue #372. Community reactions: 1 upvotes.

Verification Summary

Worked: 2
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

claudeanthropicllmapienhancement