Drupal is a registered trademark of Dries Buytaert
Release: Drupal 10.3.6 Update released for Drupal core (10.3.6)! Release: Drupal 11.0.5 Update released for Drupal core (11.0.5)! Release: Drupal 10.2.9 Update released for Drupal core (10.2.9)! Release: Drupal 10.2.10 Update released for Drupal core (10.2.10)! Release: Drupal 10.3.7 Update released for Drupal core (10.3.7)! Release: Drupal 11.0.6 Update released for Drupal core (11.0.6)! Release: Drupal 10.3.8 Update released for Drupal core (10.3.8)! Release: Drupal 11.0.7 Update released for Drupal core (11.0.7)! Module Revived: Translation Management Tool 8.x-1.19 Module tmgmt updated after 7 months of inactivity (8.x-1.19). Usage Milestone: Account field split Module account_field_split crossed 10,000 active installs.

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