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

@karkata-ai/openai-compatible

v0.1.1

Published

OpenAI-compatible chat completions adapter and concise Agent factory for Karkata.

Readme

@karkata-ai/openai-compatible

文档 | English | 中文

Karkata 的 OpenAI-compatible Chat Completions Adapter,包含便捷的 createAgent() 工厂以及可独立传给 Core 的 OpenAICompatibleAdapter。

安装

npm install @karkata-ai/core @karkata-ai/openai-compatible

使用

import { createAgent } from '@karkata-ai/openai-compatible'

const agent = createAgent({
  baseURL: 'https://your-provider.example/v1',
  apiKey: process.env.MODEL_API_KEY,
  maxRetries: 2,
  agent: {
    systemPrompt: 'Reply in Chinese.',
    streaming: {},
  },
})

const result = await agent.send('你好')

baseURL 是唯一必填的 Provider 配置。model 可选:提供时会作为请求体元数据发送,省略时不发送 model 字段。使用后端 LLM Proxy 时,代理可以忽略、覆盖、映射或拒绝前端传入的模型;直接连接严格要求模型的 Provider 时,应由调用方提供 model。

Adapter 规范化文本、Tool Call、Token Usage、SSE 流和常见 HTTP/网络错误。只重试网络错误、HTTP 429 与 HTTP 5xx;鉴权、校验和普通 4xx 不重试。自定义 headers 或 fetch 可用于短期令牌和应用后端代理。

不要把长期 API Key 放入公开浏览器包。不同服务虽然使用相似的 OpenAI 路径,也可能在流式事件、工具调用或错误体上存在差异;发布前应对目标 Provider 显式运行真实 smoke。

在 Karkata 仓库中设置 KARKATA_BASE_URL、KARKATA_API_KEY、KARKATA_MODEL,然后运行 npm run test:integration:real。可选的 KARKATA_STREAMING=true 会验证流式路径;命令不会打印密钥或响应正文。

完整配置与 Runtime 说明见 Karkata 仓库。

License

MIT