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/responsesRequest Body
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID to use |
input | string/array | Yes | Input text or messages |
instructions | string | No | System instructions |
temperature | number | No | Sampling temperature |
max_output_tokens | integer | No | Maximum tokens to generate |
tools | array | No | Available tools |
response_format | object | No | Output 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
)Related
- Chat Completions - Primary chat API
- Models - Available models
How is this guide?
Reasoning Models
OpenAI o1, o3 Reasoning API - Advanced AI reasoning for math, coding, and complex problems. Access reasoning models through UniterRouter with extended thinking and chain-of-thought.
Embeddings POST
OpenAI Embeddings API - Generate text-embedding-3-large, ada-002 vectors through UniterRouter. Build semantic search, RAG applications with unified embedding API.