Skip to content
This repository was archived by the owner on Feb 25, 2025. It is now read-only.

Commit 9141d05

Browse files
committed
Initial commit
1 parent 5a8157f commit 9141d05

File tree

2 files changed

+132
-0
lines changed

2 files changed

+132
-0
lines changed

README.md.lnk

-768 Bytes
Binary file not shown.

doc/README_zh.md

Lines changed: 132 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
<div align="center">
2+
<h1>DDG2API</h1>
3+
<p style="font-size: 16px">
4+
<b>DuckDuckGo AI To API</b>
5+
<br>
6+
通过 API 与 DuckDuckGo AI 对话,免费使用 gpt-4o-mini、
7+
<br>
8+
claude-3-haiku、llama-3.1-70b、mixtral-8x7b 等模型。
9+
<br>
10+
支持连续对话,兼容 OpenAI API 格式。
11+
</p>
12+
<a href="https://deploy.workers.cloudflare.com/?url=https://github.com/meethuhu/ddg2api/actions/workflows/workers-deploy.yml">
13+
<img src="https://deploy.workers.cloudflare.com/button" style="height: 30px;" />
14+
</a>
15+
<span>&nbsp;</span>
16+
<a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmeethuhu%2FDDG2API">
17+
<img src="https://vercel.com/button" style="height: 30px;" />
18+
</a>
19+
<br><br>
20+
21+
[中文](./doc/README_zh.md) | [English](./README_en.md)
22+
</div>
23+
24+
## 支持的接口
25+
26+
- `GET - /v1/models` - 获取可用模型列表
27+
- `POST - /v1/chat/completions` - 发送对话请求
28+
29+
## 可用模型
30+
31+
- `gpt-4o-mini`
32+
- `claude-3-haiku-20240307`
33+
- `meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo`
34+
- `mistralai/Mixtral-8x7B-Instruct-v0.1`
35+
36+
## 环境变量
37+
38+
| 名称 | 是否必需 | 描述 |
39+
| ---------- | -------- | ------------------------------ |
40+
| `PORT` | 可选 | 服务端口,默认为 3000 |
41+
| `API_KEYS` | 可选 | API密钥组,多个值用逗号(,)分隔 |
42+
43+
## 部署方式
44+
45+
- ### CloudFlare 部署
46+
47+
<a href="https://deploy.workers.cloudflare.com/?url=https://github.com/meethuhu/ddg2api/actions/workflows/workers-deploy.yml">
48+
<img src="https://deploy.workers.cloudflare.com/button" style="height: 30px;" /></a>
49+
50+
*建议手动设置 `API_KEYS`
51+
*需要手动部署请前往 `cf` 分支
52+
53+
- ### Vercel 部署
54+
55+
<a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmeethuhu%2FDDG2API">
56+
<img src="https://vercel.com/button" style="height: 30px;" /></a>
57+
58+
*建议手动设置 `API_KEYS`
59+
60+
- ### Docker 部署
61+
62+
```shell
63+
docker run -d \
64+
--name ddg2api \
65+
-p 3000:3000 \
66+
-e API_KEYS=your_api_key1,your_api_key2 \
67+
-e TZ=Asia/Shanghai \
68+
--restart always \
69+
ghcr.io/meethuhu/ddg2api:main
70+
```
71+
72+
- ### Docker Compose 部署
73+
74+
```docker-compose
75+
services:
76+
ddg2api:
77+
image: ghcr.io/meethuhu/ddg2api:latest
78+
container_name: ddg2api
79+
ports:
80+
- '3000:3000'
81+
environment:
82+
- API_KEYS=your_api_key1,your_api_key2
83+
- TZ=Asia/Shanghai
84+
restart: always
85+
```
86+
87+
- ### Node.js 部署
88+
89+
```shell
90+
git clone https://github.com/meethuhu/DDG2API.git
91+
92+
cd DDG2API
93+
94+
npm install
95+
96+
node index.js
97+
```
98+
99+
## 使用示例
100+
101+
```shell
102+
# 获取模型列表
103+
curl http://localhost:3000/v1/models \
104+
-H "Authorization: Bearer your_api_key"
105+
```
106+
107+
```shell
108+
# 发送对话请求
109+
curl http://localhost:3000/v1/chat/completions \
110+
-H "Authorization: Bearer your_api_key" \
111+
-H "Content-Type: application/json" \
112+
-d '{
113+
"model": "gpt-4o-mini",
114+
"messages": [{"role": "user", "content": "你好"}],
115+
"stream": false
116+
}'
117+
```
118+
119+
### 注意事项
120+
121+
1. 本项目仅供学习和研究使用
122+
2. 请遵守 DuckDuckGo 的使用条款
123+
3. 建议在本地或私有环境中使用
124+
4. 请妥善保管你的密钥
125+
126+
### 开源协议
127+
128+
MIT License
129+
130+
### 贡献
131+
132+
欢迎提交 Issues 和 Pull Requests!

0 commit comments

Comments
 (0)