Skip to main content

Python >= 3.9

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

Go To TOP

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)

Go To TOP

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"

Go To TOP

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.

Go To TOP

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)

Go To TOP

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.

Metadata

Release files for duckai 0.3.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for duckai 0.3.1
File
duckai-0.3.1-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details
duckai-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.13 CPython 3.13 Linux glibc 2.17+ x86-64 Details
duckai-0.3.1-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details
duckai-0.3.1-cp313-cp313-macosx_10_13_x86_64.whl CPython 3.13 CPython 3.13 macOS 10.13+ x86-64 Details
duckai-0.3.1-cp312-cp312-win_amd64.whl CPython 3.12 CPython 3.12 Windows x86-64 Details
duckai-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.12 CPython 3.12 Linux glibc 2.17+ x86-64 Details
duckai-0.3.1-cp312-cp312-macosx_11_0_arm64.whl CPython 3.12 CPython 3.12 macOS 11.0+ ARM64 Details
duckai-0.3.1-cp312-cp312-macosx_10_13_x86_64.whl CPython 3.12 CPython 3.12 macOS 10.13+ x86-64 Details
duckai-0.3.1-cp311-cp311-win_amd64.whl CPython 3.11 CPython 3.11 Windows x86-64 Details
duckai-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.11 CPython 3.11 Linux glibc 2.17+ x86-64 Details
duckai-0.3.1-cp311-cp311-macosx_11_0_arm64.whl CPython 3.11 CPython 3.11 macOS 11.0+ ARM64 Details
duckai-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl CPython 3.11 CPython 3.11 macOS 10.9+ x86-64 Details
duckai-0.3.1-cp310-cp310-win_amd64.whl CPython 3.10 CPython 3.10 Windows x86-64 Details
duckai-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 CPython 3.10 Linux glibc 2.17+ x86-64 Details
duckai-0.3.1-cp310-cp310-macosx_11_0_arm64.whl CPython 3.10 CPython 3.10 macOS 11.0+ ARM64 Details
duckai-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl CPython 3.10 CPython 3.10 macOS 10.9+ x86-64 Details
duckai-0.3.1-cp39-cp39-win_amd64.whl CPython 3.9 CPython 3.9 Windows x86-64 Details
duckai-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.9 CPython 3.9 Linux glibc 2.17+ x86-64 Details
duckai-0.3.1-cp39-cp39-macosx_11_0_arm64.whl CPython 3.9 CPython 3.9 macOS 11.0+ ARM64 Details
duckai-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl CPython 3.9 CPython 3.9 macOS 10.9+ x86-64 Details

Total release size: 1.3 MB

Release files / duckai-0.3.1-cp313-cp313-win_amd64.whl

Download URL duckai-0.3.1-cp313-cp313-win_amd64.whl
Size 48.8 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
2dabd9768c388abc840b4d502ba9fc2d029e2b12e9adf23bef89247d9a8a6e3a
BLAKE2b-256 checksum
How to use checksums
68610dc6471a140170f796967a1128abb7c350927b09c78d62743790e3d33c26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL duckai-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 82.9 kB
Tags CPython 3.13 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
bf71468538c7405cbb2708183ab6a71b19c7e53c08b93d72f0781f6ae838d071
BLAKE2b-256 checksum
How to use checksums
9068d9ebeb87e8f48172e633ec142157e147dfcbc9e2d7abc7e45caad799eb12
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp313-cp313-macosx_11_0_arm64.whl

Download URL duckai-0.3.1-cp313-cp313-macosx_11_0_arm64.whl
Size 62.8 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
c30c00ef1b2896d7f51712c31ab0e8a553820a92e5a3b477fe19e3e818d1d768
BLAKE2b-256 checksum
How to use checksums
2f4095fef94c9acbf21172f37e0130b5e52f8a8145c66c12a8279e4ab6033b98
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp313-cp313-macosx_10_13_x86_64.whl

Download URL duckai-0.3.1-cp313-cp313-macosx_10_13_x86_64.whl
Size 66.5 kB
Tags CPython 3.13 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
ed2f0a890ddc56d57cb7384299fab4d8a5e7bdd11aa6888e0f7c1a63a34c27de
BLAKE2b-256 checksum
How to use checksums
f0e30f1debaef8f3306eb6a07af00ec57d933383cef16d0f81de020732706c5f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp312-cp312-win_amd64.whl

Download URL duckai-0.3.1-cp312-cp312-win_amd64.whl
Size 49.0 kB
Tags CPython 3.12 Windows x86-64
SHA-256 checksum
How to use checksums
ea182182d231abc9363eedac228c34aa8bbe4c301d069b4fd451e1a0064487d5
BLAKE2b-256 checksum
How to use checksums
a0a8e9c30337e680ec1e2aae4fd54a6a8bde38f4b44bcd3c989f69c91bc712cf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL duckai-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 83.2 kB
Tags CPython 3.12 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
c68a869a4a7a5cc8f9bd42d02cbe8437332215f76c79e0d879d9311adb4781a9
BLAKE2b-256 checksum
How to use checksums
3895a45b757702bbbf1c77a63f1d6b70d02d895deea7677d35ea8d6ed265a389
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp312-cp312-macosx_11_0_arm64.whl

Download URL duckai-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
Size 62.9 kB
Tags CPython 3.12 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
0efd150c27256df3330bff65bf493fae1dd119ce9c1f433eba671968cd759784
BLAKE2b-256 checksum
How to use checksums
de5a73251f7ab64ed688aba2cfbe9c29b9c166aeaafe1671c0be6a6f0bd2cf89
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp312-cp312-macosx_10_13_x86_64.whl

