Responses

Responses

POST https://models.mixlayer.ai/v1/responses

Create a model response using the OpenAI Responses API shape. Use this endpoint when you want input items, function-call output items, structured text output, response storage, or Responses-style streaming events.

For classic OpenAI chat compatibility, see Chat Completions.

Authentication

Every request requires a Bearer token in the Authorization header. Create one in the Mixlayer console.

Authorization: Bearer $MIXLAYER_API_KEY

Minimal request

curl https://models.mixlayer.ai/v1/responses \
  -H "Authorization: Bearer $MIXLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen/qwen3.5-4b-free",
    "input": "Write a one-sentence bedtime story."
  }'

Request parameters

This page is the canonical reference for supported Responses parameters.

ParameterTypeRequiredDescription
modelstringYesModel identifier.
inputstring or array of input itemsYesText prompt or Responses input items. See Input.
instructionsstringNoSystem/developer instructions prepended to the request.
streambooleanNoIf true, returns Responses Server-Sent Events. Defaults to false.
temperaturefloatNoSampling temperature.
top_pfloatNoNucleus sampling value.
frequency_penaltyfloatNoFrequency penalty.
presence_penaltyfloatNoPresence penalty.
max_output_tokensintegerNoMaximum generated output tokens.
toolsarrayNoFunction tools the model may call. Only type: "function" tools are supported.
tool_choice"auto" or "none"NoDefaults to "auto". "none" disables tool use for the request.
textobjectNoText output configuration. See Text format.
reasoningobjectNoReasoning configuration. See Reasoning.
storebooleanNoIf true, stores the response so a later request can use previous_response_id. Defaults to false.
previous_response_idstringNoContinues from a stored response.
metadataobjectNoMetadata stored with the response when store is true.
safety_identifierstringNoEnd-user or session identifier echoed on the response object.
prompt_cache_keystringNoPrompt-cache key echoed on the response object.
parallel_tool_callsbooleanNoSupported only as true; when tools is present, Mixlayer defaults this to true.
truncation"disabled"NoCompatibility field. Only "disabled" is supported.
service_tier"default"NoCompatibility field. Only "default" is supported.
stream_options.include_usagebooleanNoAccepted for streaming requests. Usage is included in terminal response events.

Input

The simplest input is a string, which Mixlayer treats as a user message:

{
  "model": "qwen/qwen3.5-4b-free",
  "input": "Explain why the sky is blue."
}

Array input supports message items, function-call items, and function-call output items:

{
  "model": "qwen/qwen3.5-4b-free",
  "input": [
    {
      "type": "message",
      "role": "user",
      "content": [
        { "type": "input_text", "text": "What is the weather in SF?" }
      ]
    }
  ]
}

Supported message roles:

RoleBehavior
userUser message.
assistantPrevious assistant message.
systemSystem message.
developerTreated as a system message.

Supported content part types:

TypeDescription
input_textText input.
output_textPrevious assistant output text.
textText content.
reasoning_textPrevious assistant reasoning text. Only valid on assistant messages.

Function Calls

Function tools use the Responses function-tool shape:

{
  "tools": [
    {
      "type": "function",
      "name": "get_weather",
      "description": "Get weather for a city.",
      "parameters": {
        "type": "object",
        "properties": {
          "city": { "type": "string" }
        },
        "required": ["city"]
      },
      "strict": true
    }
  ]
}

Tool names must be 1-64 characters and contain only ASCII letters, numbers, _, or -. parameters must be a valid JSON Schema object. If omitted, Mixlayer uses an empty object schema.

To continue after a tool call, send the prior function_call item and a matching function_call_output item:

{
  "input": [
    {
      "type": "function_call",
      "call_id": "call_1",
      "name": "get_weather",
      "arguments": "{\"city\":\"SF\"}"
    },
    {
      "type": "function_call_output",
      "call_id": "call_1",
      "output": "{\"temp\":65}"
    }
  ]
}

Text Format

Use text.format to request plain text, JSON object mode, or JSON Schema output.

{
  "text": {
    "format": {
      "type": "json_schema",
      "name": "answer",
      "schema": {
        "type": "object",
        "properties": {
          "answer": { "type": "string" }
        },
        "required": ["answer"]
      },
      "strict": true
    }
  }
}

Supported text.format.type values:

TypeDescription
textPlain text output.
json_objectJSON object mode.
json_schemaJSON Schema-constrained output. Requires name and schema; strict is optional.

