Skip to main content

DuckDuckAI

DuckDuckAI is a Python package for interacting with DuckDuckGo's chat API. It allows you to fetch responses from DuckDuckGo's AI models and print them in a streamed format or as a complete response.

Installation

To install the DuckDuckAI package, you can use pip:

pip install DuckDuckAI

Usage

You can interact with DuckDuckAI by calling the ask function. It supports both streaming responses or returning the entire message at once.

Example

from duckduckai import ask

# Fetch response in streamed format (printing character by character)
ask("Tell me a joke", stream=True)[0] # Use 0 if you want to retrieve it inside a variable.

# Fetch response as a complete message
response = ask("Tell me a joke", stream=False)
print(response)

Parameters

Parameter Type Description Default
query str The search query string. Required
stream bool Whether to stream results or fetch them all at once. True
model str The model to use for the response. gpt-4o-mini

Available Models

DuckDuckAI currently supports the following models:

Model ID Description
gpt-4o-mini A smaller variant of GPT-4o designed for quick, concise responses with less computation.
meta-llama/Llama-3.3-70B-Instruct-Turbo Meta's large-scale Llama 3.3 model with 70 billion parameters designed for fast and accurate responses.
claude-3-haiku-20240307 Anthropic's Claude 3 Haiku model optimized for efficient, high-quality responses.
mistralai/Mistral-Small-24B-Instruct-2501 Mistral AI's 24 billion parameter model trained for instruction-based tasks.
o3-mini OpenAI's compact reasoning model optimized for lightweight performance.

Additional models may be available but subject to access restrictions. Some models may require specific permissions or may not be available in all regions.

Advanced Usage

You can reuse the authentication token to make multiple requests more efficiently:

from duckduckai import ask, fetch_x_vqd_token

# Fetch a token once
token = fetch_x_vqd_token()

# Use the same token for multiple requests
response1 = ask("What is quantum computing?", model="gpt-4o-mini", token=token)[0]  # Do not put [0] if you want the token in the response
response2 = ask("Explain neural networks", model="claude-3-haiku-20240307", token=token)[0] # Do not put [0] if you want the token in the response

License

This project is licensed under the Apache-2.0 license - see the LICENSE file for details.

Metadata

Release files for DuckDuckAI 1.0.4

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

Source distribution (sdist)

Source distribution for DuckDuckAI 1.0.4
File Size Uploaded
duckduckai-1.0.4.tar.gz 3.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for DuckDuckAI 1.0.4
File Interpreter ABI Platform
DuckDuckAI-1.0.4-py3-none-any.whl Python 3 none any Details

Total release size: 7.9 kB

Release files / duckduckai-1.0.4.tar.gz

Download URL duckduckai-1.0.4.tar.gz
Size 3.8 kB
Tags Source
SHA-256 checksum
How to use checksums
f2820386fef4147be94abd984ca229eb16951e113428cc5e6bead09b35c5b4df
BLAKE2b-256 checksum
How to use checksums
d7712466e0fe302ce5c4e6e41f9eda6cc6bb2aa74a5d7e42195973721692fc0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / DuckDuckAI-1.0.4-py3-none-any.whl

Download URL DuckDuckAI-1.0.4-py3-none-any.whl
Size 4.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
050f10b57b41a45b4bfa3ada0c7e478a895f40139254f4165a6d3b2e401f6d89
BLAKE2b-256 checksum
How to use checksums
a039bac417b11a5a47827856117dfeba17ec2750481dd67a40d16f27982c57e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

1.0.4 This release

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 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