npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@yesilsci/health-ai-api

v0.1.1

Published

Official TypeScript client for the Yesil Health AI enterprise (B2B) API.

Downloads

258

Readme

@yesilsci/health-ai-api

Official TypeScript client for the Yesil Health enterprise (B2B) API.

Zero runtime dependencies — uses the platform fetch + ReadableStream (Node ≥ 18, modern browsers, edge runtimes). The hard part of integrating — parsing the typed Server-Sent Events stream — is handled for you.

Install

npm install @yesilsci/health-ai-api

Quick start

import { YesilHealthClient } from '@yesilsci/health-ai-api';
import { randomUUID } from 'node:crypto';

const client = new YesilHealthClient({
  baseUrl: 'https://api.yesilhealth.com',
  apiKey: process.env.YESIL_API_KEY!, // sent as X-API-Key
});

for await (const ev of client.chatStream({
  question: 'Is metformin safe for a patient with stage 3 CKD?',
  request_id: randomUUID(),          // idempotent billing — strongly recommended
  demographics: { age: 62, sex: 'female' },
  health_context: 'eGFR 45 mL/min/1.73m². On lisinopril 10mg daily.',
})) {
  if (ev.type === 'delta') process.stdout.write(ev.content);
}

One-shot (no live rendering):

const { text, events } = await client.chat({ question: '...' });

Authentication

Every request is authenticated with your enterprise API key via the X-API-Key header. Keep it server-side; never ship it in a browser bundle or mobile app.

The event stream

chatStream() yields typed events. Route on event.type:

| type | Payload | Notes | |--------------------|--------------------------------------|-------| | meta | phase, conversation_id, research preview fields | Lifecycle + mid-stream research previews. | | delta | content: string | Append content to build the answer text. | | citation | citation fields | A literature citation for the answer. | | graph | data: {...} | Structured chart/diagram, delivered out-of-band from text. | | memory_extracted | signals: MemorySignal[] | Only if your tenant has extract_memory enabled. Persist and replay via memory. | | done | summary: {...} | Terminal success event. | | error | message, code | Terminal failure event; stream ends. |

Forward compatibility. The API only ever adds fields and event types within a contract version — it never renames, removes, or retypes existing ones. Always include a default branch in your switch and ignore unknown event types. This client surfaces them as UnknownEvent rather than throwing.

Request fields

| Field | Required | Description | |------------------------|----------|-------------| | question | ✅ | The end-user's question. | | request_id | — | Client UUID for idempotent billing. Strongly recommended. | | demographics | — | Small structured profile (≤ 12 KB JSON). | | health_context | — | Free-form clinical context (vitals, EHR summary, wearable rollups). | | conversation_history | — | Last turns only (max 8), roleuser/assistant. | | memory | — | Raw memory signals to replay. | | tenant_id | — | Optional hint; must match the key's tenant. |

Errors

Non-2xx HTTP responses throw YesilApiError with status, code (server error_code), and message:

import { YesilApiError } from '@yesilsci/health-ai-api';

try {
  await client.chat({ question: '...' });
} catch (e) {
  if (e instanceof YesilApiError) {
    if (e.code === 'RATE_LIMITED') { /* back off */ }
    if (e.status === 402)          { /* quota exhausted / billing */ }
  }
}

Common codes: RATE_LIMITED (429), quota/billing (402), INVALID_API_KEY (401). In-stream failures arrive as an error event (see table above), not an exception, unless you use the chat() convenience wrapper which re-throws them.

Account endpoints

await client.billing(); // billing status
await client.quota();   // quota / rate-limit status
await client.usage();   // usage report

Cancellation

Pass an AbortSignal to stop a stream early:

const ac = new AbortController();
setTimeout(() => ac.abort(), 5_000);
for await (const ev of client.chatStream({ question: '...' }, { signal: ac.signal })) { /* … */ }

Versioning

The client targets contract v1 (/api/v1). When Yesil Health cuts a new major version it ships alongside v1; bump apiVersion in ClientOptions to migrate on your own schedule. v1 is never force-killed.