jev_dart
September 21, 2026 · View on GitHub
Dart client for TypeSafe AI — Jev, the System One model.
Send state and typed questions (noul, choice, score); get structured answers your code can branch on.
This is a pure Dart package (no Flutter dependency). Use it from a CLI, a server, or a Flutter app via import 'package:jev_dart/jev_dart.dart'.
Install
dependencies:
jev_dart: ^0.1.4
Set TYPESAFE_API_KEY or JEV_API_KEY (also loaded from .env in tests and the example), then:
import 'package:jev_dart/jev_dart.dart';
void main() async {
final client = TypeSafeClient();
final result = await client.systemOne(
state: {'document': 'I was charged twice. Please fix this ASAP.'},
questions: {
'category': choice('What is this ticket about?', {
'billing': null,
'technical': null,
'other': null,
}),
},
);
print(result.choice('category').choice);
client.close();
}
HTTP transport
- VM / mobile / desktop: default client is
Http2Client(http2: ^3.1.0) — pooled HTTP/2 toapi.typesafe.ai. - Web:
package:httpClient(HTTP/1.1).http2needsdart:io. - HTTP/2 only: if the host does not negotiate
h2, inject HTTP/1.1 explicitly:
TypeSafeClient(httpClient: http.Client());
JSON performance
The client keeps one HTTP client alive so the VM transport can reuse its pooled
HTTP/2 connection. Request payloads are written directly to UTF-8 bytes and
JSON responses are decoded directly from response bytes with Crimson. Ordinary
JSON values use its fast writer; values exposing only toJson() automatically
fall back to Dart's standard encoder.
On Web, the package uses the direct JsonUtf8Encoder and the standard decoder
because Crimson's current VM-oriented implementation is not JavaScript-safe.
On VM/mobile/desktop, the fast decoder assumes the server returned valid
UTF-8 JSON, as required by the API contract. Non-JSON responses and decoder
failures keep the tolerant dart:convert fallback.
Flutter
Import this package. Do not add a Flutter plugin wrapper unless you need widgets or native channels.
Configuration
Constructor values override environment variables, then SDK defaults.
| Option | Env | Default |
|---|---|---|
apiKey | TYPESAFE_API_KEY | required |
baseUrl | TYPESAFE_BASE_URL | https://api.typesafe.ai |
defaultModel | TYPESAFE_DEFAULT_MODEL | jev-latest |
logLevel | TYPESAFE_LOG_LEVEL | warn |
timeout | — | 10s per attempt |
retry | — | 2 retries, 408/429/5xx |
Example
example/main.dart runs three live cases (TypeSafe quickstart playground, the JS SDK demo, and a calm contrast ticket) and checks the answers (urgency high vs low, billing vs not sales, etc.):
dart run example/main.dart