Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

README: Add support for xAI #466

Merged
merged 1 commit into from
Nov 6, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 39 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ gptel is a simple Large Language Model chat client for Emacs, with support for m
| Cerebras | ✓ | [[https://cloud.cerebras.ai/][API key]] |
| Github Models | ✓ | [[https://github.com/settings/tokens][Token]] |
| Novita AI | ✓ | [[https://novita.ai/model-api/product/llm-api?utm_source=github_gptel&utm_medium=github_readme&utm_campaign=link][Token]] |
| xAI | ✓ | [[https://console.x.ai?utm_source=github_gptel&utm_medium=github_readme&utm_campaign=link][API key]] |
#+html: </div>

*General usage*: ([[https://www.youtube.com/watch?v=bsRnh_brggM][YouTube Demo]])
Expand Down Expand Up @@ -81,6 +82,7 @@ gptel uses Curl if available, but falls back to url-retrieve to work without ext
- [[#cerebras][Cerebras]]
- [[#github-models][Github Models]]
- [[#novita-ai][Novita AI]]
- [[#xAI][xAI]]
- [[#usage][Usage]]
- [[#in-any-buffer][In any buffer:]]
- [[#in-a-dedicated-chat-buffer][In a dedicated chat buffer:]]
Expand Down Expand Up @@ -770,6 +772,43 @@ The above code makes the backend available to select. If you want it to be the

#+html: </details>

#+html: <details><summary>
**** xAI
#+html: </summary>

Register a backend with
#+begin_src emacs-lisp
;; xAI offers an OpenAI compatible API
(gptel-make-openai "xAI" ;Any name you want
:host "api.x.ai"
:key "your-api-key" ;can be a function that returns the key
:endpoint "/v1/chat/completions"
:stream t
:models '(;; xAI now only offers `grok-beta` as of the time of this writing
grok-beta))
#+end_src

You can pick this backend from the menu when using gptel (see [[#usage][Usage]])

***** (Optional) Set as the default gptel backend

The above code makes the backend available to select. If you want it to be the default backend for gptel, you can set this as the value of =gptel-backend=. Use this instead of the above.
#+begin_src emacs-lisp
;; OPTIONAL configuration
(setq
gptel-model 'grok-beta
gptel-backend
(gptel-make-openai "xAI" ;Any name you want
:host "api.x.ai"
:key "your-api-key" ;can be a function that returns the key
:endpoint "/v1/chat/completions"
:stream t
:models '(;; xAI now only offers `grok-beta` as of the time of this writing
grok-beta)))
#+end_src

#+html: </details>

** Usage

(There is also a [[https://www.youtube.com/watch?v=bsRnh_brggM][video demo]] showing various uses of gptel.)
Expand Down