v1.12.0 - 2026-04-29
- Cost Tracking: Responses from
chat.sample()/chat.stream(),image.sample()/image.sample_batch(), andvideo.generate()/video.extend()now expose acost_usdproperty that returns the per-request cost in USD (orNonewhen the server does not report cost) - Files API:
client.files.upload()(sync and async) now accepts an optionalexpires_afterparameter to set a TTL on uploaded files. Accepts either anint(seconds) or adatetime.timedelta. After the duration elapses, the file is automatically deleted. - Collections API Enhancements:
- Added
descriptionparameter tocollections.create()andcollections.update()for human-friendly collection descriptions - Added
collections.generate_description()method that asks the API to summarize a collection based on its document contents - Added
field_definitionsparameter tocollections.update()for adding or deleting field definitions on existing collections. Each entry is either an add ({"field_definition": {...}, "operation": "add"}) or a delete ({"key": "...", "operation": "delete"}); typed viaFieldDefinitionAdd/FieldDefinitionDelete(re-exported as the unionFieldDefinitionUpdate) - Added
BytesConfigurationas a third chunking strategy (alongsidechars_configurationandtokens_configuration) onChunkConfiguration - Added
filterparameter tocollections.list_documents()for filtering on file metadata and document fields (e.g.,'status:DOCUMENT_STATUS_PROCESSED','fields.isbn:"978-1-234567-89-0"') wait_for_indexingpolling now treats the newDOCUMENT_STATUS_CHUNKED,DOCUMENT_STATUS_EMBEDDING, andDOCUMENT_STATUS_WRITINGstatuses as in-progress instead of unknown
- Added
- Telemetry Improvements:
- Added tracing span around
collections.reindex_document - Added
collection.idandfile.idspan attributes todelete_collection,add_existing_document,remove_document,reindex_document, andgenerate_description - Added
cost_in_usd_ticksto telemetry span attributes for chat, image, and video responses
- Added tracing span around
- Breaking Change:
chunk_configurationvalidation is now stricter. Whenchunk_configurationis provided, it must specify exactly one ofchars_configuration,tokens_configuration, orbytes_configuration. Previously, calls that omitted all three (e.g., to update onlystrip_whitespace) silently succeeded; they now raiseValueError. Callers updating only top-level chunk flags must now also include their existing chunking strategy.
- Breaking Change: Removed the
team_idfield fromFileresponses returned by the Files API (upload,list,get). The same value is available viaclient.auth.get_api_key_info().team_id, which is the canonical source.
v1.11.0 - 2026-03-27
- Inline File Attachments:
chat.file()now supports inline file data via a newdataparameter (with optionalfilenameandmime_type), in addition to the existingfile_idmode - URL File Attachments:
chat.file()now supports public URL file references via a newurlparameter (with optionalfilenameandmime_type)
v1.10.0 - 2026-03-24
- Video Extension API: Added
extend()andextend_start()methods to sync and async video clients for extending existing videos with a text prompt - Reference-to-Video Generation: Added
reference_image_urlsparameter tovideo.generate(),video.start(), andvideo.prepare()for reference-image-based video generation (R2V)
v1.9.1 - 2026-03-19
- Model Literals: Updated
grok-4.20model variants frombetato GA naming convention (e.g.,grok-4.20,grok-4.20-0309,grok-4.20-multi-agent)
v1.9.0 - 2026-03-19
- Image/Video Batch Support: Added
image.prepare()andvideo.prepare()methods to create batch requests for image and video generation - Batch API Enhancement: Added
input_file_idparameter tobatch.create()for creating batches from uploaded JSONL files - Batch Result Properties: Added
image_responseandvideo_responseproperties onBatchResultfor typed access to image and video batch results - Model Type Signatures: Image and video client methods now accept
Union[ImageGenerationModel, str]/Union[VideoGenerationModel, str]for model parameters, enabling IDE autocomplete
- Polling Robustness: Unknown deferred statuses in video and collections polling loops now emit a warning and continue polling instead of raising
ValueError - Timeout Error Messages:
PollTimernow accepts an optionalcontextparameter for more descriptiveTimeoutErrormessages
v1.8.2 - 2026-03-16
- Video Generation Error Handling: Video generation polling now raises a
VideoGenerationError(withcodeandmessageattributes) when the API reports a generation failure, instead of returning an incomplete response
v1.8.1 - 2026-03-11
- Model Literals: Updated
grok-4.20model variants fromexperimental-betatobetanaming convention (e.g.,grok-4.20-beta,grok-4.20-beta-0309,grok-4.20-multi-agent-beta-0309)
v1.8.0 - 2026-03-05
- Multi-Agent Chat: Added
agent_countparameter tochat.create()for configuring the number of agents (4 or 16) when using multi-agent models - Model Literals:
- Added
grok-4.20-experimental-betaandgrok-4.20-multi-agent-experimental-betamodel variants toChatModel - Added
grok-imagine-image-protoImageGenerationModel
- Added
- Deprecated Models: Removed
grok-2-imagemodel variants fromImageGenerationModel
v1.7.0 - 2026-02-18
- Multi-Reference Image Editing: Added
image_urlsparameter toimage.sample()andimage.sample_batch()for multi-reference image editing with mutual exclusivity enforcement againstimage_url - 2K Image Resolution: Added
"2k"option toImageResolutionfor higher resolution image generation
- Video Polling Defaults: Reduced default
PollTimerpoll interval from 100ms to 1s and introducedDEFAULT_VIDEO_POLL_INTERVALandDEFAULT_VIDEO_TIMEOUTconstants for video clients
- Image Prompt:
BaseImageResponse.promptnow returns an empty string and emits aDeprecationWarningafter theup_sampled_promptfield was removed from theGeneratedImageproto
v1.6.1 - 2026-01-29
- Video Generation API: Added new
client.videosub-client (sync and async) for video generation, supporting text-to-video and image-to-video with configurableaspect_ratio,resolution, andduration - Image Generation Enhancements:
- Added
image_urlparameter toimage.sample()andimage.sample_batch()for using a reference image as a starting point for generation - Added
aspect_ratioparameter for controlling image aspect ratios (e.g.,"1:1","16:9","9:16") - Added
resolutionparameter for controlling image resolution ("1k")
- Added
- Type Aliases: Added
ImageAspectRatio,ImageFormat,ImageResolution,VideoAspectRatio,VideoResolution, andVideoGenerationModeltype aliases - Model Literals: Added
grok-imagine-imagetoImageGenerationModelandgrok-imagine-videoasVideoGenerationModel
v1.6.0 - 2026-01-27
- Batch API: Added new
client.batchsub-client for interacting with the Batch API:- Ability to create, manage, and retrieve batch jobs
- Integration with existing chat objects when adding requests to a batch
- New optional
batch_request_idfield inchat.createmethod
- Developer Role: Added
developerrole support for chat messages withdeveloper()utility function - Tool Call ID Field: Added
tool_call_idfield and argument totool_resultutility function for explicit tool call identification - User Location for Web Search: Added user-location support to
web_search()server-side tool with new location-related arguments
- Telemetry Improvements:
- Updated chat spans to be compliant with latest OpenTelemetry
gen_aisemantic conventions - Now emits
xaiundergen_ai.provider.namefield instead ofgen_ai.system - Added
server.addressattribute set toapi.x.ai - Added instrumentation for Files API methods (
upload,delete) - Added instrumentation for Collections API methods (
create,update,delete,upload_document,add_existing_document,remove_document,update_document)
- Updated chat spans to be compliant with latest OpenTelemetry
v1.5.0 - 2025-12-04
- Server-Side Tool Output Utilities: Added utility functions to retrieve server-side tool call outputs from responses
- Collections API Enhancements:
- Added
field_definitionsparameter tocollections.create()enabling custom document metadata schemas with validation constraints (required,unique,inject_into_chunk) - Added
metric_spaceparameter tocollections.create()supporting HNSW distance metrics (cosine,euclidean,inner_product) - Added
filterparameter tocollections.list()with support for filtering bycollection_name,created_at, anddocuments_count - Added
wait_for_indexingparameter to document upload with customizablepoll_intervalandtimeout - Added
instructionsandretrieval_modeparameters tocollections.search() - Implemented dict-based
TypedDictinterfaces as ergonomic alternatives to protobuf objects
- Added
- Inline Citations: Added property methods for convenient access to inline citations on responses for both streaming and unary responses
- Added
end_indexfield forInlineCitation
- Added
- Verbose Streaming: Added
verbose_streamingto include options for streaming responses
- Renamed built-in document search tool to "attachment search" for clarity
- Collections
upload_documentnow streams bytes via the FilesUploadFileendpoint, then attaches the resulting file to the collection
- Breaking Change: The
content_typeparameter was removed from the publiccollections.upload_documentfunction
v1.4.1 - 2025-11-26
- Tool Call Status Tracking: Added status field to tool call entries in chat response outputs for tracking tool execution progress
- Tool call messages now include a status field indicating the current state of the tool call
- Multiple entries for the same tool call can now represent different stages (in progress, success, failure)
- Enables real-time tracking of server-side tool execution lifecycle
- Batch File Upload: Added
batch_uploadmethod to both sync and async file clients for concurrent uploads of multiple files with progress tracking - Max Turns Parameter: Added
max_turnsparameter tochat.createfor configuring the maximum number of agentic turns when using server-side tools - Include Field: Added
includefield to chat requests allowing users to specify optional outputs to be returned (e.g., tool output, inline citations) - Inline Citations: Added
InlineCitationsupport for agentic search outputs - Model Literals: Introduced
Modelliterals for type-safe model specification and editor autocomplete support
- Reorganized existing literals into the
typesfolder for better organization - Updated gRPC metadata to include the language (Python) alongside SDK version
v1.4.0 - 2025-11-07
- Files API: Added support for the Files API with new
client.filessub-client for uploading and managing files - Remote MCP Tools: Added support for remote MCP (Model Context Protocol) tool integration, enabling connection to external MCP servers
- Collections Search Tool: Added collections-search as a server-side tool with proto support and convenience utility functions
- Structured Outputs Enhancement: Allow passing a Pydantic
BaseModeldirectly toresponse_formatparameter inchat.createfor type-safe structured outputs - Client Resource Management: Added context manager support and explicit
close()methods toClientandAsyncClientfor proper gRPC channel cleanup - Chat Response Features:
- Added support for encrypted content in chat responses
- Added debug output support in chat responses
- Tool Enhancements:
- Added
SERVER_SIDE_TOOL_MCPandSERVER_SIDE_TOOL_COLLECTIONS_SEARCHtoServerSideToolusage enum - Added
ToolCallTypesupport inToolCallfor distinguishing between client-side and server-side tools - Added utility function
get_tool_call_type()for retrieving tool call types - Added new examples for MCP and collections search server-side tools
- Added
- Client Configuration:
- Added option to use an insecure gRPC channel via
insecureparameter (useful for local development) - Added
xai-sdk-versionmetadata header to all gRPC requests for better debugging and analytics
- Added option to use an insecure gRPC channel via
- Telemetry Controls: Added ability to exclude sensitive attributes from telemetry spans/traces via the
XAI_SDK_DISABLE_SENSITIVE_TELEMETRY_ATTRIBUTESenvironment variable
- Optimized streaming chat response memory usage with lazy buffering
- Renamed internal
ChoiceChunkclass toCompletionOutputChunk - Improved agentic response handling to append all output entries correctly
- Set index correctly in
parsemethod for chat responses
- Removed double await in
UnaryStreamAioInterceptor
v1.3.1 - 2025-10-17
- Fixed handling of multi-output responses in agentic workflows (server-side tools). When server-side tools are used, the API returns multiple completion outputs in a single response (tool call → tool result → final answer). This release ensures:
response.tool_callsnow correctly returns ALL tool calls from all assistant outputs in the response, not just those from a single output indexresponse.contentproperly aggregates and returns the final assistant response content- Streaming chunks correctly expose all assistant outputs during agentic multi-turn conversations
- All outputs are properly tracked and indexed, preventing missing tool calls or incomplete responses
v1.3.0 - 2025-10-15
- Added proto support for three new server-side tools in agentic workflows:
web_search(): Enables web search with configurable domain filtering (exclude/allow lists) and image understanding capabilitiesx_search(): Enables X (Twitter) search with date range filtering, handle-based filtering (include/exclude), and both image and video understandingcode_execution(): Enables server-side code execution for computational tasks
- Added convenience functions in new
xai_sdk.toolsmodule for easily creating server-side tool configurations - Added
ServerSideToolenum in usage proto for tracking server-side tool usage (WEB_SEARCH, X_SEARCH, CODE_EXECUTION, VIEW_IMAGE, VIEW_X_VIDEO) - Added
server_side_tools_usedfield toSamplingUsagefor detailed usage tracking of which server-side tools were invoked
- Breaking Proto Change: Renamed response structure fields for semantic clarity and better multi-output support:
GetChatCompletionResponse.choices→GetChatCompletionResponse.outputsGetChatCompletionChunk.choices→GetChatCompletionChunk.outputsChoicemessage type →CompletionOutputChoiceChunkmessage type →CompletionOutputChunk- This change better reflects the API's capability to return multiple completion outputs rather than "choices," providing clearer semantics for the response structure
v1.2.0 - 2025-09-18
- Added support for the new collections API
- Added a new
collectionssub-client toClientandAsyncClientwhich can be used to interact with the collections API. - The
ClientandAsyncClientobjects now accept an optionalmanagement_api_keyparameter which can be used to authenticate requests to the management API (e.g. CRUD operations on collections). Alternatively, theXAI_MANAGEMENT_API_KEYenvironment variable can be used to set this value without having to pass it as a parameter. - Added support for the new stateful chat API
- Added two new parameters to the
chat.createmethod:store_messageswhether to persist messages on xAI servers such that they can be referenced and retrieved later.previous_response_idallows you to specify the ID of a previously stored response to use as the starting point for the new chat.
- Added two new methods to the
chatobject:get_stored_completionallows you to retrieve a previously stored response by its ID.delete_stored_completionallows you to delete a previously stored response by its ID.
- Breaking Change: Removed the
documentssub-client fromClientandAsyncClient. In order to search for documents within collections, use theclient.collections.searchmethod instead.
v1.1.0 - 2025-08-21
- Added OpenTelemetry integration for distributed tracing and monitoring of SDK operations
- Instrumented all methods that make gRPC requests to produce spans with relevant request/response attributes closely adhering to the OpenTelemetry GenAI Semantic Conventions.
- Added a new
telemetrymodule (xai_sdk.telemetry) which can be used to setup trace creation and exporting of traces to an otel backend or to the console - Added a new
documentssub-client toClientandAsyncClientwhich can be used to interact with the documents API. - Added a new
searchmethod on thedocumentssub-client which can be used to perform semantic search for documents that are stored in collections.
v1.0.1 - 2025-07-22
- Fixed a bug that caused the
from_dateandto_dateparameters to have no effect when using them viaSearchParametersfor the live search feature
v1.0.0 - 2025-07-02
- Added support for new parameters to the
x_source(from xai_sdk.search import x_source) for use with the live search API feature:included_x_handlesallows you to limit posts used to those only authored by particular handlesexcluded_x_handlesallows you to exclude posts authored by particular handlespost_favorite_countallows you to set a threshold for the minimum number of favorites a post must have to be consideredpost_view_countallows you to set a threshold for the minimum number of views a post must have to be considered
v1.0.0rc2 - 2025-06-26
- Fixed an issue where long running gRPC requests would prematurely terminate.
v1.0.0rc1 - 2025-06-13
- Initial RC version of the xai-sdk