Skip to main content
Provides chat completions for all open source models that are chat, audio-text-to-text, image-text-to-text, video-text-to-text, it also supports chat completions models from 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 We provide free api access to models from openai, mistral, and google. You will need to supply a header provider-key in order to make requests to anthropic, and cohere models. e.g. If you are trying to run anthropic/claude-sonnet-4-5, provider-key will be an Anthropic key. For unlimited rate limits you will need to supply a header provider-key. NOTE: Logprobs are supported for all models!

Basic usage (Open Source)

import OpenAI from "openai";

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

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,
  max_tokens: 150,
  temperature: 0.7
});

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

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

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 stream = await client.chat.completions.create({
  model: "Qwen/Qwen3-4B",
  messages,
  max_tokens: 150,
  temperature: 0.7,
  stream: true
});

let text = '';
for await (const event of stream) {
  if (event.choices[0].finish_reason) {
    break;
  }

  const content = event.choices[0].delta.content;
  text += content;
  console.log(content);
}

console.log({ text });
import OpenAI from "openai";

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

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: "openai/gpt-4",
  messages,
  max_tokens: 150,
  temperature: 0.7
});

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

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

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 stream = await client.chat.completions.create({
  model: "openai/gpt-4",
  messages,
  max_tokens: 150,
  temperature: 0.7,
  stream: true
});

let text = '';
for await (const event of stream) {
  if (event.choices[0].finish_reason) {
    break;
  }

  const content = event.choices[0].delta.content;
  text += content;
  console.log(content);
}

console.log({ text });