Skip to main content

A package to interact with DuckDuckGo AI-powered search

Project description

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.

Project details


Download files

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

Source Distribution

duckduckai-1.0.4.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

DuckDuckAI-1.0.4-py3-none-any.whl (4.1 kB view details)

Uploaded Python 3

File details

Details for the file duckduckai-1.0.4.tar.gz.

File metadata

  • Download URL: duckduckai-1.0.4.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for duckduckai-1.0.4.tar.gz
Algorithm Hash digest
SHA256 f2820386fef4147be94abd984ca229eb16951e113428cc5e6bead09b35c5b4df
MD5 4583cddba67431787bea5c12038769ce
BLAKE2b-256 d7712466e0fe302ce5c4e6e41f9eda6cc6bb2aa74a5d7e42195973721692fc0f

See more details on using hashes here.

File details

Details for the file DuckDuckAI-1.0.4-py3-none-any.whl.

File metadata

  • Download URL: DuckDuckAI-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 4.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.5

File hashes

Hashes for DuckDuckAI-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 050f10b57b41a45b4bfa3ada0c7e478a895f40139254f4165a6d3b2e401f6d89
MD5 c391ea9bea2fd983bac29e4f11ffe9c8
BLAKE2b-256 a039bac417b11a5a47827856117dfeba17ec2750481dd67a40d16f27982c57e9

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