Skip to content

Commit fe9a201

Browse files
committed
feat: add documentation for OpenRouter API support
1 parent 69821f5 commit fe9a201

File tree

3 files changed

+76
-2
lines changed

3 files changed

+76
-2
lines changed

README.md

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ Developed with the help of [SGPT](https://github.com/tbckr/sgpt).
2020
This is a Go implementation. For the original Python implementation,
2121
visit [shell-gpt](https://github.com/TheR1D/shell_gpt). Please keep this in mind when reporting issues.
2222

23-
Note: Currently under heavy refactoring for v3, but v2 is still maintained.
23+
> [!NOTE]
24+
> Currently under heavy refactoring for v3, but v2 is still maintained.
2425
2526
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
2627
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->
@@ -68,6 +69,8 @@ Note: Currently under heavy refactoring for v3, but v2 is still maintained.
6869
results, benefiting from the powerful language model.
6970
- **Bash Functions and Aliases:** Seamlessly integrate SGPT responses into custom bash functions and aliases, optimizing
7071
your workflows and making your daily tasks more efficient.
72+
- **OpenRouter Support:** Use [OpenRouter](https://openrouter.ai) to access various large language models (LLMs) via a
73+
single API, providing flexibility and convenience in your interactions with different models.
7174

7275
By offering these versatile features, SGPT serves as a powerful tool to enhance your overall productivity, streamline
7376
your workflow, and simplify complex tasks.
@@ -183,7 +186,8 @@ To use the OpenAI API, you must first obtain an API key.
183186
After completing these steps, you'll have an OpenAI API key that can be used to interact with the OpenAI models through
184187
the SGPT tool.
185188

186-
**Note:** Your API key is sensitive information. Do not share it with anyone.
189+
> [!IMPORTANT]
190+
> Your API key is sensitive information. Do not share it with anyone.
187191
188192
### Querying OpenAI Models
189193

@@ -263,6 +267,39 @@ There are three "r"s in the word "strawberry".
263267

264268
**Important:** The o1 API does not support personas.
265269

270+
### OpenRouter API Support
271+
272+
SGPT seamlessly integrates with the [OpenRouter API](https://openrouter.ai), giving you access to a wide range of AI
273+
models beyond OpenAI's offerings.
274+
275+
1. Set the OpenRouter API base URL:
276+
```shell
277+
export OPENAI_API_BASE="https://openrouter.ai/api/v1"
278+
```
279+
280+
2. Create an API key at [OpenRouter](https://openrouter.ai/settings/keys) and set it as your environment variable:
281+
```shell
282+
export OPENAI_API_KEY="your_openrouter_api_key"
283+
```
284+
285+
Once configured, you can specify any OpenRouter-supported model with the `-m` flag:
286+
287+
```shell
288+
$ sgpt -m "anthropic/claude-3.7-sonnet" "mass of sun"
289+
The mass of the Sun is approximately:
290+
291+
1.989 × 10^30 kilograms (kg)
292+
293+
This is roughly 333,000 times the mass of Earth. The Sun contains about 99.86% of all the mass in our solar system.
294+
```
295+
296+
Browse the complete list of available models on the [OpenRouter models page](https://openrouter.ai/models).
297+
298+
> [!TIP]
299+
> Under [Integrations](https://openrouter.ai/settings/integrations) in your OpenRouter account, you can link your
300+
> existing OpenAI API key. This allows you to use any remaining OpenAI credits when accessing OpenAI models through
301+
> OpenRouter.
302+
266303
### Chat Capabilities
267304

268305
SGPT provides chat functionality that enables interactive conversations with OpenAI models. You can use the `--chat`

docs/usage/openrouter.md

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# OpenRouter API Support
2+
3+
SGPT seamlessly integrates with the [OpenRouter API](https://openrouter.ai), giving you access to a wide range of AI
4+
models beyond OpenAI's offerings.
5+
6+
## Setup
7+
8+
1. Set the OpenRouter API base URL:
9+
```shell
10+
export OPENAI_API_BASE="https://openrouter.ai/api/v1"
11+
```
12+
13+
2. Create an API key at [OpenRouter](https://openrouter.ai/settings/keys) and set it as your environment variable:
14+
```shell
15+
export OPENAI_API_KEY="your_openrouter_api_key"
16+
```
17+
18+
## Usage
19+
20+
Once configured, you can specify any OpenRouter-supported model with the `-m` flag:
21+
22+
```shell
23+
$ sgpt -m "anthropic/claude-3.7-sonnet" "mass of sun"
24+
The mass of the Sun is approximately:
25+
26+
1.989 × 10^30 kilograms (kg)
27+
28+
This is roughly 333,000 times the mass of Earth. The Sun contains about 99.86% of all the mass in our solar system.
29+
```
30+
31+
Browse the complete list of available models on the [OpenRouter models page](https://openrouter.ai/models).
32+
33+
> [!TIP]
34+
> Under [Integrations](https://openrouter.ai/settings/integrations) in your OpenRouter account, you can link your
35+
> existing OpenAI API key. This allows you to use any remaining OpenAI credits when accessing OpenAI models through
36+
> OpenRouter.

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ nav:
7171
- Query Models: 'usage/query-models.md'
7272
- GPT-4o and GPT4 Vision API: 'usage/gpt-4o.md'
7373
- o1 API Support: 'usage/o1.md'
74+
- OpenRouter API Support: 'usage/openrouter.md'
7475
- Chat: 'usage/chat.md'
7576
- Docker: 'usage/docker.md'
7677
- Personas: 'usage/personas.md'

0 commit comments

Comments
 (0)