Skip to content

DuckDuckGo AI to API. Chatting with DuckDuckGo AI through API,Free to use gpt-4o-mini, claude-3-haiku, llama-3.1-70b, mixtral-8x7b, etc. Supports continuous dialogue, compatible with OpenAI API format.

License

Notifications You must be signed in to change notification settings

meethuhu/DDG2API

Repository files navigation

DDG2API

DuckDuckGo AI to API
Chatting with DuckDuckGo AI through API,Free to use gpt-4o-mini,
claude-3-haiku, llama-3.1-70b, mixtral-8x7b, etc.
Supports continuous dialogue, compatible with OpenAI API format.

 

中文 | English

Supported Interfaces

  • GET - /v1/models

  • POST - /v1/chat/completions

Available models

  • gpt-4o-mini
  • claude-3-haiku-20240307
  • meta-llama/Meta-Llama-3.1-70B-Instruct-Turbo
  • mistralai/Mixtral-8x7B-Instruct-v0.1

Environment variables

Name Option Description
PORT Optional Request port, default is 3000
API_KEYS Optional API key group, separate multiple values with ,
PATH_PREFIX Optional The actual endpoint URL should be prefixed with PATH_PREFIX after configuration, example: /PATH_PREFIX/v1/chat/completions

Deployment

  • CloudFlare

    *suggest manually setting API_KEYS
    *To deploy manually, go to the cf branch

  • Vercel

    *suggest manually setting API_KEYS

  • Docker

    docker run -d \
      --name ddg2api \
      -p 3000:3000 \
      -e API_KEYS=your_api_key1,your_api_key2 \
      -e TZ=Asia/Shanghai \
      --restart always \
      ghcr.io/meethuhu/ddg2api:main
  • Docker Compose

    services:
      ddg2api:
        image: ghcr.io/meethuhu/ddg2api:latest
        container_name: ddg2api
        ports:
          - '3000:3000'
        environment:
          - API_KEYS=your_api_key1,your_api_key2
          - TZ=Asia/Shanghai
        restart: always
    
  • Nodejs

    git clone https://github.com/meethuhu/DDG2API.git
    
    cd DDG2API
    
    npm install
    
    node index.js

Usage example

# Get model list
curl http://localhost:3000/v1/models \
  -H "Authorization: Bearer your_api_key"
# Send chat request
curl http://localhost:3000/v1/chat/completions \
  -H "Authorization: Bearer your_api_key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-4o-mini",
    "messages": [{"role": "user", "content": "你好"}],
    "stream": false
  }'

Notes

  1. This project is for learning and research purposes only
  2. Please comply with DuckDuckGo's terms of use
  3. Recommended for use in local or private environments
  4. Please keep your keys secure

Open Source License

MIT License

Contributing

Welcome to submit Issues and Pull Requests!

About

DuckDuckGo AI to API. Chatting with DuckDuckGo AI through API,Free to use gpt-4o-mini, claude-3-haiku, llama-3.1-70b, mixtral-8x7b, etc. Supports continuous dialogue, compatible with OpenAI API format.

Topics

Resources

License

Stars

Watchers

Forks

Packages