✨ 𝕏-AI
𝕏-AI is a complete SDK and a WIP CLI/TUI that provides a powerful and intuitive interface to interact with the X-AI API.
📜 Table of Contents
✨ Features
- Fetch API Key Information 🔑
- Chat Completions 💬
- Text Completions 📝
- Embedding Creation 📊
- Fetch Model Information 🧐
- List Embedding Models 📜
- Fetch Language Model Details 🌐
- List Language Models 🗃️
📦 Installation
Add the following to your Cargo.toml:
[]
= "0.0.1"
= { = "1.41.1", = ["full"] }
🛠️ Usage Examples
Fetch API Key Information 🔑
use env;
use ApiKeyRequestBuilder;
use XaiClient;
use ApiKeyFetcher;
use ClientConfig;
async
// Output
// API Key ID: 06e3dd6...5e7f61
Chat Completions 💬
use env;
use ChatCompletionsRequestBuilder;
use XaiClient;
use ChatCompletionsFetcher;
use Message;
use ClientConfig;
async
// Output
// Chatbot Response: The answer to life, the universe, and everything is **42**. However, this answer is famously incomplete without knowing the question, which remains unknown. This concept comes from Douglas Adams' "The Hitchhiker's Guide to the Galaxy." If you're looking for deeper meaning or a more personal answer, I'd say it's about finding what gives your life purpose and joy, which can be quite different for everyone. What do you think might be your personal answer to life and the universe?
Text Completions 📝
use env;
use XaiClient;
use CompletionsRequestBuilder;
use ;
async
// Output
// Generated Text: Make the poem rhyme.
// In the land of code, a language so bright,
// Rust emerges with all its might.
// With safety and speed, it's quite the sight,
// Guarding memory with all its might.
// Fear not the bugs, nor the seg
Embedding Creation 📊
use env;
use XaiClient;
use EmbeddingRequestBuilder;
use ClientConfig;
use EmbeddingFetcher;
async
// Output
// TODO
List Models 📜
use env;
use XaiClient;
use ReducedModelListRequestBuilder;
use ClientConfig;
use ListModelFetcher;
async
// Output
// Model ID: grok-beta, Owned By: xai
// Model ID: grok-vision-beta, Owned By: xai
📌 Examples
[!WARNING]
🚧 Under Construction
This repository contains a list of notebooks examples on how to use the sdk and or the cli. To use the notebooks in this repository, you need to set up your environment. Follow these steps to get started:
-
Clone the repository to your local machine:
-
Install the required dependencies and libraries. Make sure you have
Rust,Jupyter Notebook, andevcxr_jupyterinstalled on your system.# Install a Rust toolchain (e.g. nightly): | # Although not recommended, but, You may need to clean the python thing cz of new v3.12 venv breaking changes # Install Jupyter Notebook # Install evcxr_jupyter, upgrade soon -
Navigate to the cloned repository and build the project:
-
Start Jupyter Notebook:
-
Access the notebooks in your web browser by clicking on the notebook file you want to explore.
| ID | Example | Open on GitHub | Launch on Binder | Launch on Colab |
|---|---|---|---|---|
| 1 | Basic |
🤝 Contributing
Contributions and feedback are welcome! If you'd like to contribute, report an issue, or suggest an enhancement, please engage with the project on GitHub. Your contributions help improve this crate for the community.
📜 License
This crate is licensed under the MIT License. See the LICENSE file for details.