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

@yavqo/aisdk

v1.0.2

Published

Official Yavqo AI SDK for Node.js — powered by Sunlight AI. First-class support for Sunlight 2 and Sunlight 2 Pro.

Readme

@yavqo/aisdk

Official Yavqo AI SDK for Node.js — powered by Sunlight AI.

Installable via:

npm install @yavqo/aisdk
# or
pnpm add @yavqo/aisdk
# or
yarn add @yavqo/aisdk

Provides first-class support for:

  • Sunlight 2 — fast, efficient coding model
  • Sunlight 2 Pro — frontier reasoning model

Quick Start

import { createYavqo, sunlight2, sunlight2Pro } from '@yavqo/aisdk';

// Zero-config — works out of the box
const yavqo = createYavqo();

// Simple prompt
const { text } = await yavqo.generateText({
  model: sunlight2,
  prompt: 'Write a hello world in TypeScript',
});

console.log(text);

// With system + messages
const { text: text2 } = await yavqo.generateText({
  model: sunlight2Pro,
  system: 'You are a helpful coding assistant.',
  messages: [{ role: 'user', content: 'Explain closures in JS' }],
  temperature: 0.7,
  maxTokens: 1024,
});

Streaming

import { createYavqo, sunlight2Pro } from '@yavqo/aisdk';

const yavqo = createYavqo();

const { textStream, final } = await yavqo.streamText({
  model: sunlight2Pro,
  prompt: 'Write a short story about a robot learning to paint',
});

for await (const delta of textStream) {
  process.stdout.write(delta);
}

const result = await final;
console.log('\n---\nUsage:', result.usage);

Chat completions

import { Yavqo, sunlight2 } from '@yavqo/aisdk';

const client = new Yavqo();

const completion = await client.chat.completions.create({
  model: sunlight2,
  messages: [
    { role: 'system', content: 'You are Sunlight, a helpful AI.' },
    { role: 'user', content: 'Hello!' },
  ],
  temperature: 0.7,
});

console.log(completion.choices[0].message.content);

Structured output (JSON) — with Zod validation

import { createYavqo, sunlight2 } from '@yavqo/aisdk';
import { z } from 'zod';

const yavqo = createYavqo();

// Option A: raw JSON Schema
const { object } = await yavqo.generateObject<{ name: string; age: number }>({
  model: sunlight2,
  prompt: 'Generate a person with name and age',
  schema: {
    type: 'object',
    properties: {
      name: { type: 'string' },
      age: { type: 'number' },
    },
    required: ['name', 'age'],
    additionalProperties: false,
  },
  schemaName: 'person',
});
console.log(object); // { name: "Alice", age: 30 }

// Option B: Zod schema — validated locally
const Person = z.object({ name: z.string(), age: z.number() });
const { object: person } = await yavqo.generateObject({
  model: sunlight2,
  prompt: 'Generate a person',
  schema: Person,
});
console.log(person);

Tools / Function calling

const { text, toolCalls } = await yavqo.generateText({
  model: sunlight2Pro,
  messages: [{ role: 'user', content: 'What is the weather in Tokyo?' }],
  tools: [
    {
      type: 'function',
      function: {
        name: 'get_weather',
        description: 'Get weather for a city',
        parameters: {
          type: 'object',
          properties: { city: { type: 'string' } },
          required: ['city'],
        },
      },
    },
  ],
});

API Reference

createYavqo(config?) / new Yavqo(config?)

interface YavqoConfig {
  apiKey?: string;      // optional — defaults to built-in key
  baseURL?: string;     // optional — defaults to Sunlight AI gateway
  headers?: Record<string, string>;
  fetch?: typeof fetch;
  timeoutMs?: number;   // default 60_000 (0 = no timeout)
  maxRetries?: number;  // default 2
  retry?: {
    maxRetries?: number;
    initialDelayMs?: number;
    maxDelayMs?: number;
    backoffFactor?: number;
    jitter?: boolean;
    retryStatusCodes?: number[];
  };
}

Models

import { sunlight2, sunlight2Pro } from '@yavqo/aisdk';

sunlight2        // Sunlight 2
sunlight2Pro     // Sunlight 2 Pro

Methods

| Method | Description | |--------|-------------| | yavqo.generateText(opts) | Non-streaming text generation | | yavqo.streamText(opts) | Streaming generation | | yavqo.generateObject(opts) | JSON object generation (with optional schema) | | yavqo.chat.completions.create(opts) | Low-level chat completions | | yavqo.chat.completions.stream(opts) | Low-level streaming | | yavqo.listModels() | List available models |

Common options

{
  model: string;            // required
  prompt?: string;
  system?: string;
  messages?: ChatMessage[];
  temperature?: number;
  top_p?: number;
  maxTokens?: number;
  tools?: Tool[];
  tool_choice?: ToolChoice;
  stop?: string | string[];
  responseFormat?: { type: 'text' | 'json_object' | 'json_schema' };
  headers?: Record<string, string>;
  extraBody?: Record<string, unknown>;
  signal?: AbortSignal;
  maxRetries?: number;
  retry?: RetryConfig;
}

Retry & backoff

Automatic retry for transient failures (429, 500, 502, 503, 504, 529) with exponential backoff + jitter and Retry-After support.

const yavqo = createYavqo({
  maxRetries: 3,
  retry: { initialDelayMs: 300, maxDelayMs: 5000, backoffFactor: 2 },
});

CJS + ESM

// ESM
import { createYavqo } from '@yavqo/aisdk';
// CJS
const { createYavqo } = require('@yavqo/aisdk');

Testing

npm test
npm run lint

TypeScript

Fully typed. Requires Node >= 18.


License

MIT © Yavqo