Skip to main content
drupalreleases

Use direct release data with your AI assistant.

Learn more

Perplexity Provider

No security coverage Under active development 38 sites

Part of the AI ecosystem · 342 projects

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.

Ask your assistant about Perplexity Provider

Check compatibility with your Drupal and PHP version, maintenance and security coverage, from current release data. How it works

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 PHP Release date
1.0.0-beta2 Pre-release Dec 2, 2024
1.0.0-beta1 Pre-release Dec 2, 2024