perplexity_dart 0.0.1 copy "perplexity_dart: ^0.0.1" to clipboard
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 #

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);
}
2
likes
130
points
79
downloads

Publisher

unverified uploader

Weekly Downloads

A lightweight Dart SDK to interact with Perplexity.ai's chat completion API (streaming + model switching supported).

Repository (GitHub)
View/report issues

Topics

#perplexity #chat #ai #llm #sdk

Documentation

API reference

License

MIT (license)

Dependencies

bloc, http

More

Packages that depend on perplexity_dart