Perplexity Provider
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.
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
Releases
| Version | Type | Core | Notes | Release date | |
|---|---|---|---|---|---|
| 1.0.0-beta2 | Pre-release | Dec 2, 2024 | |||
| 1.0.0-beta1 | Pre-release | Dec 2, 2024 |