Skip to content

Commit 2ff7f16

Browse files
committed
fix: change env and fix a bug which OPENAI_ will exposing to other openai instance.
its not make your api key leak but its will make your request confuse in openai ai gateway
1 parent 037ad30 commit 2ff7f16

14 files changed

Lines changed: 29 additions & 27 deletions

File tree

src/server/utils/env.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,12 @@ export const env = {
7272
},
7373
},
7474
openai: {
75-
enable: Boolean(process.env.OPENAI_API_KEY),
76-
baseUrl: process.env.OPENAI_BASE_URL,
77-
apiKey: process.env.OPENAI_API_KEY,
78-
modelName: process.env.OPENAI_MODEL_NAME ?? 'gpt-4o',
75+
// This only work on tianji internal usage, which call ai feature by tianji.
76+
// add `SHARED_` prefix to avoid exposing to other OpenAI instances.
77+
enable: Boolean(process.env.SHARED_OPENAI_API_KEY),
78+
baseUrl: process.env.SHARED_OPENAI_BASE_URL,
79+
apiKey: process.env.SHARED_OPENAI_API_KEY,
80+
modelName: process.env.SHARED_OPENAI_MODEL_NAME ?? 'gpt-4o',
7981
},
8082
allowRegister: checkEnvTrusty(process.env.ALLOW_REGISTER),
8183
allowOpenapi: checkEnvTrusty(process.env.ALLOW_OPENAPI ?? 'true'),

website/docs/api/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ The Tianji API uses **Bearer Token** authentication. You need to include your AP
1313
### HTTP Header Format
1414

1515
```http
16-
Authorization: Bearer YOUR_API_KEY
16+
Authorization: Bearer <YOUR_API_KEY>
1717
```
1818

1919
## Obtaining API Keys

website/docs/api/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Test your API connection using curl:
5454

5555
```bash
5656
curl -X GET "https://your-tianji-domain.com/open/global/config" \
57-
-H "Authorization: Bearer YOUR_API_KEY" \
57+
-H "Authorization: Bearer <YOUR_API_KEY>" \
5858
-H "Content-Type: application/json"
5959
```
6060

website/docs/install/environment.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ Tianji supports various environment variables to customize its behavior. You can
6262

6363
| Variable | Description | Default | Example |
6464
| --- | --- | --- | --- |
65-
| `OPENAI_API_KEY` | OpenAI API key | - | `your-openai-api-key` |
66-
| `OPENAI_BASE_URL` | Custom OpenAI API URL | - | `https://api.openai.com/v1` |
67-
| `OPENAI_MODEL_NAME` | OpenAI model to use | `gpt-4o` | `gpt-3.5-turbo` |
65+
| `SHARED_OPENAI_API_KEY` | OpenAI API key | - | `your-openai-api-key` |
66+
| `SHARED_OPENAI_BASE_URL` | Custom OpenAI API URL | - | `https://api.openai.com/v1` |
67+
| `SHARED_OPENAI_MODEL_NAME` | OpenAI model to use | `gpt-4o` | `gpt-3.5-turbo` |
6868
| `DEBUG_AI_FEATURE` | Debug AI features | `false` | `true` |
6969

7070
## Sandbox Configuration

website/i18n/de/docusaurus-plugin-content-docs/current/api/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Die Tianji-API verwendet die **Bearer-Token**-Authentifizierung. Sie müssen Ihr
1313
### HTTP-Header-Format
1414

1515
```http
16-
Authorization: Bearer YOUR_API_KEY
16+
Authorization: Bearer <YOUR_API_KEY>
1717
```
1818

1919
## Erhalt von API-Schlüsseln

website/i18n/de/docusaurus-plugin-content-docs/current/api/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ Testen Sie Ihre API-Verbindung mit curl:
5454

5555
```bash
5656
curl -X GET "https://your-tianji-domain.com/open/global/config" \
57-
-H "Authorization: Bearer YOUR_API_KEY" \
57+
-H "Authorization: Bearer <YOUR_API_KEY>" \
5858
-H "Content-Type: application/json"
5959
```
6060

website/i18n/de/docusaurus-plugin-content-docs/current/install/environment.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ Tianji unterstützt verschiedene Umgebungsvariablen zur Anpassung des Verhaltens
6262

6363
| Variable | Beschreibung | Standard | Beispiel |
6464
| --- | --- | --- | --- |
65-
| `OPENAI_API_KEY` | OpenAI API-Schlüssel | - | `your-openai-api-key` |
66-
| `OPENAI_BASE_URL` | Benutzerdefinierte OpenAI API-URL | - | `https://api.openai.com/v1` |
67-
| `OPENAI_MODEL_NAME` | Zu verwendendes OpenAI-Modell | `gpt-4o` | `gpt-3.5-turbo` |
65+
| `SHARED_OPENAI_API_KEY` | OpenAI API-Schlüssel | - | `your-openai-api-key` |
66+
| `SHARED_OPENAI_BASE_URL` | Benutzerdefinierte OpenAI API-URL | - | `https://api.openai.com/v1` |
67+
| `SHARED_OPENAI_MODEL_NAME` | Zu verwendendes OpenAI-Modell | `gpt-4o` | `gpt-3.5-turbo` |
6868
| `DEBUG_AI_FEATURE` | AI-Funktionen debuggen | `false` | `true` |
6969

7070
## Sandbox-Konfiguration

website/i18n/fr/docusaurus-plugin-content-docs/current/install/environment.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ Tianji prend en charge diverses variables d'environnement pour personnaliser son
6262

6363
| Variable | Description | Défault | Exemple |
6464
| --- | --- | --- | --- |
65-
| `OPENAI_API_KEY` | Clé API OpenAI | - | `votre-clé-api-openai` |
66-
| `OPENAI_BASE_URL` | URL API OpenAI personnalisée | - | `https://api.openai.com/v1` |
67-
| `OPENAI_MODEL_NAME` | Modèle OpenAI à utiliser | `gpt-4o` | `gpt-3.5-turbo` |
65+
| `SHARED_OPENAI_API_KEY` | Clé API OpenAI | - | `votre-clé-api-openai` |
66+
| `SHARED_OPENAI_BASE_URL` | URL API OpenAI personnalisée | - | `https://api.openai.com/v1` |
67+
| `SHARED_OPENAI_MODEL_NAME` | Modèle OpenAI à utiliser | `gpt-4o` | `gpt-3.5-turbo` |
6868
| `DEBUG_AI_FEATURE` | Déboguer les fonctionnalités AI | `false` | `true` |
6969

7070
## Configuration du Bac à Sable

website/i18n/ja/docusaurus-plugin-content-docs/current/api/authentication.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Tianji APIは**Bearer Token**認証を使用します。各APIリクエストの
1313
### HTTPヘッダーフォーマット
1414

1515
```http
16-
Authorization: Bearer YOUR_API_KEY
16+
Authorization: Bearer <YOUR_API_KEY>
1717
```
1818

1919
## APIキーの取得

website/i18n/ja/docusaurus-plugin-content-docs/current/api/getting-started.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ curl を使用して API 接続をテストします:
5454

5555
```bash
5656
curl -X GET "https://your-tianji-domain.com/open/global/config" \
57-
-H "Authorization: Bearer YOUR_API_KEY" \
57+
-H "Authorization: Bearer <YOUR_API_KEY>" \
5858
-H "Content-Type: application/json"
5959
```
6060

0 commit comments

Comments
 (0)