13 releases

new 0.2.6 Dec 12, 2024
0.2.5 Dec 8, 2024
0.2.0 Nov 9, 2024
0.1.8 Nov 8, 2024
0.1.5 Oct 25, 2024

#1401 in Web programming

Download history 287/week @ 2024-10-16 102/week @ 2024-10-23 71/week @ 2024-10-30 362/week @ 2024-11-06 14/week @ 2024-11-13 10/week @ 2024-11-20 362/week @ 2024-12-04

396 downloads per month

MIT license

70KB
1.5K SLoC

duckai

Crates.io License crates.io Crates.io Total Downloads

🚀 Support my journey to full-time open-source development by sponsoring me on GitHub

DuckDuckGo AI to OpenAI API

  • API authentication
  • Support IP proxy pool
  • Built-in Http connection pool
  • Streaming/non-streaming API

Model

Model mapping, unsupported models default to gpt-4o-mini

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

Chat

curl --request POST 'http://127.0.0.1:8080/v1/chat/completions' \
  --header 'Content-Type: application/json' \
  --data '{
    "messages": [
      {
        "role": "user",
        "content": "Rust example."
      }
    ],
    "model": "gpt-4o-mini",
    "stream": true
  }'

Command

$ duckai -h
DuckDuckGo AI to OpenAI

Usage: duckai
       duckai <COMMAND>

Commands:
  run      Run server
  start    Start server daemon
  restart  Restart server daemon
  stop     Stop server daemon
  log      Show the server daemon log
  ps       Show the server daemon process
  gt       Generate config template file (yaml format file)
  help     Print this message or the help of the given subcommand(s)

Options:
  -h, --help     Print help
  -V, --version  Print version

$ duckai run -h
Run server

Usage: duckai run [CONFIG_PATH]

Arguments:
  [CONFIG_PATH]  Configuration filepath [default: duckai.yaml]

Options:
  -h, --help  Print help

Install

If you need more detailed installation and usage information, please check here
  1. Install
  • cargo
cargo install duckai
  • Dokcer
docker run --rm -it -p 8080:8080 ghcr.io/penumbra-x/duckai:latest run
  • Compile
# Required install docker
cargo install cross
cross build --target x86_64-unknown-linux-musl --release
cross build --target aarch64-unknown-linux-musl --release
  1. Generate config template file
duckai gt # Generate duckai.yaml file (current directory)
# Debug mode
debug: false

# Listen address
bind: 0.0.0.0:8080

# Client timeout
timeout: 60

# Client connect timeout
connect_timeout: 10

# Client tcp keepalive
tcp_keepalive: 90

# Maximum tcp connection
concurrent: 100

# Proxy pool
proxies:
- !url http://127.0.0.1:6152
- !url socks5://127.0.0.1:6153
- !cidr 2001:470:e953::/48
- !iface 192.168.1.10

# Enable TLS
tls_cert: null
tls_key: null

# API key
api_key: null
  1. Proxy pool

IP proxy pool type supports three types (priority: CIDR > Proxy > Interface, using round-robin strategy):

  • URL,protocol supports: http/https/socks4/socks5/socks5h
  • Interface,bind local network interface address
  • CIDR,support IPv4/IPv6 subnet, the premise is that the subnet routes are normally communicable

Contribution

If you want to submit contributions, please open Pull Request

Get help

Your questions may have been answered in issues

Dependencies

~46–79MB
~1.5M SLoC