Skip to main content
Drupal is a registered trademark of Dries Buytaert
Release: Mailchimp 3.1.5 Minor update available for module mailchimp (3.1.5). Release: Commerce Shipping 3.0.5 Minor update available for module commerce_shipping (3.0.5). Release: GoogleTag Manager 2.0.1 Minor update available for module gtm (2.0.1). Usage Milestone: Easy Breadcrumb Module easy_breadcrumb crossed 100,000 active installs. Release: FlowDrop 1.6.1 Minor update available for module flowdrop (1.6.1). Release: MCP Sentinel 2.17.0 Minor update available for module mcp_sentinel (2.17.0). Release: Commerce ML Exchange 2.0.1 Minor update available for module cmlexchange (2.0.1). Release: Commerce ML Exchange 2.0.0 Major update available for module cmlexchange (2.0.0). Release: SynImport 2.0.0 Major update available for module synimport (2.0.0). Module Revived: Contextual Filter from Referer 1.0.2 Module contextual_filter_referer updated after 22 months of inactivity (1.0.2).

Perplexity Provider

47 sites No security coverage

Part of the AI ecosystem · 302 projects

View on drupal.org

This module integrates Perplexity AI into your Drupal site, allowing you to leverage Perplexity's language models for various AI tasks. It supports Perplexity's Sonar models and can be configured to handle model parameters and citations.

Perplexity AI Provider for Drupal

This module provides Perplexity AI integration for Drupal's AI module. It allows you to use Perplexity's powerful language models for various AI tasks in your Drupal site.

Requirements

  • Drupal 10 || 11
  • AI module
  • Key module

Install the required modules:

composer require drupal/ai drupal/key
drush en ai key

Enable the Perplexity AI Provider module:

drush en ai_perplexity

Configuration

Create an API key at Perplexity AI Settings.

Store your API key in the Key module:
Go to /admin/config/system/keys

Configure the Perplexity AI Provider:
Go to /admin/config/ai/perplexity

Select your API key from the dropdown
Choose your default model
Configure model settings

Available Models

llama-3.1-sonar-small-128k-onlinegeneral use
llama-3.1-sonar-large-128k-online
llama-3.1-sonar-huge-128k-online

Features

  • Seamless integration with Drupal's AI module
  • Support for all Perplexity Sonar models
  • Configurable model parameters
  • Citation support in responses
  • Rate limit handling

Usage Example

// Get the AI provider plugin manager
$ai_provider_manager = \Drupal::service('ai.provider');

// Get the Perplexity provider
$provider = $ai_provider_manager->createInstance('perplexity');

// Create a chat message
$input = new ChatInput();
$input->addMessage(new ChatMessage('user', 'What is quantum computing?'));

// Get the response
$output = $provider->chat($input, 'llama-3.1-sonar-small-128k-online');

// Access the response text
$response_text = $output->getMessage()->getText();

// Access citations if available
$citations = $output->getMetadata()['citations'] ?? [];

Example response structure

$output = [
  'message' => [
    'role' => 'assistant',
    'content' => 'The response text...'
  ],
  'metadata' => [
    'citations' => [
      // Citation information
    ]
  ]
];

Troubleshooting

API Key Issues

  1. Verify your API key is correctly stored in the Key module.
  2. Check if the key has proper permissions.
  3. Rate Limiting - The module handles rate limits automatically.
  4. If you encounter rate limits, try reducing request frequency.

Depends on

Dependencies of the latest stable release

No dependencies recorded for this project.

Required by

Tracked projects that depend on this one

No tracked projects depend on this one yet.

Activity

Tracked releases
2
Tracked since
Dec 2024
Latest release
1 year ago
Releases (12 mo)
0 ▼ from 2
Maintenance
Dormant

Releases

Version Type Core Release date
1.0.0-beta2 Pre-release Dec 2, 2024
1.0.0-beta1 Pre-release Dec 2, 2024