From e994a443d35a34082ad5d6d45dd92163b10635cd Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Sat, 6 Apr 2024 18:08:15 -0400 Subject: [PATCH] README: add OpenRouter instructions (#282) README: Add instructions for using OpenRouter. --- README.org | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/README.org b/README.org index 659667d..b250b2b 100644 --- a/README.org +++ b/README.org @@ -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]] | | Anthropic (Claude) | ✓ | [[https://www.anthropic.com/api][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]]) @@ -61,6 +62,7 @@ GPTel uses Curl if available, but falls back to url-retrieve to work without ext - [[#perplexity][Perplexity]] - [[#anthropic-claude][Anthropic (Claude)]] - [[#groq][Groq]] + - [[#openrouter][OpenRouter]] - [[#usage][Usage]] - [[#in-any-buffer][In any 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: +#+html:
+**** OpenRouter +#+html: + +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:
+ + + ** Usage (This is also a [[https://www.youtube.com/watch?v=bsRnh_brggM][video demo]] showing various uses of gptel.)