Skip to main content
Provides Responses for all closed source providers: openai, and anthropic. The Responses API is the unified successor to Chat Completions: you send input (text, images, files, tool outputs, etc.) and receive a response object that can contain messages, tool calls, and (for reasoning models) reasoning items. Note, anthropic does not yet support tool calls. To specify a provider, prefix the model with the provider. For example, gpt-5.1 should be passed as openai/gpt-5.1.

Thinking (Reasoning) parameters

Some OpenAI reasoning models (e.g. openai/gpt-5.x, openai/o3, openai/o4-mini) support the reasoning object:
  • reasoning.effort: "none" | "low" | "medium" | "high" | ... (model-dependent)
  • reasoning.summary: "none" | "auto" | "detailed" (optional)
All Anthropic models should support thinking. ⚠️ max_output_tokens limits reasoning tokens + visible output tokens, so if you increase reasoning.effort, consider raising max_output_tokens.
import OpenAI from "openai";

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

const response = await client.responses.create({
  model: "openai/gpt-5.1",
  input: [
    { role: "system", content: "You are a friendly chatbot" },
    { role: "user", content: "Hello bot, what is the capital of England?" }
  ],

  // Thinking controls (OpenAI reasoning models only)
  reasoning: {
    effort: "medium",   // try: "none" | "low" | "medium" | "high" (model-dependent)
    summary: "auto"     // "none" | "auto" | "detailed"
  },

  // Caps reasoning + visible output tokens together
  max_output_tokens: 300
});

console.log("Answer:", response.output_text);

// Optional: read a reasoning summary item (if requested & returned)
const reasoningItem = response.output?.find((it) => it.type === "reasoning");
if (reasoningItem?.summary?.length) {
  console.log("Reasoning summary:", reasoningItem.summary.map(s => s.text).join("\n"));
}
import OpenAI from "openai";

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

const stream = await client.responses.create({
  model: "openai/gpt-5.1",
  input: [
    { role: "system", content: "You are a friendly chatbot" },
    { role: "user", content: "Hello bot, what is the capital of England?" }
  ],
  reasoning: { effort: "medium", summary: "auto" },
  max_output_tokens: 400,
  stream: true
});

let text = "";
let reasoningSummary = "";

for await (const event of stream) {
  if (event.type === "response.output_text.delta") {
    text += event.delta;
    process.stdout.write(event.delta);
  }

  // Optional: stream reasoning summary text (if enabled by reasoning.summary)
  if (event.type === "response.reasoning_summary_text.delta") {
    reasoningSummary += event.delta;
  }

  if (event.type === "response.completed") break;
}

console.log("\n\nFinal:", { text });
if (reasoningSummary) console.log("\nReasoning summary:\n", reasoningSummary);