Skip to content

Commit 7dfc614

Browse files
committed
Add token-based API validation support
Introduced global and instance-specific tokens for optional API validation in the configuration. Updated the README with the relevant configuration details and examples, along with additional API documentation for managing authentication and token usage.
1 parent 1c50aec commit 7dfc614

File tree

2 files changed

+39
-14
lines changed

2 files changed

+39
-14
lines changed

README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,10 @@ browser:
9090
user-data-dir: "/anyAIProxyAPI/user-data-dir"
9191
api-port: "2048"
9292
headless: false
93+
logfile: "any-ai-proxy.log"
94+
tokens: # Global tokens for API validation (optional)
95+
- "global-token-1"
96+
- "global-token-2"
9397
instance:
9498
- name: "gemini-aistudio"
9599
adapter: "gemini-aistudio"
@@ -104,6 +108,9 @@ instance:
104108
init: "init-system" # init runner
105109
chat_completions: "chat_completions" # chat_completions runner
106110
context_canceled: "context-canceled" # context canceled(client disconnect) runner
111+
tokens: # Instance-specific tokens for API validation (optional)
112+
- "gemini-token-3"
113+
- "gemini-token-4"
107114
- name: "chatgpt"
108115
adapter: "chatgpt"
109116
proxy-url: ""
@@ -141,6 +148,7 @@ instance:
141148
- `user-data-dir`: User data directory
142149
- `api-port`: Port for the API server
143150
- `headless`: Run browser in headless mode
151+
- `tokens`: Global tokens for API validation (optional)
144152
- `instance`: Array of AI service instances to manage. Each instance has its own configuration
145153
- `name`: Instance name
146154
- `adapter`: Adapter name (corresponds to different AI services)
@@ -150,6 +158,7 @@ instance:
150158
- `file`: File to store authentication information
151159
- `check`: CSS selector to check login status
152160
- `runner`: Runner configuration. All runner files must be defined in a directory corresponding to the instance name
161+
- `tokens`: Instance specific tokens for API validation (optional)
153162

154163
For details on the runner file syntax, please refer to [runner.md](runner.md)
155164

@@ -163,29 +172,45 @@ go run main.go
163172

164173
The server will start on the configured port (default: 2048).
165174

175+
### Management Web Interface
176+
177+
#### Uploading Auth information for AI website
178+
```
179+
http://localhost:2048/v1/auth/upload
180+
```
181+
166182
### API Endpoints
167183
168184
#### Chat Completions
169185
```bash
170-
POST http://localhost:2048/v1/chat/completions
171-
Content-Type: application/json
172-
173-
{
174-
"model": "instance-name/model-name",
175-
"messages": [
176-
{
177-
"role": "user",
178-
"content": "Hello, how are you?"
179-
}
180-
]
181-
}
186+
curl -X POST http://localhost:2048/v1/chat/completions \
187+
-H "Content-Type: application/json" \
188+
-d '{
189+
"model": "instance-name/model-name",
190+
"messages": [
191+
{
192+
"role": "user",
193+
"content": "Hello, how are you?"
194+
}
195+
]
196+
}'
182197
```
183198

184199
#### Headless Screenshot
185200
```bash
186201
GET http://localhost:2048/screenshot?instance=instance-name
187202
```
188203

204+
#### Auth Information Upload
205+
```bash
206+
POST http://localhost:2048/v1/auth/upload \
207+
-H "Content-Type: application/json" \
208+
-d '{
209+
"name": "instance-name",
210+
"auth": "{\"cookies\":[],\"local_storage\":{\"key\":\"value\"}}"
211+
}'
212+
```
213+
189214
#### Server Information
190215
```bash
191216
GET http://localhost:2048/
@@ -340,4 +365,4 @@ A: Please check if the Fingerprint Chromium path configuration is correct and en
340365
A: Set `debug: true` in `runner/main.yaml`, which will enable detailed debug logging.
341366

342367
### Q: Which operating systems are supported?
343-
A: Supports macOS, Linux, and Windows, but requires the corresponding platform's Fingerprint Chromium browser.
368+
A: Supports macOS, Linux, and Windows but requires the corresponding platform's Fingerprint Chromium browser.

runner

Submodule runner updated 1 file

0 commit comments

Comments
 (0)