Skip to content

Use xAI in your terminal

Use xAI models with your own key. You pay xAI directly; kunji never sees your bill.

  1. Create an API key at https://console.x.ai.
  2. Run kunji keys add xai and paste the key. kunji checks it works, then stores it in your OS keychain.
  3. Pick a default model from the list (type to search).
  4. Run kunji and start chatting.
Provider id xai
Type OpenAI-compatible API
API address https://api.x.ai/v1
Key variable XAI_API_KEY
Terminal window
kunji models xai # see available models
kunji use xai:<model> # make one your default
kunji chat -m xai:<model> # or chat with it once

Inside a chat, switch to it with /model xai:<model>; the conversation carries over.

For CI or scripts you can skip the keychain:

Terminal window
export XAI_API_KEY=your-key-here
kunji ask -m xai:<model> "Hello"