AI chat using the DuckDuckGo.com search engine
Project description
duckai
AI chat using the DuckDuckGo.com search engine.
‼️ Chat ratelimit: 1 request per 15 seconds
Supported OS:
🐧 Linux: amd64
🪟 Windows: amd64
🍏 macOS: amd64, arm64
Table of Contents
Install
pip install -U duckai
CLI version
duckai --help
CLI examples:
duckai chat
DuckAI class
The DuckAI classes is used to retrieve chat results from DuckDuckGo.com.
class DuckAI:
"""duckai class to get search results from duckduckgo.com
Args:
proxy (str, optional): proxy for the HTTP client, supports http/https/socks5 protocols.
example: "http://user:pass@example.com:3128". Defaults to None.
timeout (int, optional): Timeout value for the HTTP client. Defaults to 10.
verify (bool): SSL verification when making the request. Defaults to True.
"""
Here is an example of initializing the DuckAI class.
from duckai import DuckAI
results = DuckAI().chat("python programming")
print(results)
Proxy
Package supports http/https/socks proxies. Example: http://user:pass@example.com:3128.
Use a rotating proxy. Otherwise, use a new proxy with each DuckAI class initialization.
1. The easiest way. Launch the Tor Browser
duckai = DuckAI(proxy="tb", timeout=20) # "tb" is an alias for "socks5://127.0.0.1:9150"
results = duckai.chat("something you need", model="mistral-small-3")
2. Use any proxy server (example with iproyal rotating residential proxies)
duckai = DuckAI(proxy="socks5h://user:password@geo.iproyal.com:32325", timeout=20)
results = duckai.chat("something you need", model="mistral-small-3")
3. The proxy can also be set using the DUCKAI_PROXY environment variable.
export DUCKAI_PROXY="socks5h://user:password@geo.iproyal.com:32325"
Exceptions
from duckai.exceptions import (
ConversationLimitException,
DuckAIException,
RatelimitException,
TimeoutException,
)
Exceptions:
DuckAIException: Base exception for duckai errors.RatelimitException: Inherits from DuckAIException, raised for exceeding API request rate limits.TimeoutException: Inherits from DuckAIException, raised for API request timeouts.ConversationLimitException: Inherits from DuckAIException, raised for conversation limit during API requests to AI endpoint.
1. chat() - AI chat
def chat(self, keywords: str, model: str = "gpt-4o-mini", timeout: int = 30) -> str:
"""Initiates a chat session with DuckDuckGo AI.
Args:
keywords (str): The initial message or question to send to the AI.
model (str): The model to use: "gpt-4o-mini", "llama-3.3-70b", "claude-3-haiku",
"o3-mini", "mistral-small-3". Defaults to "gpt-4o-mini".
timeout (int): Timeout value for the HTTP client. Defaults to 30.
Returns:
str: The response from the AI.
"""
Example
results = DuckAI().chat("summarize Daniel Defoe's The Consolidator", model='claude-3-haiku')
# There is also `chat_yield` generator which yields chunks while a response is being processed:
for x in DuckAI().chat_yield("How Do Airplanes Fly", model='llama-3.3-70b'):
print(x)
Disclaimer
This library is not affiliated with DuckDuckGo and is for educational purposes only. It is not intended for commercial use or any purpose that violates DuckDuckGo's Terms of Service. By using this library, you acknowledge that you will not use it in a way that infringes on DuckDuckGo's terms. The official DuckDuckGo website can be found at https://duckduckgo.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file duckai-0.3.1-cp313-cp313-win_amd64.whl.
File metadata
- Download URL: duckai-0.3.1-cp313-cp313-win_amd64.whl
- Upload date:
- Size: 48.8 kB
- Tags: CPython 3.13, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2dabd9768c388abc840b4d502ba9fc2d029e2b12e9adf23bef89247d9a8a6e3a
|
|
| MD5 |
4d1de4849bb9563dbcda57a220e9a73f
|
|
| BLAKE2b-256 |
68610dc6471a140170f796967a1128abb7c350927b09c78d62743790e3d33c26
|
File details
Details for the file duckai-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 82.9 kB
- Tags: CPython 3.13, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
bf71468538c7405cbb2708183ab6a71b19c7e53c08b93d72f0781f6ae838d071
|
|
| MD5 |
731fe805322eab157f37bc4e7516b87b
|
|
| BLAKE2b-256 |
9068d9ebeb87e8f48172e633ec142157e147dfcbc9e2d7abc7e45caad799eb12
|
File details
Details for the file duckai-0.3.1-cp313-cp313-macosx_11_0_arm64.whl.
File metadata
- Download URL: duckai-0.3.1-cp313-cp313-macosx_11_0_arm64.whl
- Upload date:
- Size: 62.8 kB
- Tags: CPython 3.13, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c30c00ef1b2896d7f51712c31ab0e8a553820a92e5a3b477fe19e3e818d1d768
|
|
| MD5 |
fe34b847b3e89996c88015818e3422b7
|
|
| BLAKE2b-256 |
2f4095fef94c9acbf21172f37e0130b5e52f8a8145c66c12a8279e4ab6033b98
|
File details
Details for the file duckai-0.3.1-cp313-cp313-macosx_10_13_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp313-cp313-macosx_10_13_x86_64.whl
- Upload date:
- Size: 66.5 kB
- Tags: CPython 3.13, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed2f0a890ddc56d57cb7384299fab4d8a5e7bdd11aa6888e0f7c1a63a34c27de
|
|
| MD5 |
161aa7496fa802c1c11a4be8a9148a9b
|
|
| BLAKE2b-256 |
f0e30f1debaef8f3306eb6a07af00ec57d933383cef16d0f81de020732706c5f
|
File details
Details for the file duckai-0.3.1-cp312-cp312-win_amd64.whl.
File metadata
- Download URL: duckai-0.3.1-cp312-cp312-win_amd64.whl
- Upload date:
- Size: 49.0 kB
- Tags: CPython 3.12, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ea182182d231abc9363eedac228c34aa8bbe4c301d069b4fd451e1a0064487d5
|
|
| MD5 |
82dfe3e87d52ea9b365fb51efda96dd6
|
|
| BLAKE2b-256 |
a0a8e9c30337e680ec1e2aae4fd54a6a8bde38f4b44bcd3c989f69c91bc712cf
|
File details
Details for the file duckai-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 83.2 kB
- Tags: CPython 3.12, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c68a869a4a7a5cc8f9bd42d02cbe8437332215f76c79e0d879d9311adb4781a9
|
|
| MD5 |
3014d7f3a9f3b4139ace343b5315494d
|
|
| BLAKE2b-256 |
3895a45b757702bbbf1c77a63f1d6b70d02d895deea7677d35ea8d6ed265a389
|
File details
Details for the file duckai-0.3.1-cp312-cp312-macosx_11_0_arm64.whl.
File metadata
- Download URL: duckai-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
- Upload date:
- Size: 62.9 kB
- Tags: CPython 3.12, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0efd150c27256df3330bff65bf493fae1dd119ce9c1f433eba671968cd759784
|
|
| MD5 |
285d6ed74cf9e75862ab4824261a0aea
|
|
| BLAKE2b-256 |
de5a73251f7ab64ed688aba2cfbe9c29b9c166aeaafe1671c0be6a6f0bd2cf89
|
File details
Details for the file duckai-0.3.1-cp312-cp312-macosx_10_13_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp312-cp312-macosx_10_13_x86_64.whl
- Upload date:
- Size: 66.6 kB
- Tags: CPython 3.12, macOS 10.13+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
939e9296d72ac80a127d3614b3228a6682769105cda3b4295e279c2a00177b33
|
|
| MD5 |
f0b1ade7652dd9283fe380f787645eee
|
|
| BLAKE2b-256 |
cc4f9b157ad06f64a6a3590f96c5058242f5eb16f2b11e47912e48ed4889168c
|
File details
Details for the file duckai-0.3.1-cp311-cp311-win_amd64.whl.
File metadata
- Download URL: duckai-0.3.1-cp311-cp311-win_amd64.whl
- Upload date:
- Size: 48.6 kB
- Tags: CPython 3.11, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efd7db0a814cc0ed0ad16dd125d94df70ce207cb105efde387c0a97c79b59cd5
|
|
| MD5 |
8ad0e7624a09d94e43b66cb25ac99247
|
|
| BLAKE2b-256 |
39bed02f53cfb83e478a1ac8369e24fb73d8bb4b532b176c37fb501701e7f971
|
File details
Details for the file duckai-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 82.2 kB
- Tags: CPython 3.11, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3195cc6889e2afd332e266fefda688e9305d7a3e867820b668d96149c50b054f
|
|
| MD5 |
54f92a5356888f12749746db0448df80
|
|
| BLAKE2b-256 |
f5e5b70bd51ba8e7283c13be6ea98692253f81c71007de171b874b7c96b95a30
|
File details
Details for the file duckai-0.3.1-cp311-cp311-macosx_11_0_arm64.whl.
File metadata
- Download URL: duckai-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
- Upload date:
- Size: 62.8 kB
- Tags: CPython 3.11, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93333de3b36b3e3a7efc4f190878c40fd8f47d9876ed318cd4e6773339f00e18
|
|
| MD5 |
7f7b6530b6423dfa38ab88ca9953610a
|
|
| BLAKE2b-256 |
06650f11029d81fd94f45605aa765cf8d2c14fad74b8808b004071fc82853cca
|
File details
Details for the file duckai-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl
- Upload date:
- Size: 65.9 kB
- Tags: CPython 3.11, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3c94106ae2bf19048d29f147197d7d02f6427867c5a38a4b2013e5f89bc34f65
|
|
| MD5 |
80c6fd3e58dd013b5fefd68561e6d0e2
|
|
| BLAKE2b-256 |
102d704cb8a0acb49b7ed58547242deb18b02b99d019e4f019a0c0becd950a41
|
File details
Details for the file duckai-0.3.1-cp310-cp310-win_amd64.whl.
File metadata
- Download URL: duckai-0.3.1-cp310-cp310-win_amd64.whl
- Upload date:
- Size: 49.0 kB
- Tags: CPython 3.10, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93f5b16c7f7c479de417163d6715b4f57d4c2622f8a6906d13a778dfcabeccb6
|
|
| MD5 |
58cafd98fecc4fd4e344736a49c6dc59
|
|
| BLAKE2b-256 |
373bc7fce8774557a3c087fbcf9a9ea3a7da32cf1e1ea4ff6b3a7e57a725dbc0
|
File details
Details for the file duckai-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 84.0 kB
- Tags: CPython 3.10, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2b6e1f1c2d2ab435cd3caa70dacbef467c74fbdc86b58db82647fcaf3a34adc9
|
|
| MD5 |
2d7ef0bf7912618e16a97a09a96e37e0
|
|
| BLAKE2b-256 |
632907c4a58672e47f228f606a50b257b1c3f6e57d216c9ddfcaeac9ac8dff57
|
File details
Details for the file duckai-0.3.1-cp310-cp310-macosx_11_0_arm64.whl.
File metadata
- Download URL: duckai-0.3.1-cp310-cp310-macosx_11_0_arm64.whl
- Upload date:
- Size: 64.1 kB
- Tags: CPython 3.10, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9254a5bc735578d3076165af0f1786331ceffee79ead74004b5c4d3f11ce5bc6
|
|
| MD5 |
4c48e2a4bba0fdd30f7acfea11a3519d
|
|
| BLAKE2b-256 |
bce4c5aefdb75ebdcb8e28faeba5442cc25ca2e0394b3227d3fb4b55789e91f8
|
File details
Details for the file duckai-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl
- Upload date:
- Size: 67.3 kB
- Tags: CPython 3.10, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
abd40623e7f67cb6633beae50a520297ec6f0980af48934eae08c455734eb9b7
|
|
| MD5 |
56598da46ffd3e49b291e24eb474008e
|
|
| BLAKE2b-256 |
85c0a872cd01a68a6134f0511f62559da4fd7e841b87b4018fb5b2c0420f5b13
|
File details
Details for the file duckai-0.3.1-cp39-cp39-win_amd64.whl.
File metadata
- Download URL: duckai-0.3.1-cp39-cp39-win_amd64.whl
- Upload date:
- Size: 48.9 kB
- Tags: CPython 3.9, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4a4d6c66777ba720a3c7fa97c985000ac518064058e479d82609d46962bcf22
|
|
| MD5 |
999c43ed049d9970f4615d448a199afe
|
|
| BLAKE2b-256 |
c1dd708504cf3c420e26a2376f5a1eaef171e3d043d051d6a19734b118529e74
|
File details
Details for the file duckai-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 83.8 kB
- Tags: CPython 3.9, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
84f8fb817ecf87c1390cfde96aa853ba95a23a37e4290b4103c248bfdd6a835f
|
|
| MD5 |
202129680ba164e18a3b37cfbb2093a1
|
|
| BLAKE2b-256 |
193fdda3818a9e5b0d1ca11c6310478f80ec8dc2b779aec95fbde624ca8ef3a9
|
File details
Details for the file duckai-0.3.1-cp39-cp39-macosx_11_0_arm64.whl.
File metadata
- Download URL: duckai-0.3.1-cp39-cp39-macosx_11_0_arm64.whl
- Upload date:
- Size: 64.1 kB
- Tags: CPython 3.9, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d13b68a88714feabeb133368ee8251638049b98d89b61cb098f1d47f3ea6d69a
|
|
| MD5 |
e44a1d13c93404d6e1b39f8931a6a94f
|
|
| BLAKE2b-256 |
fa43f39602d3fe434059726a8ec0ebd4d3e80b6ff8a05fcba07253fa22471a60
|
File details
Details for the file duckai-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl.
File metadata
- Download URL: duckai-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
- Upload date:
- Size: 67.3 kB
- Tags: CPython 3.9, macOS 10.9+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
f2da9c9e60dcf0995e584e376a07844456dd184016bc71994e3ec921ae7e8466
|
|
| MD5 |
779be28391f32876afe61f2abd90d4ea
|
|
| BLAKE2b-256 |
8bdcaabcbee0af2db0b2bfa9cff3de2c5f130e364d37eed56e4ec8ea9f840e8a
|