docs: 调整readme语言版本

This commit is contained in:
tbphp
2025-07-16 09:32:11 +08:00
parent 39b1290a3f
commit 014af4220a
3 changed files with 560 additions and 560 deletions

372
README.md
View File

@@ -1,272 +1,272 @@
# GPT-Load
[中文文档](README_CN.md) | English
中文文档 | [English](README_EN.md)
[![Release](https://img.shields.io/github/v/release/tbphp/gpt-load)](https://github.com/tbphp/gpt-load/releases)
[![Build Docker Image](https://github.com/tbphp/gpt-load/actions/workflows/docker-build.yml/badge.svg)](https://github.com/tbphp/gpt-load/actions/workflows/docker-build.yml)
![Go Version](https://img.shields.io/badge/Go-1.23+-blue.svg)
![License](https://img.shields.io/badge/license-MIT-green.svg)
A high-performance, enterprise-grade AI API transparent proxy service designed specifically for enterprises and developers who need to integrate multiple AI services. Built with Go, featuring intelligent key management, load balancing, and comprehensive monitoring capabilities, designed for high-concurrency production environments.
一个高性能、企业级的 AI 接口透明代理服务,专门为需要集成多种 AI 服务的企业和开发者设计。采用 Go 语言开发,具备智能密钥管理、负载均衡和完善的监控功能,专为高并发生产环境而设计。
For detailed documentation, please visit [Official Documentation](https://www.gpt-load.com/docs)
详细请查看[官方文档](https://www.gpt-load.com/docs)
## Features
## 功能特性
- **Transparent Proxy**: Complete preservation of native API formats, supporting OpenAI and Google Gemini among other formats (continuously expanding)
- **Intelligent Key Management**: High-performance key pool with group-based management, automatic rotation, and failure recovery
- **Load Balancing**: Weighted load balancing across multiple upstream endpoints to enhance service availability
- **Smart Failure Handling**: Automatic key blacklist management and recovery mechanisms to ensure service continuity
- **Dynamic Configuration**: System settings and group configurations support hot-reload without requiring restarts
- **Enterprise Architecture**: Distributed leader-follower deployment supporting horizontal scaling and high availability
- **Modern Management**: Vue 3-based web management interface that is intuitive and user-friendly
- **Comprehensive Monitoring**: Real-time statistics, health checks, and detailed request logging
- **High-Performance Design**: Zero-copy streaming, connection pool reuse, and atomic operations
- **Production Ready**: Graceful shutdown, error recovery, and comprehensive security mechanisms
- **透明代理**: 完全保留原生 API 格式,支持 OpenAI Google Gemini 等多种格式(持续扩展中)
- **智能密钥管理**: 高性能密钥池,支持分组管理、自动轮换和故障恢复
- **负载均衡**: 支持多上游端点的加权负载均衡,提升服务可用性
- **智能故障处理**: 自动密钥黑名单管理和恢复机制,确保服务连续性
- **动态配置**: 系统设置和分组配置支持热重载,无需重启即可生效
- **企业级架构**: 分布式主从部署,支持水平扩展和高可用
- **现代化管理**: 基于 Vue 3 的 Web 管理界面,直观易用
- **全面监控**: 实时统计、健康检查、详细请求日志
- **高性能设计**: 零拷贝流式传输、连接池复用、原子操作
- **生产就绪**: 优雅关闭、错误恢复、完善的安全机制
## Supported AI Services
## 支持的 AI 服务
GPT-Load serves as a transparent proxy service, completely preserving the native API formats of various AI service providers:
GPT-Load 作为透明代理服务,完整保留各 AI 服务商的原生 API 格式:
- **OpenAI Format**: Official OpenAI API, Azure OpenAI, and other OpenAI-compatible services
- **Google Gemini Format**: Native APIs for Gemini Pro, Gemini Pro Vision, and other models
- **Extensibility**: Plugin-based architecture design for rapid integration of new AI service providers and their native formats
- **OpenAI 格式**: 官方 OpenAI APIAzure OpenAI、以及其他 OpenAI 兼容服务
- **Google Gemini 格式**: Gemini ProGemini Pro Vision 等模型的原生 API
- **扩展性**: 插件化架构设计,可快速集成新的 AI 服务提供商及其原生格式
## Quick Start
## 快速开始
### System Requirements
### 环境要求
- Go 1.23+ (for source builds)
- Docker (for containerized deployment)
- MySQL 8.2+ (for database storage)
- Redis (for caching and distributed coordination, optional)
- Go 1.23+ (源码构建)
- Docker (容器化部署)
- MySQL 8.2+ (数据库存储)
- Redis (缓存和分布式协调,可选)
### Method 1: Using Docker Compose (Recommended)
### 方式一:使用 Docker Compose(推荐)
**Installation Commands:**
**安装命令:**
```bash
# Create Directory
# 创建目录
mkdir -p gpt-load && cd gpt-load
# Download configuration files
# 下载配置文件
wget https://raw.githubusercontent.com/tbphp/gpt-load/refs/heads/main/docker-compose.yml
wget -O .env https://raw.githubusercontent.com/tbphp/gpt-load/refs/heads/main/.env.example
# Edit configuration file (modify service port and authentication key as needed)
# 编辑配置文件根据需要修改服务端口和认证Key等
# vim .env
# Start services (includes MySQL and Redis)
# 启动服务(包含 MySQL Redis
docker compose up -d
```
**Other Commands:**
**其他命令:**
```bash
# Check service status
# 查看服务状态
docker compose ps
# View logs
# 查看日志
docker compose logs -f
# Restart Service
# 重启服务
docker compose down && docker compose up -d
# Update to latest version
# 更新到最新版本
docker compose pull && docker compose down && docker compose up -d
```
After deployment:
部署完成后:
- Access Web Management Interface: <http://localhost:3001>
- API Proxy Address: <http://localhost:3001/proxy>
- 访问 Web 管理界面:<http://localhost:3001>
- API 代理地址:<http://localhost:3001/proxy>
> Use the default authentication key `sk-123456` to login to the management interface. The authentication key can be modified via AUTH_KEY in the .env file.
> 使用默认的认证 Key `sk-123456` 登录管理端,认证 Key 可以在 .env 中修改 AUTH_KEY。
### Method 2: Source Build
### 方式二:源码构建
Source build requires locally installed MySQL and Redis (optional).
源码构建需要本地已安装 MySQL Redis(可选)。
```bash
# Clone and build
# 克隆并构建
git clone https://github.com/tbphp/gpt-load.git
cd gpt-load
go mod tidy
# Create configuration
# 创建配置
cp .env.example .env
# Modify DATABASE_DSN and REDIS_DSN configurations in .env
# REDIS_DSN is optional; if not configured, memory storage will be enabled
# 修改 .env 中 DATABASE_DSN REDIS_DSN 配置
# REDIS_DSN 为可选,如果不配置则启用内存存储
# Run
# 运行
make run
```
After deployment:
部署完成后:
- Access Web Management Interface: <http://localhost:3001>
- API Proxy Address: <http://localhost:3001/proxy>
- 访问 Web 管理界面:<http://localhost:3001>
- API 代理地址:<http://localhost:3001/proxy>
> Use the default authentication key `sk-123456` to login to the management interface. The authentication key can be modified via AUTH_KEY in the .env file.
> 使用默认的认证 Key `sk-123456` 登录管理端,认证 Key 可以在 .env 中修改 AUTH_KEY。
### Method 3: Cluster Deployment
### 方式三:集群部署
Cluster deployment requires all nodes to connect to the same MySQL and Redis, with Redis being mandatory. It's recommended to use unified distributed MySQL and Redis clusters.
集群部署需要所有节点都连接同一个 MySQL Redis,并且 Redis 是必须要求。建议使用统一的分布式 MySQL Redis 集群。
**Deployment Requirements:**
**部署要求:**
- All nodes must configure identical `AUTH_KEY`, `DATABASE_DSN`, `REDIS_DSN`
- Leader-follower architecture where follower nodes must configure environment variable: `IS_SLAVE=true`
- 所有节点必须配置相同的 `AUTH_KEY``DATABASE_DSN``REDIS_DSN`
- 一主多从架构,从节点必须配置环境变量:`IS_SLAVE=true`
For details, please refer to [Cluster Deployment Documentation](https://www.gpt-load.com/docs/cluster)
详细请参考[集群部署文档](https://www.gpt-load.com/docs/cluster)
## Configuration System
## 配置系统
### Configuration Architecture Overview
### 配置架构概述
GPT-Load adopts a dual-layer configuration architecture:
GPT-Load 采用双层配置架构:
#### 1. Static Configuration (Environment Variables)
#### 1. 静态配置(环境变量)
- **Characteristics**: Read at application startup, immutable during runtime, requires application restart to take effect
- **Purpose**: Infrastructure configuration such as database connections, server ports, authentication keys, etc.
- **Management**: Set via `.env` files or system environment variables
- **特点**:应用启动时读取,运行期间不可修改,需重启应用生效
- **用途**:基础设施配置,如数据库连接、服务器端口、认证密钥等
- **管理方式**:通过 `.env` 文件或系统环境变量设置
#### 2. Dynamic Configuration (Hot-Reload)
#### 2. 动态配置(热重载)
- **System Settings**: Stored in database, providing unified behavioral standards for the entire application
- **Group Configuration**: Behavior parameters customized for specific groups, can override system settings
- **Configuration Priority**: Group Configuration > System Settings
- **Characteristics**: Supports hot-reload, takes effect immediately after modification without application restart
- **系统设置**:存储在数据库中,为整个应用提供统一的行为基准
- **分组配置**:为特定分组定制的行为参数,可覆盖系统设置
- **配置优先级**:分组配置 > 系统设置
- **特点**:支持热重载,修改后立即生效,无需重启应用
### Static Configuration (Environment Variables)
### 静态配置(环境变量)
#### Server Configuration
#### 服务器配置
| Setting | Environment Variable | Default | Description |
| ------------------------- | ---------------------------------- | --------------- | ----------------------------------------------- |
| Service Port | `PORT` | 3001 | HTTP server listening port |
| Service Address | `HOST` | 0.0.0.0 | HTTP server binding address |
| Read Timeout | `SERVER_READ_TIMEOUT` | 60 | HTTP server read timeout (seconds) |
| Write Timeout | `SERVER_WRITE_TIMEOUT` | 600 | HTTP server write timeout (seconds) |
| Idle Timeout | `SERVER_IDLE_TIMEOUT` | 120 | HTTP connection idle timeout (seconds) |
| Graceful Shutdown Timeout | `SERVER_GRACEFUL_SHUTDOWN_TIMEOUT` | 10 | Service graceful shutdown wait time (seconds) |
| Follower Mode | `IS_SLAVE` | false | Follower node identifier for cluster deployment |
| Timezone | `TZ` | `Asia/Shanghai` | Specify timezone |
| 配置项 | 环境变量 | 默认值 | 说明 |
| ------------ | ---------------------------------- | --------------- | -------------------------- |
| 服务端口 | `PORT` | 3001 | HTTP 服务器监听端口 |
| 服务地址 | `HOST` | 0.0.0.0 | HTTP 服务器绑定地址 |
| 读取超时 | `SERVER_READ_TIMEOUT` | 60 | HTTP 服务器读取超时(秒) |
| 写入超时 | `SERVER_WRITE_TIMEOUT` | 600 | HTTP 服务器写入超时(秒) |
| 空闲超时 | `SERVER_IDLE_TIMEOUT` | 120 | HTTP 连接空闲超时(秒) |
| 优雅关闭超时 | `SERVER_GRACEFUL_SHUTDOWN_TIMEOUT` | 10 | 服务优雅关闭等待时间(秒) |
| 从节点模式 | `IS_SLAVE` | false | 集群部署时从节点标识 |
| 时区 | `TZ` | `Asia/Shanghai` | 指定时区 |
#### Authentication & Database Configuration
#### 认证与数据库配置
| Setting | Environment Variable | Default | Description |
| ------------------- | -------------------- | ----------- | ------------------------------------------------------------------------------- |
| Authentication Key | `AUTH_KEY` | `sk-123456` | Unique authentication key for accessing management interface and proxy requests |
| Database Connection | `DATABASE_DSN` | - | MySQL database connection string |
| Redis Connection | `REDIS_DSN` | - | Redis connection string, uses memory storage when empty |
| 配置项 | 环境变量 | 默认值 | 说明 |
| ---------- | -------------- | ----------- | ------------------------------------ |
| 认证密钥 | `AUTH_KEY` | `sk-123456` | 访问管理端以及请求代理的唯一认证密钥 |
| 数据库连接 | `DATABASE_DSN` | - | MySQL 数据库连接字符串 |
| Redis 连接 | `REDIS_DSN` | - | Redis 连接字符串,为空时使用内存存储 |
#### Performance & CORS Configuration
#### 性能与跨域配置
| Setting | Environment Variable | Default | Description |
| ----------------------- | ------------------------- | ----------------------------- | ----------------------------------------------- |
| Max Concurrent Requests | `MAX_CONCURRENT_REQUESTS` | 100 | Maximum concurrent requests allowed by system |
| Enable CORS | `ENABLE_CORS` | true | Whether to enable Cross-Origin Resource Sharing |
| Allowed Origins | `ALLOWED_ORIGINS` | `*` | Allowed origins, comma-separated |
| Allowed Methods | `ALLOWED_METHODS` | `GET,POST,PUT,DELETE,OPTIONS` | Allowed HTTP methods |
| Allowed Headers | `ALLOWED_HEADERS` | `*` | Allowed request headers, comma-separated |
| Allow Credentials | `ALLOW_CREDENTIALS` | false | Whether to allow sending credentials |
| 配置项 | 环境变量 | 默认值 | 说明 |
| ------------ | ------------------------- | ----------------------------- | ------------------------ |
| 最大并发请求 | `MAX_CONCURRENT_REQUESTS` | 100 | 系统允许的最大并发请求数 |
| 启用 CORS | `ENABLE_CORS` | true | 是否启用跨域资源共享 |
| 允许的来源 | `ALLOWED_ORIGINS` | `*` | 允许的来源,逗号分隔 |
| 允许的方法 | `ALLOWED_METHODS` | `GET,POST,PUT,DELETE,OPTIONS` | 允许的 HTTP 方法 |
| 允许的头部 | `ALLOWED_HEADERS` | `*` | 允许的请求头,逗号分隔 |
| 允许凭据 | `ALLOW_CREDENTIALS` | false | 是否允许发送凭据 |
#### Logging Configuration
#### 日志配置
| Setting | Environment Variable | Default | Description |
| ------------------- | -------------------- | -------------- | ----------------------------------- |
| Log Level | `LOG_LEVEL` | `info` | Log level: debug, info, warn, error |
| Log Format | `LOG_FORMAT` | `text` | Log format: text, json |
| Enable File Logging | `LOG_ENABLE_FILE` | false | Whether to enable file log output |
| Log File Path | `LOG_FILE_PATH` | `logs/app.log` | Log file storage path |
| 配置项 | 环境变量 | 默认值 | 说明 |
| ------------ | ----------------- | -------------- | ---------------------------------- |
| 日志级别 | `LOG_LEVEL` | `info` | 日志级别:debug, info, warn, error |
| 日志格式 | `LOG_FORMAT` | `text` | 日志格式:text, json |
| 启用文件日志 | `LOG_ENABLE_FILE` | false | 是否启用文件日志输出 |
| 日志文件路径 | `LOG_FILE_PATH` | `logs/app.log` | 日志文件存储路径 |
### Dynamic Configuration (Hot-Reload)
### 动态配置(热重载)
Dynamic configuration is stored in the database and supports real-time modification through the web management interface, taking effect immediately without restart.
动态配置存储在数据库中,支持通过 Web 管理界面进行实时修改,修改后立即生效无需重启。
**Configuration Priority**: Group Configuration > System Settings
**配置优先级**:分组配置 > 系统设置
#### Basic Settings
#### 基础设置
| Setting | Field Name | Default | Group Override | Description |
| ------------------ | ------------------------------------ | ----------------------- | -------------- | -------------------------------------------- |
| Project URL | `app_url` | `http://localhost:3001` | ❌ | Project base URL |
| Log Retention Days | `request_log_retention_days` | 7 | ❌ | Request log retention days, 0 for no cleanup |
| Log Write Interval | `request_log_write_interval_minutes` | 5 | ❌ | Log write to database cycle (minutes) |
| 配置项 | 字段名 | 默认值 | 分组可覆盖 | 说明 |
| ------------ | ------------------------------------ | ----------------------- | ---------- | ---------------------------- |
| 项目地址 | `app_url` | `http://localhost:3001` | ❌ | 项目基础 URL |
| 日志保留天数 | `request_log_retention_days` | 7 | ❌ | 请求日志保留天数0 为不清理 |
| 日志写入间隔 | `request_log_write_interval_minutes` | 5 | ❌ | 日志写入数据库周期(分钟) |
#### Request Settings
#### 请求设置
| Setting | Field Name | Default | Group Override | Description |
| ----------------------------- | ------------------------- | ------- | -------------- | ------------------------------------------------------------------- |
| Request Timeout | `request_timeout` | 600 | ✅ | Forward request complete lifecycle timeout (seconds) |
| Connection Timeout | `connect_timeout` | 15 | ✅ | Timeout for establishing connection with upstream service (seconds) |
| Idle Connection Timeout | `idle_conn_timeout` | 120 | ✅ | HTTP client idle connection timeout (seconds) |
| Response Header Timeout | `response_header_timeout` | 15 | ✅ | Timeout for waiting upstream response headers (seconds) |
| Max Idle Connections | `max_idle_conns` | 100 | ✅ | Connection pool maximum total idle connections |
| Max Idle Connections Per Host | `max_idle_conns_per_host` | 50 | ✅ | Maximum idle connections per upstream host |
| 配置项 | 字段名 | 默认值 | 分组可覆盖 | 说明 |
| -------------------- | ------------------------- | ------ | ---------- | ------------------------------ |
| 请求超时 | `request_timeout` | 600 | ✅ | 转发请求完整生命周期超时(秒) |
| 连接超时 | `connect_timeout` | 15 | ✅ | 与上游服务建立连接超时(秒) |
| 空闲连接超时 | `idle_conn_timeout` | 120 | ✅ | HTTP 客户端空闲连接超时(秒) |
| 响应头超时 | `response_header_timeout` | 15 | ✅ | 等待上游响应头超时(秒) |
| 最大空闲连接数 | `max_idle_conns` | 100 | ✅ | 连接池最大空闲连接总数 |
| 每主机最大空闲连接数 | `max_idle_conns_per_host` | 50 | ✅ | 每个上游主机最大空闲连接数 |
#### Key Configuration
#### 密钥配置
| Setting | Field Name | Default | Group Override | Description |
| -------------------------- | --------------------------------- | ------- | -------------- | -------------------------------------------------------------------------- |
| Max Retries | `max_retries` | 3 | ✅ | Maximum retry count using different keys for single request |
| Blacklist Threshold | `blacklist_threshold` | 3 | ✅ | Number of consecutive failures before key enters blacklist |
| Key Validation Interval | `key_validation_interval_minutes` | 60 | ✅ | Background scheduled key validation cycle (minutes) |
| Key Validation Concurrency | `key_validation_concurrency` | 10 | ✅ | Concurrency for background validation of invalid keys |
| Key Validation Timeout | `key_validation_timeout_seconds` | 20 | ✅ | API request timeout for validating individual keys in background (seconds) |
| 配置项 | 字段名 | 默认值 | 分组可覆盖 | 说明 |
| -------------- | --------------------------------- | ------ | ---------- | ------------------------------------------------ |
| 最大重试次数 | `max_retries` | 3 | ✅ | 单个请求使用不同密钥的最大重试次数 |
| 黑名单阈值 | `blacklist_threshold` | 3 | ✅ | 密钥连续失败多少次后进入黑名单 |
| 密钥验证间隔 | `key_validation_interval_minutes` | 60 | ✅ | 后台定时验证密钥周期(分钟) |
| 密钥验证并发数 | `key_validation_concurrency` | 10 | ✅ | 后台定时验证无效 Key 时的并发数 |
| 密钥验证超时 | `key_validation_timeout_seconds` | 20 | ✅ | 后台定时验证单个 Key 时的 API 请求超时时间(秒) |
## Web Management Interface
## Web 管理界面
Access the management console at: <http://localhost:3001> (default address)
访问管理控制台:<http://localhost:3001>(默认地址)
### Interface Overview
### 界面展示
<img src="screenshot/dashboard.png" alt="Dashboard" width="600"/>
<img src="screenshot/dashboard.png" alt="仪表盘" width="600" />
<br/>
<img src="screenshot/keys.png" alt="Key Management" width="600"/>
<img src="screenshot/keys.png" alt="密钥管理" width="600" />
<br/>
The web management interface provides the following features:
Web 管理界面提供以下功能:
- **Dashboard**: Real-time statistics and system status overview
- **Key Management**: Create and configure AI service provider groups, add, delete, and monitor API keys
- **Request Logs**: Detailed request history and debugging information
- **System Settings**: Global configuration management and hot-reload
- **仪表盘**: 实时统计信息和系统状态概览
- **密钥管理**: 创建和配置 AI 服务商分组,添加、删除和监控 API 密钥
- **请求日志**: 详细的请求历史记录和调试信息
- **系统设置**: 全局配置管理和热重载
## API Usage Guide
## API 使用说明
### Proxy Interface Invocation
### 代理接口调用方式
GPT-Load routes requests to different AI services through group names. Usage is as follows:
GPT-Load 通过分组名称路由请求到不同的 AI 服务。使用方式如下:
#### 1. Proxy Endpoint Format
#### 1. 代理端点格式
```text
http://localhost:3001/proxy/{group_name}/{original_api_path}
http://localhost:3001/proxy/{group_name}/{原始API路径}
```
- `{group_name}`: Group name created in the management interface
- `{original_api_path}`: Maintain complete consistency with original AI service paths
- `{group_name}`: 在管理界面创建的分组名称
- `{原始API路径}`: 保持与原始 AI 服务完全一致的路径
#### 2. Authentication Methods
#### 2. 认证方式
As a transparent proxy service, GPT-Load completely preserves the native authentication formats of various AI services:
作为透明代理服务GPT-Load 完全保留各 AI 服务的原生认证格式:
- **OpenAI Format**: Uses `Authorization: Bearer {AUTH_KEY}` header authentication
- **Gemini Format**: Uses URL parameter `key={AUTH_KEY}` authentication
- **Unified Key**: All services use the unified key value configured in the `AUTH_KEY` environment variable
- **OpenAI 格式**: 使用 `Authorization: Bearer {AUTH_KEY}` 头部认证
- **Gemini 格式**: 使用 URL 参数 `key={AUTH_KEY}` 认证
- **统一密钥**: 所有服务都使用环境变量 `AUTH_KEY` 中配置的统一密钥值
#### 3. OpenAI Interface Example
#### 3. OpenAI 接口调用示例
Assuming a group named `openai` was created:
假设创建了名为 `openai` 的分组:
**Original invocation:**
**原始调用方式:**
```bash
curl -X POST https://api.openai.com/v1/chat/completions \
@@ -275,7 +275,7 @@ curl -X POST https://api.openai.com/v1/chat/completions \
-d '{"model": "gpt-4.1-mini", "messages": [{"role": "user", "content": "Hello"}]}'
```
**Proxy invocation:**
**代理调用方式:**
```bash
curl -X POST http://localhost:3001/proxy/openai/v1/chat/completions \
@@ -284,16 +284,16 @@ curl -X POST http://localhost:3001/proxy/openai/v1/chat/completions \
-d '{"model": "gpt-4.1-mini", "messages": [{"role": "user", "content": "Hello"}]}'
```
**Changes required:**
**变更说明:**
- Replace `https://api.openai.com` with `http://localhost:3001/proxy/openai`
- Replace original API Key with unified authentication key `sk-123456` (default value)
- `https://api.openai.com` 替换为 `http://localhost:3001/proxy/openai`
- 将原始 API Key 替换为统一认证密钥 `sk-123456`(默认值)
#### 4. Gemini Interface Example
#### 4. Gemini 接口调用示例
Assuming a group named `gemini` was created:
假设创建了名为 `gemini` 的分组:
**Original invocation:**
**原始调用方式:**
```bash
curl -X POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-pro:generateContent?key=your-gemini-key \
@@ -301,7 +301,7 @@ curl -X POST https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-
-d '{"contents": [{"parts": [{"text": "Hello"}]}]}'
```
**Proxy invocation:**
**代理调用方式:**
```bash
curl -X POST http://localhost:3001/proxy/gemini/v1beta/models/gemini-2.5-pro:generateContent?key=sk-123456 \
@@ -309,37 +309,37 @@ curl -X POST http://localhost:3001/proxy/gemini/v1beta/models/gemini-2.5-pro:gen
-d '{"contents": [{"parts": [{"text": "Hello"}]}]}'
```
**Changes required:**
**变更说明:**
- Replace `https://generativelanguage.googleapis.com` with `http://localhost:3001/proxy/gemini`
- Replace `key=your-gemini-key` in URL parameter with unified authentication key `sk-123456` (default value)
- `https://generativelanguage.googleapis.com` 替换为 `http://localhost:3001/proxy/gemini`
- 将 URL 参数中的 `key=your-gemini-key` 替换为统一认证密钥 `sk-123456`(默认值)
#### 5. Supported Interfaces
#### 5. 支持的接口
**OpenAI Format:**
**OpenAI 格式:**
- `/v1/chat/completions` - Chat conversations
- `/v1/completions` - Text completion
- `/v1/embeddings` - Text embeddings
- `/v1/models` - Model list
- And all other OpenAI-compatible interfaces
- `/v1/chat/completions` - 聊天对话
- `/v1/completions` - 文本补全
- `/v1/embeddings` - 文本嵌入
- `/v1/models` - 模型列表
- 以及其他所有 OpenAI 兼容接口
**Gemini Format:**
**Gemini 格式:**
- `/v1beta/models/*/generateContent` - Content generation
- `/v1beta/models` - Model list
- And all other Gemini native interfaces
- `/v1beta/models/*/generateContent` - 内容生成
- `/v1beta/models` - 模型列表
- 以及其他所有 Gemini 原生接口
#### 6. Client SDK Configuration
#### 6. 客户端 SDK 配置
**OpenAI Python SDK:**
**OpenAI Python SDK**
```python
from openai import OpenAI
client = OpenAI(
api_key="sk-123456", # Use unified authentication key
base_url="http://localhost:3001/proxy/openai" # Use proxy endpoint
api_key="sk-123456", # 使用统一认证密钥
base_url="http://localhost:3001/proxy/openai" # 使用代理端点
)
response = client.chat.completions.create(
@@ -348,14 +348,14 @@ response = client.chat.completions.create(
)
```
**Google Gemini SDK (Python):**
**Google Gemini SDK (Python)**
```python
import google.generativeai as genai
# Configure API key and base URL
# 配置 API 密钥和基础 URL
genai.configure(
api_key="sk-123456", # Use unified authentication key
api_key="sk-123456", # 使用统一认证密钥
client_options={"api_endpoint": "http://localhost:3001/proxy/gemini"}
)
@@ -363,11 +363,11 @@ model = genai.GenerativeModel('gemini-2.5-pro')
response = model.generate_content("Hello")
```
> **Important Note**: As a transparent proxy service, GPT-Load completely preserves the native API formats and authentication methods of various AI services. You only need to replace the endpoint address and use the unified key value for seamless migration.
> **重要提示**作为透明代理服务GPT-Load 完全保留各 AI 服务的原生 API 格式和认证方式,仅需要替换端点地址并使用统一密钥值即可无缝迁移。
## License
## 许可证
MIT License - see [LICENSE](LICENSE) file for details.
MIT 许可证 - 详情请参阅 [LICENSE](LICENSE) 文件。
## Star History