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 to api.typesafe.ai.
  • Web: package:http Client (HTTP/1.1). http2 needs dart: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.

OptionEnvDefault
apiKeyTYPESAFE_API_KEYrequired
baseUrlTYPESAFE_BASE_URLhttps://api.typesafe.ai
defaultModelTYPESAFE_DEFAULT_MODELjev-latest
logLevelTYPESAFE_LOG_LEVELwarn
timeout10s per attempt
retry2 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

Docs: https://docs.typesafe.ai/