| Crates.io | xai-rs |
| lib.rs | xai-rs |
| version | 0.0.8 |
| created_at | 2025-11-11 21:32:12.981231+00 |
| updated_at | 2025-12-10 20:46:37.261109+00 |
| description | Rust SDK for xAI API |
| homepage | |
| repository | https://github.com/nicoestrada/xai-rs |
| max_upload_size | |
| id | 1928218 |
| size | 121,424 |
xai-rs)The xAI Rust SDK is a gRPC client that lets you talk to xAI's API in Rust. It currently exposes an asynchronous client built on tonic.
GetCompletion), streaming chunks (GetCompletionChunk), and agentic server-side tool callingAsyncClient that authenticates with the xAI APIget_completion) and server‑streaming (get_completion_chunk) helpers.proto filesChatMessage), requests (build_request), and tool definitions for server-side agentic flowscargo add xai-rs
Alternatively, add this to your Cargo.toml:
[dependencies]
xai-rs = "0.0.8"
examples/ direxamples/chat_unary.rs – single response via GetCompletionexamples/chat_server_streaming.rs – server-streaming chunks via GetCompletionChunkexamples/agentic_tool_calling.rs – enables server-side web/X/code tools and streams tool-call telemetrycargo run --example <example_name> after setting XAI_API_KEY (and optionally XAI_MODEL)Contributions are welcome! Please open issues or submit pull requests on the GitHub repository.
Open gaps include, additional RPCs (images, models, telemetry, etc.), a sync client, retries, and richer error types.
This project is licensed under the MIT License. See the LICENSE file for details.