RunarsRunars Docs
EndpointsAPI Endpoints

POST /v1/responses

OpenAI Responses API compatible endpoint

Generate a response using the OpenAI Responses API format. This endpoint is an alternative to /v1/chat/completions with a different request/response shape.

⚠️ Known limitation

Tool calling is not yet supported on this endpoint. If you need tool calling, use /v1/chat/completions or /v1/messages instead.

Endpoint

POST https://api.runars.ca/v1/responses

Authentication

Include your API key as a Bearer token:

-H "Authorization: Bearer sk-runars-..."

Request body

For a comparison of common parameters across all endpoints, see Parameters Reference.

The Responses API uses input and instructions instead of the messages format:

FieldTypeRequiredDescription
modelstringYesModel identifier, must be "glm-5.2"
inputstringYesThe user's input/prompt
instructionsstringNoSystem instructions (similar to system prompt)
max_tokensintegerNoMaximum tokens in the response
streambooleanNoEnable streaming (default: false)

Response (non-streaming)

{
  "id": "response_...",
  "object": "response",
  "created": 1234567890,
  "model": "glm-5.2",
  "output_text": "The response text here.",
  "status": "completed",
  "finish_reason": "stop"
}

Response (streaming)

With stream: true, the endpoint returns server-sent events:

event: response.created
data: {"id":"response_...","object":"response","created":1234567890,"model":"glm-5.2"}

event: response.output_text.delta
data: {"object":"response.delta","delta":{"output_text":"The "}}

event: response.output_text.delta
data: {"object":"response.delta","delta":{"output_text":"response "}}

event: response.completed
data: {"object":"response.completed","id":"response_...","status":"completed","finish_reason":"stop"}

Examples

Simple text request

curl https://api.runars.ca/v1/responses \
  -H "Authorization: Bearer sk-runars-..." \
  -H "content-type: application/json" \
  -d '{
    "model": "glm-5.2",
    "input": "What is the capital of France?"
  }'

With instructions

curl https://api.runars.ca/v1/responses \
  -H "Authorization: Bearer sk-runars-..." \
  -H "content-type: application/json" \
  -d '{
    "model": "glm-5.2",
    "instructions": "You are a helpful assistant. Keep responses concise.",
    "input": "Explain quantum computing in one sentence."
  }'

Using the OpenAI SDK

import OpenAI from "openai"

const openai = new OpenAI({
  baseURL: "https://api.runars.ca/v1",
  apiKey: process.env.OPENAI_API_KEY,
})

const response = await openai.beta.responses.create({
  model: "glm-5.2",
  input: "Tell me a short story about a robot.",
  max_tokens: 500,
})

console.log(response.output_text)

Streaming

const stream = await openai.beta.responses.create({
  model: "glm-5.2",
  input: "Tell me a short story about a robot.",
  stream: true,
})

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

Add OpenAI's web search tool and Runars executes the searches gateway-side:

{
  "model": "glm-5.2",
  "input": "What happened in the news today?",
  "tools": [
    {
      "type": "web_search",
      "search_context_size": "medium",
      "filters": { "allowed_domains": ["example.com"] }
    }
  ]
}
  • Output: web_search_call items (action.type: "search" with the query) precede the message item; the message's output_text carries url_citation annotations for the sources used.
  • Usage: usage.web_search_requests reports the executed-search count.
  • Options: search_context_size (low/medium/high → how many results the model sees), filters.allowed_domains / blocked_domains, and user_location are honored. web_search_preview is accepted as an alias.
  • Billing: $10 / 1,000 executed searches (standard rate) plus normal token costs; errored searches are not billed. Rounds of web_search_call items in follow-up input are accepted and skipped.

Comparison to /v1/chat/completions

AspectChat CompletionsResponses
Request formatmessages arrayinput string + instructions
Response formatchoices[0].message.contentoutput_text
Multi-turn✅ (via message history)⚠️ (requires manual state)
Tool calling
Streaming eventschat.completion.chunkresponse.* events

Use /v1/responses if:

  • You prefer the simpler input/output_text API shape
  • You're porting code from a different API that uses this format
  • You don't need tool calling

Use /v1/chat/completions if:

  • You need tool calling
  • You're building multi-turn conversations
  • You're using the OpenAI SDK

Error responses

400 Bad Request

Missing required field:

{
  "error": {
    "message": "Invalid request: missing required field 'input'",
    "type": "invalid_request_error"
  }
}

401 Unauthorized

Invalid or missing API key:

{
  "error": {
    "message": "Unauthorized",
    "type": "invalid_request_error",
    "code": "invalid_api_key"
  }
}

429 Too Many Requests

Rate limit exceeded:

{
  "error": {
    "message": "Rate limit exceeded",
    "type": "server_error",
    "code": "insufficient_quota"
  }
}

Future roadmap

Tool calling support is planned for this endpoint. In the meantime, use /v1/chat/completions or /v1/messages if you need tools.

On this page