UniterRouter
API ReferenceOpenAI Compatible

Responses

OpenAI Responses API - New conversation format for GPT-4, GPT-4o with built-in tool handling. Simplified API for multi-turn conversations and agent workflows.

Responses API

The Responses API is OpenAI's newer format for creating AI responses. UniterRouter fully supports this API format.

Chat Completions vs Responses: The Responses API is OpenAI's newer format. For most use cases, Chat Completions remains the recommended approach.

Endpoint

POST https://api.uniterouter.ai/v1/responses

Request Body

ParameterTypeRequiredDescription
modelstringYesModel ID to use
inputstring/arrayYesInput text or messages
instructionsstringNoSystem instructions
temperaturenumberNoSampling temperature
max_output_tokensintegerNoMaximum tokens to generate
toolsarrayNoAvailable tools
response_formatobjectNoOutput format specification

Example Request

curl https://api.uniterouter.ai/v1/responses \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $UNITEROUTER_API_KEY" \
  -d '{
    "model": "gpt-4o",
    "input": "What is the capital of France?",
    "instructions": "You are a helpful assistant."
  }'
from openai import OpenAI

client = OpenAI(
    base_url="https://api.uniterouter.ai/v1",
    api_key="your_uniterouter_api_key",
)

response = client.responses.create(
    model="gpt-4o",
    input="What is the capital of France?",
    instructions="You are a helpful assistant."
)

print(response.output_text)
import OpenAI from "openai";

const client = new OpenAI({
  baseURL: "https://api.uniterouter.ai/v1",
  apiKey: process.env.UNITEROUTER_API_KEY,
});

const response = await client.responses.create({
  model: "gpt-4o",
  input: "What is the capital of France?",
  instructions: "You are a helpful assistant."
});

console.log(response.output_text);

Response

{
  "id": "resp_abc123",
  "object": "response",
  "created_at": 1699000000,
  "model": "gpt-4o",
  "output": [
    {
      "type": "message",
      "role": "assistant",
      "content": [
        {
          "type": "output_text",
          "text": "The capital of France is Paris."
        }
      ]
    }
  ],
  "usage": {
    "input_tokens": 20,
    "output_tokens": 10,
    "total_tokens": 30
  }
}

Multi-turn Conversations

Include previous messages in the input:

response = client.responses.create(
    model="gpt-4o",
    input=[
        {"role": "user", "content": "Hi!"},
        {"role": "assistant", "content": "Hello! How can I help?"},
        {"role": "user", "content": "What's the weather like?"}
    ]
)

Tool Use

tools = [
    {
        "type": "function",
        "name": "get_weather",
        "description": "Get current weather",
        "parameters": {
            "type": "object",
            "properties": {
                "location": {"type": "string"}
            },
            "required": ["location"]
        }
    }
]

response = client.responses.create(
    model="gpt-4o",
    input="What's the weather in Tokyo?",
    tools=tools
)

How is this guide?