This project is not covered by Drupal’s security advisory policy.
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
- Verify your API key is correctly stored in the Key module.
- Check if the key has proper permissions.
- Rate Limiting - The module handles rate limits automatically.
- If you encounter rate limits, try reducing request frequency.
Project information
- Project categories: Integrations
- Ecosystem: AI (Artificial Intelligence)
47 sites report using this module
- Created by vince_pl on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
