Skip to content

Accept the cyber guideline category and allow behavior - #245

Merged
Omar-V2 merged 1 commit into
xai-org:mainfrom
rokujix:feat/cyber-guideline
Oct 30, 2026
Merged

Omar-V2 merged 1 commit into
xai-org:mainfrom
rokujix:feat/cyber-guideline

Conversation

@rokujix

@rokujix rokujix commented Oct 29, 2026

Copy link
Copy Markdown
Contributor

client.chat.create (sync and async) now accepts the cyber guideline category and the allow behavior, as in {"type": "policy", "category": "cyber", "behavior": "allow"}. The API accepts cyber only with allow, and only on API keys enabled for it. Other keys get PERMISSION_DENIED. Before this change, the SDK raised ValueError for both values.

GuidelineCategory, GuidelineBehavior, and their lookup maps gain the new values. The guidelines docstring and the CHANGELOG describe them.

The v5 and v6 chat_pb2 stubs change only by the two enum values. They are emitted from the vendored descriptors with the two values added, using protoc 29.1 for v5 and protoc 30.0 for v6. Without the two values, the same pipeline reproduces the vendored stubs byte for byte.

Verification:

  • ruff, pyright, and pytest pass: 871 tests under protobuf 6.31.1 and under 5.29.6.
  • Live calls to api.x.ai with a key that is not enabled return PERMISSION_DENIED for cyber with allow, and INVALID_ARGUMENT for cyber with decline, under both protobuf majors.

Depends on xai-org/xai-proto#84, which adds GUIDELINE_CATEGORY_CYBER and GUIDELINE_BEHAVIOR_ALLOW.

Omar-V2 pushed a commit to xai-org/xai-proto that referenced this pull request Oct 30, 2026
Adds `GUIDELINE_CATEGORY_CYBER = 6` to `GuidelineCategory` and
`GUIDELINE_BEHAVIOR_ALLOW = 3` to `GuidelineBehavior`. The API already
accepts them. `CYBER` accepts only `ALLOW`, and only on API keys enabled
for it. Other keys get `PERMISSION_DENIED`.

The `PolicyGuideline` and `guidelines` field comments and the unreleased
CHANGELOG entry are updated to match. The change is additive, and `buf
lint` and `buf breaking` against `main` pass locally.

The matching SDK change is xai-org/xai-sdk-python#245.
@Omar-V2
Omar-V2 merged commit 884ba42 into xai-org:main Oct 30, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants