Skip to content

Commit 581638b

Browse files
committed
Update docs
1 parent 51bc727 commit 581638b

File tree

4 files changed

+92
-52
lines changed

4 files changed

+92
-52
lines changed

README.md

Lines changed: 12 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@ OpenAI-compatible RESTful APIs for Amazon Bedrock
66

77
## Breaking Changes
88

9-
This tool can now automatically detect new models supported in Amazon Bedrock.
9+
This solution can now **automatically detect** new models supported in Amazon Bedrock.
1010
So whenever new models are added to Amazon Bedrock, you can immediately try them without the need to wait for code changes to this repo.
1111

1212
This is to use the `ListFoundationModels` api and the `ListInferenceProfiles` api by Amazon Bedrock, due to this change, additional IAM permissions are required to your Lambda/Fargate role.
1313

1414
If you are facing error: 'Unsupported model xxx, please use models API to get a list of supported models' even the model ID is correct,
15-
please either update your existing stack with the new template in the deployment folder or manually add below permissions to the related Lambda/Fargate role.
15+
please either update your existing stack (**Recommended**) with the new template in the deployment folder or manually add below permissions to the related Lambda/Fargate role.
1616

1717
```json
1818
{
@@ -48,19 +48,7 @@ If you find this GitHub repository useful, please consider giving it a free star
4848

4949
Please check [Usage Guide](./docs/Usage.md) for more details about how to use the new APIs.
5050

51-
> **Note:** The legacy [text completion](https://platform.openai.com/docs/api-reference/completions) API is not supported, you should change to use chat completion API.
52-
53-
Supported Amazon Bedrock models family:
54-
55-
- Anthropic Claude 2 / 3 (Haiku/Sonnet/Opus) / 3.5 Sonnet
56-
- Meta Llama 2 / 3
57-
- Mistral / Mixtral
58-
- Cohere Command R / R+
59-
- Cohere Embedding
60-
61-
You can call the `models` API to get the full list of model IDs supported.
62-
63-
> **Note:** The default model is set to `anthropic.claude-3-sonnet-20240229-v1:0` which can be changed via Lambda environment variables (`DEFAULT_MODEL`).
51+
> **Note:** The default model is set to `anthropic.claude-3-sonnet-20240229-v1:0` which can be changed via Lambda environment variables (`DEFAULT_MODEL`). You can call the [Models API](./docs/Usage.md#models-api) to get the full list of model IDs supported.
6452
6553
## Get Started
6654

@@ -224,20 +212,14 @@ Short answer is that API Gateway does not support server-sent events (SSE) for s
224212

225213
### Which regions are supported?
226214

227-
This solution only supports the regions where Amazon Bedrock is available, as for now, below are the list.
228-
229-
- US East (N. Virginia): us-east-1
230-
- US West (Oregon): us-west-2
231-
- Asia Pacific (Singapore): ap-southeast-1
232-
- Asia Pacific (Sydney): ap-southeast-2
233-
- Asia Pacific (Tokyo): ap-northeast-1
234-
- Europe (Frankfurt): eu-central-1
235-
- Europe (Paris): eu-west-3
236-
237215
Generally speaking, all regions that Amazon Bedrock supports will also be supported, if not, please raise an issue in Github.
238216

239217
Note that not all models are available in those regions.
240218

219+
### Which models are supported?
220+
221+
You can use the [Models API](./docs/Usage.md#models-api) to get/refresh a list of supported models in the current region.
222+
241223
### Can I build and use my own ECR image
242224

243225
Yes, you can clone the repo and build the container image by yourself (`src/Dockerfile`) and then push to your ECR repo. You can use `scripts/push-to-ecr.sh`
@@ -246,7 +228,11 @@ Replace the repo url in the CloudFormation template before you deploy.
246228

247229
### Can I run this locally
248230

249-
Yes, you can run this locally.
231+
Yes, you can run this locally, e.g. run below command under `src` folder:
232+
233+
```bash
234+
uvicorn api.app:app --host 0.0.0.0 --port 8000
235+
```
250236

251237
The API base url should look like `http://localhost:8000/api/v1`.
252238

README_CN.md

Lines changed: 14 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66

77
## 重大变更
88

9-
这个方案现在可以自动检测 Amazon Bedrock 中支持的新模型。
9+
这个方案现在可以**自动检测** Amazon Bedrock 中支持的新模型。
1010
因此,当 Amazon Bedrock 添加新模型时,您可以立即尝试使用它们,无需等待此代码库的更新。
1111

1212
这是通过使用Amazon Bedrock 的 `ListFoundationModels API``ListInferenceProfiles` API 实现的。由于这一变更,您需要为 Lambda/Fargate 角色添加额外的 IAM 权限。
1313

1414
如果您遇到错误:"Unsupported model xxx, please use models API to get a list of supported models"(即使Model ID 是正确的),
15-
请使用Deployment 文件夹中的新模板更新您现有的堆栈,或手动为相关的 Lambda/Fargate 角色添加以下权限。
15+
请使用Deployment 文件夹中的新模板更新您现有的堆栈(**推荐**,或手动为相关的 Lambda/Fargate 角色添加以下权限。
1616

1717
```json
1818
{
@@ -50,19 +50,7 @@ OpenAI 的 API 或 SDK 无缝集成并试用 Amazon Bedrock 的模型,而无需
5050

5151
请查看[使用指南](./docs/Usage_CN.md)以获取有关如何使用新API的更多详细信息。
5252

53-
> 注意: 不支持旧的 [text completion](https://platform.openai.com/docs/api-reference/completions) API,请更改为使用Chat Completion API。
54-
55-
支持的Amazon Bedrock模型家族:
56-
57-
- Anthropic Claude 2 / 3 (Haiku/Sonnet/Opus) / 3.5 Sonnet
58-
- Meta Llama 2 / 3
59-
- Mistral / Mixtral
60-
- Cohere Command R / R+
61-
- Cohere Embedding
62-
63-
你可以先调用`models` API 获取支持的详细 model ID 列表。
64-
65-
> 注意: 默认模型为 `anthropic.claude-3-sonnet-20240229-v1:0`, 可以通过更改Lambda环境变量进行更改。
53+
> 注意: 默认模型为 `anthropic.claude-3-sonnet-20240229-v1:0`, 可以通过更改Lambda环境变量进行更改。你可以先调用 [Models API](./docs/Usage.md#models-api) 查看支持的详细 model ID 列表。
6654
6755
## 使用指南
6856

@@ -223,20 +211,14 @@ print(response)
223211

224212
### 支持哪些区域?
225213

226-
只支持Amazon Bedrock可用的区域, 截至当前,包括以下区域:
227-
228-
- 美国东部(弗吉尼亚北部):us-east-1
229-
- 美国西部(俄勒冈州):us-west-2
230-
- 亚太地区(新加坡):ap-southeast-1
231-
- 亚太地区(悉尼):ap-southeast-2
232-
- 亚太地区(东京):ap-northeast-1
233-
- 欧洲(法兰克福):eu-central-1
234-
- 欧洲(巴黎):eu-west-3
235-
236214
通常来说,所有Amazon Bedrock支持的区域都支持,如果不支持,请提个Github Issue。
237215

238216
注意,并非所有模型都在上面区可用。
239217

218+
### 支持哪些模型?
219+
220+
你可以通过[Model API](./docs/Usage_CN.md#models-api) 获取(或更新)当前区支持的模型列表。
221+
240222
### 我可以构建并使用自己的ECR镜像吗?
241223

242224
是的,你可以克隆repo并自行构建容器镜像(src/Dockerfile),然后推送到你自己的ECR仓库。 脚本可以参考`scripts/push-to-ecr.sh`
@@ -245,7 +227,13 @@ print(response)
245227

246228
### 我可以在本地运行吗?
247229

248-
是的,你可以在本地运行,那么API Base URL应该类似于`http://localhost:8000/api/v1`
230+
是的,你可以在本地运行, 例如在`src` 文件夹下运行:
231+
232+
```bash
233+
uvicorn api.app:app --host 0.0.0.0 --port 8000
234+
```
235+
236+
那么API Base URL应该类似于`http://localhost:8000/api/v1`
249237

250238
### 使用代理API会有任何性能牺牲或延迟增加吗?
251239

docs/Usage.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,40 @@ export OPENAI_API_KEY=<API key>
99
export OPENAI_BASE_URL=<API base url>
1010
```
1111

12+
## Models API
13+
14+
You can use this API to get a list of supported model IDs.
15+
16+
Also, you can use this API to refresh the model list if new models are added to Amazon Bedrock.
17+
18+
19+
**Example Request**
20+
21+
```bash
22+
curl -s $OPENAI_BASE_URL/models -H "Authorization: Bearer $OPENAI_API_KEY" | jq .data
23+
```
24+
25+
**Example Response**
26+
27+
```bash
28+
[
29+
...
30+
{
31+
"id": "anthropic.claude-3-5-sonnet-20240620-v1:0",
32+
"created": 1734416893,
33+
"object": "model",
34+
"owned_by": "bedrock"
35+
},
36+
{
37+
"id": "us.anthropic.claude-3-5-sonnet-20240620-v1:0",
38+
"created": 1734416893,
39+
"object": "model",
40+
"owned_by": "bedrock"
41+
},
42+
...
43+
]
44+
```
45+
1246
## Embedding API
1347

1448
**Important Notice**: Please carefully review the following points before using this proxy API for embedding.

docs/Usage_CN.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,38 @@ export OPENAI_API_KEY=<API key>
99
export OPENAI_BASE_URL=<API base url>
1010
```
1111

12+
## Models API
13+
14+
你可以通过这个API 获取支持的models 列表。 另外,如果Amazon Bedrock有新模型加入后,你也可以用它来更新刷新模型列表。
15+
16+
**Request 示例**
17+
18+
```bash
19+
curl -s $OPENAI_BASE_URL/models -H "Authorization: Bearer $OPENAI_API_KEY" | jq .data
20+
```
21+
22+
**Response 示例**
23+
24+
```bash
25+
[
26+
...
27+
{
28+
"id": "anthropic.claude-3-5-sonnet-20240620-v1:0",
29+
"created": 1734416893,
30+
"object": "model",
31+
"owned_by": "bedrock"
32+
},
33+
{
34+
"id": "us.anthropic.claude-3-5-sonnet-20240620-v1:0",
35+
"created": 1734416893,
36+
"object": "model",
37+
"owned_by": "bedrock"
38+
},
39+
...
40+
]
41+
```
42+
43+
1244
## Embedding API
1345

1446
**重要**: 在使用此代理 API 之前,请仔细阅读以下几点:

0 commit comments

Comments
 (0)