Skip to content

Commit 6e250b9

Browse files
authored
README: Add support for xAI (#466)
README.org: Add instructions for xAI.
1 parent e69a00c commit 6e250b9

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

README.org

+39
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ gptel is a simple Large Language Model chat client for Emacs, with support for m
2727
| Cerebras | ✓ | [[https://cloud.cerebras.ai/][API key]] |
2828
| Github Models | ✓ | [[https://github.com/settings/tokens][Token]] |
2929
| Novita AI | ✓ | [[https://novita.ai/model-api/product/llm-api?utm_source=github_gptel&utm_medium=github_readme&utm_campaign=link][Token]] |
30+
| xAI | ✓ | [[https://console.x.ai?utm_source=github_gptel&utm_medium=github_readme&utm_campaign=link][API key]] |
3031
#+html: </div>
3132

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

771773
#+html: </details>
772774

775+
#+html: <details><summary>
776+
**** xAI
777+
#+html: </summary>
778+
779+
Register a backend with
780+
#+begin_src emacs-lisp
781+
;; xAI offers an OpenAI compatible API
782+
(gptel-make-openai "xAI" ;Any name you want
783+
:host "api.x.ai"
784+
:key "your-api-key" ;can be a function that returns the key
785+
:endpoint "/v1/chat/completions"
786+
:stream t
787+
:models '(;; xAI now only offers `grok-beta` as of the time of this writing
788+
grok-beta))
789+
#+end_src
790+
791+
You can pick this backend from the menu when using gptel (see [[#usage][Usage]])
792+
793+
***** (Optional) Set as the default gptel backend
794+
795+
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.
796+
#+begin_src emacs-lisp
797+
;; OPTIONAL configuration
798+
(setq
799+
gptel-model 'grok-beta
800+
gptel-backend
801+
(gptel-make-openai "xAI" ;Any name you want
802+
:host "api.x.ai"
803+
:key "your-api-key" ;can be a function that returns the key
804+
:endpoint "/v1/chat/completions"
805+
:stream t
806+
:models '(;; xAI now only offers `grok-beta` as of the time of this writing
807+
grok-beta)))
808+
#+end_src
809+
810+
#+html: </details>
811+
773812
** Usage
774813

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

0 commit comments

Comments
 (0)