llm-xai
LLM plugin to access xAI's models
Installation
First, install the LLM command-line utility.
Now install this plugin in the same environment as LLM.
llm install llm-xai
Configuration
You will need an API key from xAI. You can obtain one here.
You can set that as an environment variable called XAI_KEY, or add it to the llm set of saved keys using:
llm keys set xai
Enter key: <paste key here>
Usage
To list available models, run:
llm models list
You should see a list that looks something like this:
xAI: xAI/grok-beta
xAI: xAIcompletion/grok-beta
...
To run a prompt against a model, pass its full model ID to the -m option, like this:
llm chat -m xAI/grok-beta
Enter your prompt, and have a chat:
Chatting with xAI/grok-beta
Type 'exit' or 'quit' to exit
Type '!multi' to enter multiple lines, then '!end' to finish
> sup playa
Hey, what's up?
>
xAI offers a completion endpoint.
llm -m xAIcompletion/grok-beta "You must know this about me:"
I’m not a fan of being alone. I have a hard time finding peace in the silence. My own thoughts drive me crazy. But I knew I had to do this for myself. I had to prove to myself that I could be alone and be okay with it
...
You can set a shorter alias for a model using the llm aliases command like so:
llm aliases set grok xAI/grok-beta
Now you can prompt Claude using:
cat llm_xai.py | llm -m grok-beta -s 'write some pytest tests for this'
Development
To set up this plugin locally, first checkout the code. Then create a new virtual environment:
cd llm-xai
python3 -m venv venv
source venv/bin/activate
Now install the dependencies and test dependencies:
pip install -e '.[test]'
To run the tests:
pytest
Metadata
Release files for llm-xai 0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| llm_xai-0.2.tar.gz | 4.0 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| llm_xai-0.2-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.4 kB
Release files / llm_xai-0.2.tar.gz
| Download URL | llm_xai-0.2.tar.gz |
|---|---|
| Size | 4.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3ff29ac518478994cdd1d731d00276ddace2e78f2ea6e792185a6f846817610f
|
|
BLAKE2b-256 checksum How to use checksums |
5979880bd549d97d772fdb58c14637450f41e96740e0e252fa1a1807f097c346
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.10
|
Release files / llm_xai-0.2-py3-none-any.whl
| Download URL | llm_xai-0.2-py3-none-any.whl |
|---|---|
| Size | 4.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
da10217998467efe8db51e0f2fe4dc11f5e01b17bc2bd2eb9acbc2b4cc97c817
|
|
BLAKE2b-256 checksum How to use checksums |
bac824a5d3830906f3e324023cfd9d5e9be09a86083744495165e87bb382144f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/5.1.1 CPython/3.11.10
|
Security for llm-xai 0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.