deepseek_box
A DeepSeek AI provider based on ai_box.
Usage
import 'package:ai_box/ai_box.dart';
import 'package:deepseek_box/deepseek_box.dart';
Future<void> main() async {
final ai = DeepSeek(apiKey: 'sk-...');
// One-shot text generation.
final answer = await ai.generateText(
model: 'deepseek-chat',
message: 'Say hello in one short sentence.',
);
print(answer);
// Multi-turn chat.
final res = await ai.chat(
model: 'deepseek-chat',
messages: [
LLMContent.system('You are concise.'),
LLMContent.user('What is the capital of Japan?'),
],
maxTokens: 32,
);
print(res.text);
print(res.usage); // token usage
}
Reasoning model
With deepseek-reasoner, the model's chain of thought is exposed through
the common ai_box reasoning API:
final res = await ai.chat(
model: 'deepseek-reasoner',
messages: [LLMContent.user('What is 17 * 24?')],
);
print(res.content.reasoning); // thinking
print(res.text); // final answer
Streaming
True SSE streaming — text arrives incrementally and the final chunk carries the finish reason and token usage:
await for (final text in ai.generateTextStream(
model: 'deepseek-chat',
message: 'Write a haiku about Dart.',
)) {
stdout.write(text);
}
Models and key validation
final models = await ai.getModels();
final ok = await ai.validateKey();
Tool calling, structured output and the sealed LLMException error
hierarchy are all provided by ai_box —
see its README for details.