Skip to main content

AI chat using the DuckDuckGo.com search engine

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

duckai-0.3.1-cp313-cp313-win_amd64.whl (48.8 kB view details)

Uploaded CPython 3.13Windows x86-64

duckai-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (82.9 kB view details)

Uploaded CPython 3.13manylinux: glibc 2.17+ x86-64

duckai-0.3.1-cp313-cp313-macosx_11_0_arm64.whl (62.8 kB view details)

Uploaded CPython 3.13macOS 11.0+ ARM64

duckai-0.3.1-cp313-cp313-macosx_10_13_x86_64.whl (66.5 kB view details)

Uploaded CPython 3.13macOS 10.13+ x86-64

duckai-0.3.1-cp312-cp312-win_amd64.whl (49.0 kB view details)

Uploaded CPython 3.12Windows x86-64

duckai-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (83.2 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64

duckai-0.3.1-cp312-cp312-macosx_11_0_arm64.whl (62.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

duckai-0.3.1-cp312-cp312-macosx_10_13_x86_64.whl (66.6 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

duckai-0.3.1-cp311-cp311-win_amd64.whl (48.6 kB view details)

Uploaded CPython 3.11Windows x86-64

duckai-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (82.2 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64

duckai-0.3.1-cp311-cp311-macosx_11_0_arm64.whl (62.8 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

duckai-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl (65.9 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

duckai-0.3.1-cp310-cp310-win_amd64.whl (49.0 kB view details)

Uploaded CPython 3.10Windows x86-64

duckai-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (84.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64

duckai-0.3.1-cp310-cp310-macosx_11_0_arm64.whl (64.1 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

duckai-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl (67.3 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

duckai-0.3.1-cp39-cp39-win_amd64.whl (48.9 kB view details)

Uploaded CPython 3.9Windows x86-64

duckai-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (83.8 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64

duckai-0.3.1-cp39-cp39-macosx_11_0_arm64.whl (64.1 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

duckai-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl (67.3 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

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

Hashes for duckai-0.3.1-cp313-cp313-win_amd64.whl
Algorithm Hash digest
SHA256 2dabd9768c388abc840b4d502ba9fc2d029e2b12e9adf23bef89247d9a8a6e3a
MD5 4d1de4849bb9563dbcda57a220e9a73f
BLAKE2b-256 68610dc6471a140170f796967a1128abb7c350927b09c78d62743790e3d33c26

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp313-cp313-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 bf71468538c7405cbb2708183ab6a71b19c7e53c08b93d72f0781f6ae838d071
MD5 731fe805322eab157f37bc4e7516b87b
BLAKE2b-256 9068d9ebeb87e8f48172e633ec142157e147dfcbc9e2d7abc7e45caad799eb12

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp313-cp313-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp313-cp313-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c30c00ef1b2896d7f51712c31ab0e8a553820a92e5a3b477fe19e3e818d1d768
MD5 fe34b847b3e89996c88015818e3422b7
BLAKE2b-256 2f4095fef94c9acbf21172f37e0130b5e52f8a8145c66c12a8279e4ab6033b98

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp313-cp313-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp313-cp313-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 ed2f0a890ddc56d57cb7384299fab4d8a5e7bdd11aa6888e0f7c1a63a34c27de
MD5 161aa7496fa802c1c11a4be8a9148a9b
BLAKE2b-256 f0e30f1debaef8f3306eb6a07af00ec57d933383cef16d0f81de020732706c5f

See more details on using hashes here.

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

Hashes for duckai-0.3.1-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 ea182182d231abc9363eedac228c34aa8bbe4c301d069b4fd451e1a0064487d5
MD5 82dfe3e87d52ea9b365fb51efda96dd6
BLAKE2b-256 a0a8e9c30337e680ec1e2aae4fd54a6a8bde38f4b44bcd3c989f69c91bc712cf

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 c68a869a4a7a5cc8f9bd42d02cbe8437332215f76c79e0d879d9311adb4781a9
MD5 3014d7f3a9f3b4139ace343b5315494d
BLAKE2b-256 3895a45b757702bbbf1c77a63f1d6b70d02d895deea7677d35ea8d6ed265a389

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 0efd150c27256df3330bff65bf493fae1dd119ce9c1f433eba671968cd759784
MD5 285d6ed74cf9e75862ab4824261a0aea
BLAKE2b-256 de5a73251f7ab64ed688aba2cfbe9c29b9c166aeaafe1671c0be6a6f0bd2cf89

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 939e9296d72ac80a127d3614b3228a6682769105cda3b4295e279c2a00177b33
MD5 f0b1ade7652dd9283fe380f787645eee
BLAKE2b-256 cc4f9b157ad06f64a6a3590f96c5058242f5eb16f2b11e47912e48ed4889168c

See more details on using hashes here.

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

Hashes for duckai-0.3.1-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 efd7db0a814cc0ed0ad16dd125d94df70ce207cb105efde387c0a97c79b59cd5
MD5 8ad0e7624a09d94e43b66cb25ac99247
BLAKE2b-256 39bed02f53cfb83e478a1ac8369e24fb73d8bb4b532b176c37fb501701e7f971

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3195cc6889e2afd332e266fefda688e9305d7a3e867820b668d96149c50b054f
MD5 54f92a5356888f12749746db0448df80
BLAKE2b-256 f5e5b70bd51ba8e7283c13be6ea98692253f81c71007de171b874b7c96b95a30

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 93333de3b36b3e3a7efc4f190878c40fd8f47d9876ed318cd4e6773339f00e18
MD5 7f7b6530b6423dfa38ab88ca9953610a
BLAKE2b-256 06650f11029d81fd94f45605aa765cf8d2c14fad74b8808b004071fc82853cca

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 3c94106ae2bf19048d29f147197d7d02f6427867c5a38a4b2013e5f89bc34f65
MD5 80c6fd3e58dd013b5fefd68561e6d0e2
BLAKE2b-256 102d704cb8a0acb49b7ed58547242deb18b02b99d019e4f019a0c0becd950a41

See more details on using hashes here.

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

Hashes for duckai-0.3.1-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 93f5b16c7f7c479de417163d6715b4f57d4c2622f8a6906d13a778dfcabeccb6
MD5 58cafd98fecc4fd4e344736a49c6dc59
BLAKE2b-256 373bc7fce8774557a3c087fbcf9a9ea3a7da32cf1e1ea4ff6b3a7e57a725dbc0

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 2b6e1f1c2d2ab435cd3caa70dacbef467c74fbdc86b58db82647fcaf3a34adc9
MD5 2d7ef0bf7912618e16a97a09a96e37e0
BLAKE2b-256 632907c4a58672e47f228f606a50b257b1c3f6e57d216c9ddfcaeac9ac8dff57

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 9254a5bc735578d3076165af0f1786331ceffee79ead74004b5c4d3f11ce5bc6
MD5 4c48e2a4bba0fdd30f7acfea11a3519d
BLAKE2b-256 bce4c5aefdb75ebdcb8e28faeba5442cc25ca2e0394b3227d3fb4b55789e91f8

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 abd40623e7f67cb6633beae50a520297ec6f0980af48934eae08c455734eb9b7
MD5 56598da46ffd3e49b291e24eb474008e
BLAKE2b-256 85c0a872cd01a68a6134f0511f62559da4fd7e841b87b4018fb5b2c0420f5b13

See more details on using hashes here.

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

Hashes for duckai-0.3.1-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 c4a4d6c66777ba720a3c7fa97c985000ac518064058e479d82609d46962bcf22
MD5 999c43ed049d9970f4615d448a199afe
BLAKE2b-256 c1dd708504cf3c420e26a2376f5a1eaef171e3d043d051d6a19734b118529e74

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 84f8fb817ecf87c1390cfde96aa853ba95a23a37e4290b4103c248bfdd6a835f
MD5 202129680ba164e18a3b37cfbb2093a1
BLAKE2b-256 193fdda3818a9e5b0d1ca11c6310478f80ec8dc2b779aec95fbde624ca8ef3a9

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 d13b68a88714feabeb133368ee8251638049b98d89b61cb098f1d47f3ea6d69a
MD5 e44a1d13c93404d6e1b39f8931a6a94f
BLAKE2b-256 fa43f39602d3fe434059726a8ec0ebd4d3e80b6ff8a05fcba07253fa22471a60

See more details on using hashes here.

File details

Details for the file duckai-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for duckai-0.3.1-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 f2da9c9e60dcf0995e584e376a07844456dd184016bc71994e3ec921ae7e8466
MD5 779be28391f32876afe61f2abd90d4ea
BLAKE2b-256 8bdcaabcbee0af2db0b2bfa9cff3de2c5f130e364d37eed56e4ec8ea9f840e8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page