|
| 1 | +<div align="center"> |
| 2 | + <h1>DDG2API</h1> |
| 3 | + <p style="font-size: 16px"> |
| 4 | + <b>DuckDuckGo AI to API</b> |
| 5 | + <br> |
| 6 | + Chatting with DuckDuckGo AI through API,Free to use gpt-4o-mini, |
| 7 | + <br> |
| 8 | + claude-3-haiku, llama-3.1-70b, mixtral-8x7b, etc. |
| 9 | + <br> |
| 10 | + Supports continuous dialogue, compatible with OpenAI API format. |
| 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;"/></a> |
| 14 | + <span> </span> |
| 15 | + <a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmeethuhu%2FDDG2API"> |
| 16 | + <img src="https://vercel.com/button" style="height: 30px;"/></a> |
| 17 | + <br><br> |
| 18 | + |
| 19 | + [中文](./doc/README_zh.md) | [English](./README_en.md) |
| 20 | +</div> |
| 21 | + |
| 22 | + |
| 23 | +## Supported Interfaces |
| 24 | + |
| 25 | +- `GET - /v1/models` |
| 26 | + |
| 27 | +- `POST - /v1/chat/completions` |
| 28 | + |
| 29 | +## Available models |
| 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 | +## Environment variables |
| 37 | + |
| 38 | +| Name | Option | Description | |
| 39 | +| ---------- | -------- | ------------------------------------------------ | |
| 40 | +| `PORT` | Optional | Request port, default is 3000 | |
| 41 | +| `API_KEYS` | Optional | API key group, separate multiple values with `,` | |
| 42 | + |
| 43 | + |
| 44 | + |
| 45 | +## Deployment |
| 46 | + |
| 47 | +- ### CloudFlare |
| 48 | + |
| 49 | + <a href="https://deploy.workers.cloudflare.com/?url=https://github.com/meethuhu/ddg2api/actions/workflows/workers-deploy.yml"> |
| 50 | + <img src="https://deploy.workers.cloudflare.com/button" style="height: 30px;"/></a> |
| 51 | + |
| 52 | + *suggest manually setting `API_KEYS` |
| 53 | + *To deploy manually, go to the `cf` branch |
| 54 | + |
| 55 | +- ### Vercel |
| 56 | + |
| 57 | + <a href="https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fmeethuhu%2FDDG2API"> |
| 58 | + <img src="https://vercel.com/button" style="height: 30px;"/></a> |
| 59 | + |
| 60 | + *suggest manually setting `API_KEYS` |
| 61 | + |
| 62 | +- ### Docker |
| 63 | + |
| 64 | + ```shell |
| 65 | + docker run -d \ |
| 66 | + --name ddg2api \ |
| 67 | + -p 3000:3000 \ |
| 68 | + -e API_KEYS=your_api_key1,your_api_key2 \ |
| 69 | + -e TZ=Asia/Shanghai \ |
| 70 | + --restart always \ |
| 71 | + ghcr.io/meethuhu/ddg2api:main |
| 72 | + ``` |
| 73 | + |
| 74 | +- ### Docker Compose |
| 75 | + |
| 76 | + ```docker-compose |
| 77 | + services: |
| 78 | + ddg2api: |
| 79 | + image: ghcr.io/meethuhu/ddg2api:latest |
| 80 | + container_name: ddg2api |
| 81 | + ports: |
| 82 | + - '3000:3000' |
| 83 | + environment: |
| 84 | + - API_KEYS=your_api_key1,your_api_key2 |
| 85 | + - TZ=Asia/Shanghai |
| 86 | + restart: always |
| 87 | + ``` |
| 88 | + |
| 89 | +- ### Nodejs |
| 90 | + |
| 91 | + ```shell |
| 92 | + git clone https://github.com/meethuhu/DDG2API.git |
| 93 | + |
| 94 | + cd DDG2API |
| 95 | + |
| 96 | + npm install |
| 97 | + |
| 98 | + node index.js |
| 99 | + ``` |
| 100 | + |
| 101 | +## Usage example |
| 102 | +```shell |
| 103 | +# Get model list |
| 104 | +curl http://localhost:3000/v1/models \ |
| 105 | + -H "Authorization: Bearer your_api_key" |
| 106 | +``` |
| 107 | + |
| 108 | +```shell |
| 109 | +# Send chat request |
| 110 | +curl http://localhost:3000/v1/chat/completions \ |
| 111 | + -H "Authorization: Bearer your_api_key" \ |
| 112 | + -H "Content-Type: application/json" \ |
| 113 | + -d '{ |
| 114 | + "model": "gpt-4o-mini", |
| 115 | + "messages": [{"role": "user", "content": "你好"}], |
| 116 | + "stream": false |
| 117 | + }' |
| 118 | +``` |
| 119 | + |
| 120 | +### Notes |
| 121 | + |
| 122 | +1. This project is for learning and research purposes only |
| 123 | +2. Please comply with DuckDuckGo's terms of use |
| 124 | +3. Recommended for use in local or private environments |
| 125 | +4. Please keep your keys secure |
| 126 | + |
| 127 | +### Open Source License |
| 128 | + |
| 129 | +MIT License |
| 130 | + |
| 131 | +### Contributing |
| 132 | + |
| 133 | +Welcome to submit Issues and Pull Requests! |
0 commit comments