feat: add service_tier support for priority processing#163
Merged
Conversation
Omar-V2
previously approved these changes
Jun 10, 2026
added 4 commits
June 11, 2026 02:05
Add service_tier parameter to chat.create() for requesting priority processing. The response includes a service_tier field indicating which tier was actually used. - Add ServiceTier type (Literal['default', 'priority']) - Add service_tier.py with proto conversion helpers - Add service_tier to chat request, response, and streaming chunks - Update proto definitions (usage_pb2, chat_pb2) for v5 and v6
Regenerated from xai-org/xai-proto#63 which adds ServiceTier enum and service_tier field to chat request/response/chunk.
buf generate produces absolute imports (from xai.api.v1 import ...) but the SDK expects relative imports (from . import ...) since the proto files live under src/xai_sdk/proto/v5/ and v6/.
0d08443 to
798893f
Compare
5fbb2cc to
798893f
Compare
Regenerate chat_pb2 (v5 + v6) so service_tier matches the API wire format: request=31, response=15, chunk=12 (was 30/13/11). Field-number-only change; no fields added or removed. Regenerated from xai-org/xai-proto#65.
Regenerate chat_pb2 (v5 + v6) to expose the code-execution generated files: OutputFile message, output_files on response (13) and chunk (11), and the INCLUDE_OPTION_CODE_EXECUTION_FILES_OUTPUT (9) include option. service_tier unchanged (31/15/12). Regenerated from xai-org/xai-proto#65.
shawnthapa
approved these changes
Jun 12, 2026
double-di
added a commit
to xai-org/xai-proto
that referenced
this pull request
Jun 12, 2026
…iles (#65) Two changes that align the public `chat.proto` with the API. ### 1. Fix `service_tier` field numbers (wire correctness) `service_tier` was assigned numbers that don't match the API, so a requested tier and the tier reported back were silently dropped on the wire. | Message | before | after | |---|---|---| | `GetCompletionsRequest.service_tier` | 30 | **31** | | `GetChatCompletionResponse.service_tier` | 13 | **15** | | `GetChatCompletionChunk.service_tier` | 11 | **12** | ### 2. Add code-execution `output_files` Expose the generated-files output from the code execution tool: - `OutputFile` message (`file_id`, `name`) - `output_files` on `GetChatCompletionResponse` (13) and `GetChatCompletionChunk` (11) - `INCLUDE_OPTION_CODE_EXECUTION_FILES_OUTPUT` (9) so it can be requested All field numbers match the API. `buf build` + `buf lint` pass. xai-sdk-python bindings updated in xai-org/xai-sdk-python#163.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add
service_tierparameter tochat.create()for requesting priority processing at a higher token price.Changes
ServiceTiertype:Literal["default", "priority"]intypes/common.pyservice_tier.py: Proto conversion helpers (service_tier_to_proto,service_tier_from_proto)chat.py: Addedservice_tierparameter tocreate(), streaming chunk aggregation, andResponse.service_tierpropertyServiceTierenum inusage_pb2,service_tierfield on request/response/chunk inchat_pb2(v5 and v6)Usage
Supersedes #159.