Skip to content

onedotnet/soxai-node

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SoxAI — Node.js SDK

The official Node.js / TypeScript client for SoxAI — a unified AI API gateway giving you access to 200+ AI models from 40+ providers through a single OpenAI-compatible API.

Installation

npm install soxai
# or
yarn add soxai
# or
pnpm add soxai
# or
bun add soxai

Quick Start

import { SoxAI } from "soxai";

const client = new SoxAI({ apiKey: "sox-your-key" });

const response = await client.chat.completions.create({
  model: "claude-sonnet-4-6", // or gpt-4o, gemini-2.5-flash, deepseek-chat, ...
  messages: [{ role: "user", content: "Hello!" }],
});

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

Why SoxAI?

  • One API key for OpenAI, Anthropic, Google, DeepSeek, Meta, and 35+ more providers
  • Automatic failover — if one provider goes down, requests route to another
  • Team management — per-developer API keys with spending limits
  • Compatible with Claude Code, Codex CLI — just set ANTHROPIC_BASE_URL
  • Free $5 credit to start, no credit card required

Examples

Streaming

import { SoxAI } from "soxai";

const client = new SoxAI();

const stream = await client.chat.completions.create({
  model: "gpt-4o-mini",
  messages: [{ role: "user", content: "Write a haiku about APIs." }],
  stream: true,
});

for await (const chunk of stream) {
  const content = chunk.choices[0]?.delta?.content;
  if (content) process.stdout.write(content);
}

Multi-Model Agent

import { SoxAI } from "soxai";

const client = new SoxAI();

async function agentStep(prompt: string, model: string) {
  const r = await client.chat.completions.create({
    model,
    messages: [{ role: "user", content: prompt }],
  });
  return r.choices[0].message.content ?? "";
}

// Cheap model for classification
const intent = await agentStep("Classify: ...", "gpt-4o-mini");

// Capable model for reasoning
const analysis = await agentStep("Analyze: ...", "claude-sonnet-4-6");

// Budget model for summarization
const summary = await agentStep(`Summarize: ${analysis}`, "deepseek-chat");

Environment Variable

export SOXAI_API_KEY="sox-your-key"
import { SoxAI } from "soxai";
const client = new SoxAI(); // reads from SOXAI_API_KEY

Using with Existing OpenAI Code

Already using the OpenAI SDK? Just change baseURL:

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "sox-your-key",
  baseURL: "https://api.soxai.io/v1",
});
// Everything else stays the same

Links

License

MIT

About

SoxAI Node.js/TypeScript SDK — Access 200+ AI models through one OpenAI-compatible API

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors