perplexity_dart

pub package License: MIT

Perplexity Dart SDK is a lightweight and type-safe Dart client for interacting with Perplexity.ai's chat/completions API.
It supports both streaming and non-streaming responses, flexible model switching (e.g., sonar, sonar-pro, etc.), and is designed to work with Dart CLI and Flutter apps.


✨ Features

  • πŸ” Streamed and full chat completion support
  • 🎯 Switch between models with known context lengths
  • πŸ’¬ Chat roles: system, user, assistant, tool
  • 🧱 BLoC integration ready
  • πŸ–ΌοΈ Coming soon: Image input via base64 or HTTPS URL

πŸš€ Getting Started

Add the SDK to your project:

dependencies:
  perplexity_dart: ^0.0.1

Import the SDK in your Dart code:

import 'package:perplexity_dart/perplexity_dart.dart';

Initialize the client with your API key:

final client = PerplexityClient(
  apiKey: 'your-api-key',
);

Send a chat request:

final response = await client.sendMessage(
  prompt: 'Hello, how are you?',
  model: PerplexityModel.sonarPro,
);

Stream a chat response:

final stream = client.streamChat(
  prompt: 'Hello, how are you?',
  model: PerplexityModel.sonarPro,
);

await for (final chunk in stream) {
  print(chunk);
}

Libraries

perplexity_dart