Reasoning

Pass reasoning.effort to control thinking mode on supported models.

ValueBehavior
noneDisables thinking.
minimalDisables thinking.
lowDisables thinking.
mediumEnables thinking.
highEnables thinking.
xhighEnables thinking.

reasoning.summary and reasoning.generate_summary may be omitted or null.

Stored Responses

Set store: true to persist a completed response. Stored responses are retained for 30 days by default, matching OpenAI. You can customize the retention period for your organization in the Mixlayer console, including enforcing zero storage.

A later request can pass that response’s id as previous_response_id to continue from the stored transcript:

{
  "model": "qwen/qwen3.5-4b-free",
  "previous_response_id": "resp_...",
  "input": "Continue from there."
}

Mixlayer loads up to 128 stored ancestors for previous_response_id.

Streaming

When stream: true, Mixlayer returns Server-Sent Events and finishes with data: [DONE].

curl https://models.mixlayer.ai/v1/responses \
  -H "Authorization: Bearer $MIXLAYER_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "qwen/qwen3.5-4b-free",
    "stream": true,
    "input": "Count to five."
  }'

Common event types include:

EventDescription
response.createdResponse object was created.
response.in_progressGeneration started.
response.output_item.addedA message, reasoning item, or function call was added.
response.output_text.deltaIncremental output text.
response.reasoning_text.deltaIncremental reasoning text.
response.function_call_arguments.deltaIncremental function-call arguments.
response.completedFinal response object with usage.
errorStreaming error event.

WebSocket transport

Mixlayer also exposes Responses over WebSocket for long-running, tool-heavy workflows. Use it when you have many turns on the same response chain and want to avoid reopening an HTTP request for every continuation.

wss://models.mixlayer.ai/v1/responses

Send a response.create JSON message for each turn. The message body is the same as POST /v1/responses, with an added type field:

{
  "type": "response.create",
  "model": "qwen/qwen3.5-4b-free",
  "input": "Count to five."
}

The server replies with Responses stream events as JSON messages, such as response.created, response.output_text.delta, response.completed, or error.

import WebSocket from "ws";
 
const ws = new WebSocket("wss://models.mixlayer.ai/v1/responses", {
  headers: {
    Authorization: `Bearer ${process.env.MIXLAYER_API_KEY}`,
  },
});
 
ws.on("open", () => {
  ws.send(JSON.stringify({
    type: "response.create",
    model: "qwen/qwen3.5-4b-free",
    input: "Count to five.",
  }));
});
 
ws.on("message", (data) => {
  const event = JSON.parse(data.toString());
  if (event.type === "response.output_text.delta") {
    process.stdout.write(event.delta);
  }
});

Use previous_response_id on the next response.create event to continue from an earlier response. Within a WebSocket connection, completed responses are cached locally, so previous_response_id can refer to earlier turns on that socket even when store is omitted.

Set store: true when a response must be durable outside the current WebSocket connection or reusable over HTTP. Set store: false when you want no stored continuation state. A store: true response cannot continue from a response that only exists in the current WebSocket scope.

Notes:

BehaviorDetails
AuthenticationPass the same Bearer token used for HTTP requests.
Event shapeServer events use the same Responses streaming event shape as HTTP streaming.
Request shapeUse type: "response.create" plus the normal create-response fields.
Unsupported fieldsDo not send background on WebSocket requests.
Parallel workUse multiple WebSocket connections for multiple in-flight responses.

Response

A non-streaming response returns a response object:

{
  "id": "resp_...",
  "object": "response",
  "created_at": 1762340000,
  "completed_at": 1762340001,
  "status": "completed",
  "model": "qwen/qwen3.5-4b-free",
  "output": [
    {
      "type": "message",
      "id": "msg_...",
      "status": "completed",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "A tiny moonbeam tucked the city into sleep.",
          "annotations": []
        }
      ]
    }
  ],
  "output_text": "A tiny moonbeam tucked the city into sleep.",
  "usage": {
    "input_tokens": 12,
    "input_tokens_details": { "cached_tokens": 0 },
    "output_tokens": 11,
    "output_tokens_details": { "reasoning_tokens": 0 },
    "total_tokens": 23
  }
}

Errors

Errors use the OpenAI error envelope:

{
  "error": {
    "message": "Missing required parameter `input`",
    "type": "invalid_request_error",
    "code": "missing_required_parameter"
  }
}