README: add OpenRouter instructions (#282)

README: Add instructions for using OpenRouter.
This commit is contained in:
Bryan Larsen 2024-04-06 18:08:15 -04:00 committed by GitHub
parent b4088e3f7b
commit e994a443d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -20,6 +20,7 @@ GPTel is a simple Large Language Model chat client for Emacs, with support for m
| Perplexity | ✓ | [[https://docs.perplexity.ai/docs/getting-started][API key]] | | Perplexity | ✓ | [[https://docs.perplexity.ai/docs/getting-started][API key]] |
| Anthropic (Claude) | ✓ | [[https://www.anthropic.com/api][API key]] | | Anthropic (Claude) | ✓ | [[https://www.anthropic.com/api][API key]] |
| Groq | ✓ | [[https://console.groq.com/keys][API key]] | | Groq | ✓ | [[https://console.groq.com/keys][API key]] |
| OpenRouter | ✓ | [[https://openrouter.ai/keys][API key]] |
*General usage*: ([[https://www.youtube.com/watch?v=bsRnh_brggM][YouTube Demo]]) *General usage*: ([[https://www.youtube.com/watch?v=bsRnh_brggM][YouTube Demo]])
@ -61,6 +62,7 @@ GPTel uses Curl if available, but falls back to url-retrieve to work without ext
- [[#perplexity][Perplexity]] - [[#perplexity][Perplexity]]
- [[#anthropic-claude][Anthropic (Claude)]] - [[#anthropic-claude][Anthropic (Claude)]]
- [[#groq][Groq]] - [[#groq][Groq]]
- [[#openrouter][OpenRouter]]
- [[#usage][Usage]] - [[#usage][Usage]]
- [[#in-any-buffer][In any buffer:]] - [[#in-any-buffer][In any buffer:]]
- [[#in-a-dedicated-chat-buffer][In a dedicated chat buffer:]] - [[#in-a-dedicated-chat-buffer][In a dedicated chat buffer:]]
@ -506,6 +508,54 @@ The above code makes the backend available to select. If you want it to be the
#+html: </details> #+html: </details>
#+html: <details><summary>
**** OpenRouter
#+html: </summary>
Register a backend with
#+begin_src emacs-lisp
;; OpenRouter offers an OpenAI compatible API
(gptel-make-openai "OpenRouter" ;Any name you want
:host "openrouter.ai"
:endpoint "/api/v1/chat/completions"
:stream t
:key "your-api-key" ;can be a function that returns the key
:models '("openai/gpt-3.5-turbo"
"mistralai/mixtral-8x7b-instruct"
"meta-llama/codellama-34b-instruct"
"codellama/codellama-70b-instruct"
"google/palm-2-codechat-bison-32k"
"google/gemini-pro"))
#+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 "mixtral-8x7b-32768"
gptel-backend
(gptel-make-openai "OpenRouter" ;Any name you want
:host "openrouter.ai"
:endpoint "/api/v1/chat/completions"
:stream t
:key "your-api-key" ;can be a function that returns the key
:models '("openai/gpt-3.5-turbo"
"mistralai/mixtral-8x7b-instruct"
"meta-llama/codellama-34b-instruct"
"codellama/codellama-70b-instruct"
"google/palm-2-codechat-bison-32k"
"google/gemini-pro")))
#+end_src
#+html: </details>
** Usage ** Usage
(This is also a [[https://www.youtube.com/watch?v=bsRnh_brggM][video demo]] showing various uses of gptel.) (This is also a [[https://www.youtube.com/watch?v=bsRnh_brggM][video demo]] showing various uses of gptel.)