Skip to content

Commit 22675de

Browse files
committed
docs: document Gemini and VertexAI provider setup and usage
- Add documentation for using both Gemini API and VertexAI Gemini as providers, including configuration options and example commands - Introduce a configuration options table detailing required parameters for Gemini and VertexAI backends - Provide separate example configuration commands for Gemini API and VertexAI Gemini usage - Replace the sequence diagram with a flowchart to better illustrate the interaction between user, CodeGPT, Gemini API, and VertexAI - Update all three README files (English, Simplified Chinese, Traditional Chinese) to reflect these improvements and additions Signed-off-by: Bo-Yi Wu <[email protected]>
1 parent 39afdb6 commit 22675de

File tree

3 files changed

+159
-48
lines changed

3 files changed

+159
-48
lines changed

README.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ English | [繁體中文](./README.zh-tw.md) | [简体中文](./README.zh-cn.md)
2525
- [How to Customize the Default Prompt Folder](#how-to-customize-the-default-prompt-folder)
2626
- [How to Change to Azure OpenAI Service](#how-to-change-to-azure-openai-service)
2727
- [Support for Gemini API Service](#support-for-gemini-api-service)
28+
- [Configuration Options](#configuration-options)
29+
- [Example: Gemini API (default backend)](#example-gemini-api-default-backend)
30+
- [Example: VertexAI Gemini](#example-vertexai-gemini)
2831
- [Support for Anthropic API Service](#support-for-anthropic-api-service)
2932
- [How to Change to Groq API Service](#how-to-change-to-groq-api-service)
3033
- [How to Change to Ollama API Service](#how-to-change-to-ollama-api-service)
@@ -235,33 +238,67 @@ codegpt config set openai.model xxxxx-gpt-4o
235238

236239
### Support for [Gemini][60] API Service
237240

238-
Build with the Gemini API, you can see the [Gemini API documentation][61]. Update the `provider` and `api_key` in your config file. Please create an API key from the [Gemini API][62] page.
241+
You can use the Gemini API or VertexAI Gemini service. See the [Gemini API documentation][61] and [VertexAI documentation][63].
242+
Update the following parameters in your config file.
243+
244+
- Please create an API key from the [Gemini API][62] page (for BackendGeminiAPI) or from [VertexAI API Key][64] (for BackendVertexAI).
245+
246+
#### Configuration Options
247+
248+
| Option | Description | Example Value | Required | Default |
249+
| ------------------- | ------------------------------------------------------------------------------------------------ | ------------------ | -------- | ------------------ |
250+
| **openai.provider** | Set to `gemini` to use Gemini provider | `gemini` | Yes | |
251+
| **gemini.api_key** | API key for Gemini or VertexAI | `xxxxxxx` | Yes | |
252+
| **gemini.model** | Model name (see [Gemini models][61]) | `gemini-2.0-flash` | Yes | |
253+
| **gemini.backend** | Gemini backend: `BackendGeminiAPI` (default, for Gemini API) or `BackendVertexAI` (for VertexAI) | `BackendGeminiAPI` | No | `BackendGeminiAPI` |
254+
| **gemini.project** | VertexAI project ID (required if using `BackendVertexAI`) | `my-gcp-project` | Cond. | |
255+
| **gemini.location** | VertexAI location (required if using `BackendVertexAI`) | `us-central1` | Cond. | |
256+
257+
#### Example: Gemini API (default backend)
239258

240259
```sh
241260
codegpt config set openai.provider gemini
242-
codegpt config set openai.api_key xxxxxxx
243261
codegpt config set openai.model gemini-2.0-flash
262+
codegpt config set gemini.api_key xxxxxxx
263+
# gemini.backend defaults to BackendGeminiAPI, so you can omit it
264+
```
265+
266+
#### Example: VertexAI Gemini
267+
268+
```sh
269+
codegpt config set openai.provider gemini
270+
codegpt config set openai.model gemini-2.0-flash
271+
codegpt config set gemini.backend BackendVertexAI
272+
codegpt config set gemini.project my-gcp-project
273+
codegpt config set gemini.location us-central1
244274
```
245275

246276
[60]: https://ai.google.dev/gemini-api
247277
[61]: https://ai.google.dev/gemini-api/docs
248278
[62]: https://aistudio.google.com/app/apikey
279+
[63]: https://cloud.google.com/vertex-ai/docs/generative-ai/learn/overview
280+
[64]: https://console.cloud.google.com/apis/credentials
249281

250282
```mermaid
251-
sequenceDiagram
252-
participant User
253-
participant GeminiClient as Gemini Provider
254-
participant GenAI as Google GenAI API
255-
256-
User->>GeminiClient: Completion(ctx, content)
257-
GeminiClient->>GenAI: GenerateContent(model, content, config)
258-
GenAI-->>GeminiClient: Response (text, usage metadata)
259-
GeminiClient-->>User: core.Response (text, usage)
260-
261-
User->>GeminiClient: GetSummaryPrefix(ctx, content)
262-
GeminiClient->>GenAI: GenerateContent(model, content, config with function call)
263-
GenAI-->>GeminiClient: Response (function call result)
264-
GeminiClient-->>User: core.Response (prefix or error)
283+
flowchart TD
284+
User([User])
285+
subgraph CodeGPT
286+
GeminiClient([Gemini Provider])
287+
end
288+
subgraph Google
289+
GeminiAPI([Gemini API])
290+
VertexAI([VertexAI Gemini])
291+
end
292+
293+
User -->|Completion / GetSummaryPrefix| GeminiClient
294+
295+
GeminiClient -- BackendGeminiAPI --> GeminiAPI
296+
GeminiAPI -- Response (text, usage) --> GeminiClient
297+
298+
GeminiClient -- BackendVertexAI --> VertexAI
299+
VertexAI -- Response (text, usage) --> GeminiClient
300+
301+
GeminiClient --> User
265302
```
266303

267304
### Support for [Anthropic][100] API Service

README.zh-cn.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
- [如何自定义默认提示文件夹](#如何自定义默认提示文件夹)
2323
- [如何切换到 Azure OpenAI 服务](#如何切换到-azure-openai-服务)
2424
- [支持 Gemini API 服务](#支持-gemini-api-服务)
25+
- [配置选项](#配置选项)
26+
- [示例:Gemini API(默认后端)](#示例gemini-api默认后端)
27+
- [示例:VertexAI Gemini](#示例vertexai-gemini)
2528
- [支持 Anthropic API 服务](#支持-anthropic-api-服务)
2629
- [如何切换到 Groq API 服务](#如何切换到-groq-api-服务)
2730
- [如何切换到 ollama API 服务](#如何切换到-ollama-api-服务)
@@ -223,34 +226,68 @@ codegpt config set openai.model xxxxx-gpt-4o
223226

224227
### 支持 [Gemini][60] API 服务
225228

226-
使用 Gemini API 构建,你可以参见 [Gemini API 文档][61]。在你的配置文件中更新 `provider``api_key`。请从 [Gemini API][62] 页面创建 API key。
229+
你可以使用 Gemini API 或 VertexAI Gemini 服务。参见 [Gemini API 文档][61][VertexAI 文档][63]
230+
请在配置文件中更新以下参数。
231+
232+
- 请从 [Gemini API][62] 页面(用于 BackendGeminiAPI)或 [VertexAI API Key][64](用于 BackendVertexAI)创建 API key。
233+
234+
#### 配置选项
235+
236+
| 选项 | 描述 | 示例值 | 是否必填 | 默认值 |
237+
| ------------------- | ------------------------------------------------------------------------------------------ | ------------------ | -------- | ------------------ |
238+
| **openai.provider** | 设置为 `gemini` 以使用 Gemini 提供商 | `gemini` || |
239+
| **gemini.api_key** | Gemini 或 VertexAI 的 API key | `xxxxxxx` || |
240+
| **gemini.model** | 模型名称(参见 [Gemini 模型][61]| `gemini-2.0-flash` || |
241+
| **gemini.backend** | Gemini 后端:`BackendGeminiAPI`(默认,适用于 Gemini API)或 `BackendVertexAI`(VertexAI) | `BackendGeminiAPI` || `BackendGeminiAPI` |
242+
| **gemini.project** | VertexAI 项目 ID(如使用 `BackendVertexAI` 必填) | `my-gcp-project` | 条件必填 | |
243+
| **gemini.location** | VertexAI 区域(如使用 `BackendVertexAI` 必填) | `us-central1` | 条件必填 | |
244+
245+
#### 示例:Gemini API(默认后端)
227246

228247
```sh
229248
codegpt config set openai.provider gemini
230-
codegpt config set openai.api_key xxxxxxx
249+
codegpt config set gemini.api_key xxxxxxx
231250
codegpt config set openai.model gemini-2.0-flash
251+
# gemini.backend 默认为 BackendGeminiAPI,可省略
232252
```
233253

234-
```mermaid
235-
sequenceDiagram
236-
participant User
237-
participant GeminiClient as Gemini Provider
238-
participant GenAI as Google GenAI API
239-
240-
User->>GeminiClient: Completion(ctx, content)
241-
GeminiClient->>GenAI: GenerateContent(model, content, config)
242-
GenAI-->>GeminiClient: Response (text, usage metadata)
243-
GeminiClient-->>User: core.Response (text, usage)
254+
#### 示例:VertexAI Gemini
244255

245-
User->>GeminiClient: GetSummaryPrefix(ctx, content)
246-
GeminiClient->>GenAI: GenerateContent(model, content, config with function call)
247-
GenAI-->>GeminiClient: Response (function call result)
248-
GeminiClient-->>User: core.Response (prefix or error)
256+
```sh
257+
codegpt config set openai.provider gemini
258+
codegpt config set openai.model gemini-1.5-pro-preview-0409
259+
codegpt config set gemini.backend BackendVertexAI
260+
codegpt config set gemini.project my-gcp-project
261+
codegpt config set gemini.location us-central1
249262
```
250263

251264
[60]: https://ai.google.dev/gemini-api
252265
[61]: https://ai.google.dev/gemini-api/docs
253266
[62]: https://aistudio.google.com/app/apikey
267+
[63]: https://cloud.google.com/vertex-ai/docs/generative-ai/learn/overview
268+
[64]: https://console.cloud.google.com/apis/credentials
269+
270+
```mermaid
271+
flowchart TD
272+
User([用户])
273+
subgraph CodeGPT
274+
GeminiClient([Gemini 提供商])
275+
end
276+
subgraph Google
277+
GeminiAPI([Gemini API])
278+
VertexAI([VertexAI Gemini])
279+
end
280+
281+
User -->|Completion / GetSummaryPrefix| GeminiClient
282+
283+
GeminiClient -- BackendGeminiAPI --> GeminiAPI
284+
GeminiAPI -- Response (text, usage) --> GeminiClient
285+
286+
GeminiClient -- BackendVertexAI --> VertexAI
287+
VertexAI -- Response (text, usage) --> GeminiClient
288+
289+
GeminiClient --> User
290+
```
254291

255292
### 支持 [Anthropic][100] API 服务
256293

README.zh-tw.md

Lines changed: 53 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@
2525
- [如何自定義默認提示文件夾](#如何自定義默認提示文件夾)
2626
- [如何切換到 Azure OpenAI 服務](#如何切換到-azure-openai-服務)
2727
- [支援 Gemini API 服務](#支援-gemini-api-服務)
28+
- [設定選項](#設定選項)
29+
- [範例:Gemini API(預設後端)](#範例gemini-api預設後端)
30+
- [範例:VertexAI Gemini](#範例vertexai-gemini)
2831
- [支援 Anthropic API 服務](#支援-anthropic-api-服務)
2932
- [如何切換到 Groq API 服務](#如何切換到-groq-api-服務)
3033
- [如何切換到 Ollama API 服務](#如何切換到-ollama-api-服務)
@@ -234,34 +237,68 @@ codegpt config set openai.model xxxxx-gpt-4o
234237

235238
### 支援 [Gemini][60] API 服務
236239

237-
使用 Gemini API 構建,您可以查看 [Gemini API 文檔][61]。在您的配置文件中更新 `provider``api_key`。請從 [Gemini API][62] 頁面創建 API key。
240+
你可以使用 Gemini API 或 VertexAI Gemini 服務。請參閱 [Gemini API 文件][61][VertexAI 文件][63]
241+
請在設定檔中更新以下參數。
242+
243+
- 請從 [Gemini API][62] 頁面(用於 BackendGeminiAPI)或 [VertexAI API Key][64](用於 BackendVertexAI)建立 API 金鑰。
244+
245+
#### 設定選項
246+
247+
| 選項 | 說明 | 範例值 | 必填 | 預設值 |
248+
| ------------------- | ------------------------------------------------------------------------------------------ | ------------------ | -------- | ------------------ |
249+
| **openai.provider** | 設為 `gemini` 以使用 Gemini 提供者 | `gemini` || |
250+
| **gemini.api_key** | Gemini 或 VertexAI 的 API 金鑰 | `xxxxxxx` || |
251+
| **gemini.model** | 模型名稱(參見 [Gemini 模型][61]| `gemini-2.0-flash` || |
252+
| **gemini.backend** | Gemini 後端:`BackendGeminiAPI`(預設,適用於 Gemini API)或 `BackendVertexAI`(VertexAI) | `BackendGeminiAPI` || `BackendGeminiAPI` |
253+
| **gemini.project** | VertexAI 專案 ID(如使用 `BackendVertexAI` 必填) | `my-gcp-project` | 條件必填 | |
254+
| **gemini.location** | VertexAI 區域(如使用 `BackendVertexAI` 必填) | `us-central1` | 條件必填 | |
255+
256+
#### 範例:Gemini API(預設後端)
238257

239258
```sh
240259
codegpt config set openai.provider gemini
241-
codegpt config set openai.api_key xxxxxxx
260+
codegpt config set gemini.api_key xxxxxxx
242261
codegpt config set openai.model gemini-2.0-flash
262+
# gemini.backend 預設為 BackendGeminiAPI,可省略
243263
```
244264

245-
```mermaid
246-
sequenceDiagram
247-
participant User
248-
participant GeminiClient as Gemini Provider
249-
participant GenAI as Google GenAI API
250-
251-
User->>GeminiClient: Completion(ctx, content)
252-
GeminiClient->>GenAI: GenerateContent(model, content, config)
253-
GenAI-->>GeminiClient: Response (text, usage metadata)
254-
GeminiClient-->>User: core.Response (text, usage)
265+
#### 範例:VertexAI Gemini
255266

256-
User->>GeminiClient: GetSummaryPrefix(ctx, content)
257-
GeminiClient->>GenAI: GenerateContent(model, content, config with function call)
258-
GenAI-->>GeminiClient: Response (function call result)
259-
GeminiClient-->>User: core.Response (prefix or error)
267+
```sh
268+
codegpt config set openai.provider gemini
269+
codegpt config set openai.model gemini-1.5-pro-preview-0409
270+
codegpt config set gemini.backend BackendVertexAI
271+
codegpt config set gemini.project my-gcp-project
272+
codegpt config set gemini.location us-central1
260273
```
261274

262275
[60]: https://ai.google.dev/gemini-api
263276
[61]: https://ai.google.dev/gemini-api/docs
264277
[62]: https://aistudio.google.com/app/apikey
278+
[63]: https://cloud.google.com/vertex-ai/docs/generative-ai/learn/overview
279+
[64]: https://console.cloud.google.com/apis/credentials
280+
281+
```mermaid
282+
flowchart TD
283+
User([使用者])
284+
subgraph CodeGPT
285+
GeminiClient([Gemini 提供者])
286+
end
287+
subgraph Google
288+
GeminiAPI([Gemini API])
289+
VertexAI([VertexAI Gemini])
290+
end
291+
292+
User -->|Completion / GetSummaryPrefix| GeminiClient
293+
294+
GeminiClient -- BackendGeminiAPI --> GeminiAPI
295+
GeminiAPI -- Response (text, usage) --> GeminiClient
296+
297+
GeminiClient -- BackendVertexAI --> VertexAI
298+
VertexAI -- Response (text, usage) --> GeminiClient
299+
300+
GeminiClient --> User
301+
```
265302

266303
### 支援 [Anthropic][100] API 服務
267304

0 commit comments

Comments
 (0)