Download URL duckai-0.3.1-cp312-cp312-macosx_10_13_x86_64.whl
Size 66.6 kB
Tags CPython 3.12 macOS 10.13+ x86-64
SHA-256 checksum
How to use checksums
939e9296d72ac80a127d3614b3228a6682769105cda3b4295e279c2a00177b33
BLAKE2b-256 checksum
How to use checksums
cc4f9b157ad06f64a6a3590f96c5058242f5eb16f2b11e47912e48ed4889168c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp311-cp311-win_amd64.whl

Download URL duckai-0.3.1-cp311-cp311-win_amd64.whl
Size 48.6 kB
Tags CPython 3.11 Windows x86-64
SHA-256 checksum
How to use checksums
efd7db0a814cc0ed0ad16dd125d94df70ce207cb105efde387c0a97c79b59cd5
BLAKE2b-256 checksum
How to use checksums
39bed02f53cfb83e478a1ac8369e24fb73d8bb4b532b176c37fb501701e7f971
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL duckai-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 82.2 kB
Tags CPython 3.11 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
3195cc6889e2afd332e266fefda688e9305d7a3e867820b668d96149c50b054f
BLAKE2b-256 checksum
How to use checksums
f5e5b70bd51ba8e7283c13be6ea98692253f81c71007de171b874b7c96b95a30
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp311-cp311-macosx_11_0_arm64.whl

Download URL duckai-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
Size 62.8 kB
Tags CPython 3.11 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
93333de3b36b3e3a7efc4f190878c40fd8f47d9876ed318cd4e6773339f00e18
BLAKE2b-256 checksum
How to use checksums
06650f11029d81fd94f45605aa765cf8d2c14fad74b8808b004071fc82853cca
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl

Download URL duckai-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl
Size 65.9 kB
Tags CPython 3.11 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
3c94106ae2bf19048d29f147197d7d02f6427867c5a38a4b2013e5f89bc34f65
BLAKE2b-256 checksum
How to use checksums
102d704cb8a0acb49b7ed58547242deb18b02b99d019e4f019a0c0becd950a41
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp310-cp310-win_amd64.whl

Download URL duckai-0.3.1-cp310-cp310-win_amd64.whl
Size 49.0 kB
Tags CPython 3.10 Windows x86-64
SHA-256 checksum
How to use checksums
93f5b16c7f7c479de417163d6715b4f57d4c2622f8a6906d13a778dfcabeccb6
BLAKE2b-256 checksum
How to use checksums
373bc7fce8774557a3c087fbcf9a9ea3a7da32cf1e1ea4ff6b3a7e57a725dbc0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL duckai-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 84.0 kB
Tags CPython 3.10 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
2b6e1f1c2d2ab435cd3caa70dacbef467c74fbdc86b58db82647fcaf3a34adc9
BLAKE2b-256 checksum
How to use checksums
632907c4a58672e47f228f606a50b257b1c3f6e57d216c9ddfcaeac9ac8dff57
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp310-cp310-macosx_11_0_arm64.whl

Download URL duckai-0.3.1-cp310-cp310-macosx_11_0_arm64.whl
Size 64.1 kB
Tags CPython 3.10 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
9254a5bc735578d3076165af0f1786331ceffee79ead74004b5c4d3f11ce5bc6
BLAKE2b-256 checksum
How to use checksums
bce4c5aefdb75ebdcb8e28faeba5442cc25ca2e0394b3227d3fb4b55789e91f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl

Download URL duckai-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl
Size 67.3 kB
Tags CPython 3.10 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
abd40623e7f67cb6633beae50a520297ec6f0980af48934eae08c455734eb9b7
BLAKE2b-256 checksum
How to use checksums
85c0a872cd01a68a6134f0511f62559da4fd7e841b87b4018fb5b2c0420f5b13
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp39-cp39-win_amd64.whl

Download URL duckai-0.3.1-cp39-cp39-win_amd64.whl
Size 48.9 kB
Tags CPython 3.9 Windows x86-64
SHA-256 checksum
How to use checksums
c4a4d6c66777ba720a3c7fa97c985000ac518064058e479d82609d46962bcf22
BLAKE2b-256 checksum
How to use checksums
c1dd708504cf3c420e26a2376f5a1eaef171e3d043d051d6a19734b118529e74
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL duckai-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 83.8 kB
Tags CPython 3.9 Linux glibc 2.17+ x86-64
SHA-256 checksum
How to use checksums
84f8fb817ecf87c1390cfde96aa853ba95a23a37e4290b4103c248bfdd6a835f
BLAKE2b-256 checksum
How to use checksums
193fdda3818a9e5b0d1ca11c6310478f80ec8dc2b779aec95fbde624ca8ef3a9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp39-cp39-macosx_11_0_arm64.whl

Download URL duckai-0.3.1-cp39-cp39-macosx_11_0_arm64.whl
Size 64.1 kB
Tags CPython 3.9 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d13b68a88714feabeb133368ee8251638049b98d89b61cb098f1d47f3ea6d69a
BLAKE2b-256 checksum
How to use checksums
fa43f39602d3fe434059726a8ec0ebd4d3e80b6ff8a05fcba07253fa22471a60
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release files / duckai-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl

Download URL duckai-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
Size 67.3 kB
Tags CPython 3.9 macOS 10.9+ x86-64
SHA-256 checksum
How to use checksums
f2da9c9e60dcf0995e584e376a07844456dd184016bc71994e3ec921ae7e8466
BLAKE2b-256 checksum
How to use checksums
8bdcaabcbee0af2db0b2bfa9cff3de2c5f130e364d37eed56e4ec8ea9f840e8a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.12.3

Release history Release notifications | RSS feed

This release

0.3.1 This release

20 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page