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

@anvia/openai

v0.1.11

Published

OpenAI provider adapter for Anvia.

Readme

@anvia/openai

OpenAI provider adapter for Anvia.

Use this package when you want Anvia agents, extractors, pipelines, embeddings, image generation, audio generation, or transcription to run on OpenAI models or OpenAI-compatible endpoints.

Installation

pnpm add @anvia/openai @anvia/core

In this monorepo, the package is available through the workspace:

pnpm --filter @anvia/openai build

Usage

import { AgentBuilder } from "@anvia/core";
import { OpenAIClient } from "@anvia/openai";

const client = new OpenAIClient({
  apiKey,
});

const model = client.completionModel("gpt-5");

const agent = new AgentBuilder("assistant", model)
  .instructions("Answer clearly and concisely.")
  .build();

const response = await agent.prompt("Summarize Anvia in one sentence.").send();

console.log(response.output);

OpenAI-Compatible APIs

When baseUrl is provided, OpenAIClient uses the chat-completions-compatible adapter by default:

import { OpenAIClient } from "@anvia/openai";

const client = new OpenAIClient({
  apiKey,
  baseUrl,
});

const model = client.completionModel("openai/gpt-5.2");

You can also force a specific completion API with completionApi: "responses" or completionApi: "chat".

Reasoning tool-call providers

Some OpenAI-compatible chat-completions providers return reasoning in provider-specific fields while using normal tool calls. For example, Moonshot Kimi K2.6 returns reasoning_content when thinking is enabled.

The chat-completions adapter preserves this reasoning in assistant history and sends it back as reasoning_content on later turns. This matters after tool calls: providers such as Moonshot can reject the next request if an assistant tool_calls message is missing its prior reasoning_content.

For Moonshot Kimi K2.6 thinking mode:

const client = new OpenAIClient({
  apiKey: process.env.OPENAI_API_KEY,
  baseUrl: "https://api.moonshot.ai/v1",
});

const model = client.completionModel("kimi-k2.6");

const response = await model.completion({
  chatHistory,
  documents: [],
  tools,
  maxTokens: 16_000,
  additionalParams: {
    thinking: { type: "enabled", keep: "all" },
  },
});

Provider caveat: Moonshot rejects forced/specified tool_choice while thinking is enabled. Let the model choose tools naturally when using Kimi thinking mode.

Other Models

const embeddingModel = client.embeddingModel("text-embedding-3-small");
const imageModel = client.imageGenerationModel();
const audioModel = client.audioGenerationModel();
const transcriptionModel = client.transcriptionModel();

Exports

  • OpenAIClient
  • OpenAIResponsesCompletionModel
  • OpenAIChatCompletionModel
  • OpenAIEmbeddingModel
  • OpenAIImageGenerationModel
  • OpenAIAudioGenerationModel
  • OpenAITranscriptionModel
  • model constants such as GPT_IMAGE_1, DALL_E_3, TTS_1, and WHISPER_1
  • openai

Development

pnpm --filter @anvia/openai typecheck
pnpm --filter @anvia/openai test
pnpm --filter @anvia/openai build