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

artificial-gateway-sdk

v1.1.26

Published

Multi-provider AI gateway SDK — unified API for OpenAI, Anthropic, Google, xAI, DeepSeek, Mistral, and more. Chat, images, audio, embeddings, and files.

Readme

Artificial Gateway SDK

Universal AI gateway client for OpenAI, Anthropic, Google AI, xAI (Grok), DeepSeek, Mistral, Qwen, Stability AI, ElevenLabs, and more.

Single SDK, any model, any provider. The gateway handles routing, fallback, and billing transparently.

npm install artificial-gateway

Quick Start

import { ArtificialGateway } from "artificial-gateway";

const client = new ArtificialGateway({
  apiKey: "ag_your_key_here",
  // baseUrl: "https://your-deployment.com", // optional
});

// Works with any provider — just pick a model
const completion = await client.chat.completions.create({
  model: "gpt-5.4",
  messages: [{ role: "user", content: "Hello!" }],
});

Chat Completions (All Providers)

Works with OpenAI, Anthropic, Google, xAI, DeepSeek, Mistral, Qwen, and more.

// Non-streaming
const reply = await client.chat.completions.create({
  model: "claude-sonnet-4-6",
  messages: [{ role: "user", content: "Explain quantum computing" }],
  max_tokens: 1000,
});
console.log(reply.choices[0].message.content);

// Streaming
const stream = await client.chat.completions.create({
  model: "gpt-5.4",
  messages: [{ role: "user", content: "Write a poem" }],
  stream: true,
});
for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content ?? "");
}

Multimodal (Vision + Audio)

// Image understanding (GPT-4o, Claude, Gemini, Grok, Mistral, Qwen)
const reply = await client.chat.completions.create({
  model: "gemini-2.5-pro",
  messages: [{
    role: "user",
    content: [
      { type: "text", text: "What's in this image?" },
      { type: "image_url", image_url: { url: "https://example.com/photo.jpg" } },
    ],
  }],
});

// Audio in chat (Gemini, GPT-4o audio)
const reply = await client.chat.completions.create({
  model: "gpt-5.4",
  messages: [{
    role: "user",
    content: [
      { type: "text", text: "Transcribe this:" },
      { type: "input_audio", input_audio: { data: base64audio, format: "wav" } },
    ],
  }],
});

Tool / Function Calling

const reply = await client.chat.completions.create({
  model: "gpt-5.4",
  messages: [{ role: "user", content: "What's the weather in Tokyo?" }],
  tools: [{
    type: "function",
    function: {
      name: "get_weather",
      description: "Get current weather",
      parameters: {
        type: "object",
        properties: {
          location: { type: "string" },
        },
        required: ["location"],
      },
    },
  }],
  tool_choice: "auto",
});

Structured Output

const reply = await client.chat.completions.create({
  model: "gpt-5.4",
  messages: [{ role: "user", content: "Extract: John is 30" }],
  response_format: {
    type: "json_schema",
    json_schema: {
      name: "person",
      strict: true,
      schema: {
        type: "object",
        properties: {
          name: { type: "string" },
          age: { type: "number" },
        },
        required: ["name", "age"],
        additionalProperties: false,
      },
    },
  },
});

Images

Works with OpenAI (DALL-E 3/2) and Stability AI (through the gateway).

// Generate
const images = await client.images.generate({
  model: "dall-e-3",
  prompt: "A cosmic turtle flying through space",
  n: 1,
  size: "1024x1024",
});
console.log(images.data[0].url);

// Edit (add mask to change part of image)
const edit = await client.images.edit({
  image: imageFile,
  mask: maskFile,
  prompt: "Add a castle in the background",
});

// Variations
const variations = await client.images.createVariation({
  image: imageFile,
  n: 3,
});

Audio

Works with OpenAI Whisper (STT), Google (STT), OpenAI TTS, and ElevenLabs (through the gateway).

// Speech-to-text (transcription)
const transcript = await client.audio.transcriptions.create({
  file: audioFile,
  model: "whisper-1",
  language: "en",
});
console.log(transcript.text);

// Translation (transcribe + translate to English)
const translation = await client.audio.translations.create({
  file: audioFile,
  model: "whisper-1",
});

// Text-to-speech
const audioResponse = await client.audio.speech.create({
  model: "tts-1",
  input: "Hello, this is a test of the text to speech system.",
  voice: "alloy",
  response_format: "mp3",
});
const blob = await audioResponse.blob();
// Save or stream the audio blob

Embeddings

Works with OpenAI, Google, Mistral, and other embedding providers.

const embedding = await client.embeddings.create({
  model: "text-embedding-3-small",
  input: "The quick brown fox jumps over the lazy dog",
});
console.log(embedding.data[0].embedding); // number[]

// Batch embedding
const batch = await client.embeddings.create({
  model: "text-embedding-3-small",
  input: ["Hello world", "Goodbye world"],
});

Files

// Upload
const file = await client.files.create({
  file: fileObject,
  purpose: "assistants",
});

// List
const files = await client.files.list();

// Retrieve
const info = await client.files.retrieve("file-xxx");

// Delete
await client.files.del("file-xxx");

// Download content
const content = await client.files.retrieveContent("file-xxx");

Moderations

const result = await client.moderations.create({
  input: "I want to hurt someone",
});
console.log(result.results[0].flagged); // true/false

Models

const models = await client.models.list();
console.log(models.map(m => `${m.id} (${m.owned_by})`));

Provider Examples

The Artificial Gateway routes by model name. The same SDK works with all providers:

| Model | Provider | Capabilities | |---|---|---| | gpt-5.4 | OpenAI | chat, vision, tools, streaming, reasoning | | claude-sonnet-4-6 | Anthropic | chat, vision, tools, streaming | | gemini-2.5-pro | Google | chat, vision, audio, tools, streaming | | grok-4.3 | xAI | chat, vision, tools, streaming | | deepseek-v4-flash | DeepSeek | chat, tools, reasoning | | mistral-large-3 | Mistral | chat, vision, tools | | qwen3.7-max | Qwen | chat, vision, tools, reasoning | | dall-e-3 | OpenAI | image generation | | whisper-1 | OpenAI | audio STT | | tts-1 | OpenAI | audio TTS | | text-embedding-3-small | OpenAI | embeddings |


Error Handling

import { ArtificialGateway, ArtificialGatewayError } from "artificial-gateway";

try {
  await client.chat.completions.create({ ... });
} catch (err) {
  if (err instanceof ArtificialGatewayError) {
    console.error(`[${err.status}] ${err.message}`);
  }
}

API Reference

ArtificialGateway(config)

| Option | Type | Default | Description | |---|---|---|---| | apiKey | string | required | Your ag_... API key | | baseUrl | string | https://app.artificialguy.com | Gateway deployment URL |

Namespaces

| Namespace | Methods | Description | |---|---|---| | chat.completions | create() | Chat completions (stream + non-stream) | | images | generate(), edit(), createVariation() | Image generation, editing, variations | | audio.transcriptions | create() | Speech-to-text | | audio.translations | create() | Audio translation to English | | audio.speech | create() | Text-to-speech | | embeddings | create() | Text embeddings | | models | list() | Available models | | files | create(), list(), retrieve(), del(), retrieveContent() | File management | | moderations | create() | Content moderation |


Requirements

  • Node.js 18+ (or modern browser with fetch, FormData, ReadableStream)
  • TypeScript (for type definitions)

License

MIT