perplexity_dart 0.0.1
perplexity_dart: ^0.0.1 copied to clipboard
A lightweight Dart SDK to interact with Perplexity.ai's chat completion API (streaming + model switching supported).
perplexity_dart #
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);
}