Skip to main content
Provides completions for all open source models that are text-generation, chat, audio-text-to-text, image-text-to-text, video-text-to-text, it also supports the closed source providers, openai, anthropic, mistral, cohere, and google. To specify a provider, prefix the model with the provider, e.g. gpt-4 should be passed in as openai/gpt4

Basic usage

import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "BYTEZ_KEY",
  baseUrl: "https://api.bytez.com/models/v2/openai/v1",
  defaultHeaders: { Authorization: "BYTEZ_KEY" }
});

const messages = [
  { role: "system", content: "You are a friendly chatbot" },
  { role: "assistant", content: "Hello, I'm a friendly bot" },
  { role: "user", content: "Hello bot, what is the capital of England?" }
];

const response = await client.chat.completions.create({
  model: "Qwen/Qwen3-4B",
  messages
});

console.log(response);
import OpenAI from "openai";

const client = new OpenAI({
  apiKey: "BYTEZ_KEY",
  baseUrl: "https://api.bytez.com/models/v2/openai/v1",
  defaultHeaders: { Authorization: "BYTEZ_KEY" }
});

const stream = await client.chat.completions.create({
  model: "Qwen/Qwen3-4B",
  messages,
  stream: true
});

let text = '';
for await (const event of stream) {
  if (event.type === "response.output_text.delta") {
    text += event.delta;
    console.log(event.delta);
  }
}

console.log({ text });
I