Responses
The OpenAI Responses endpoint used by Codex and similar tools.
The endpoint compatible with the OpenAI Responses API, OpenAI's newer unified interface. Codex and some other tools only support this endpoint.
POST https://tokenfunc.com/v1/responsescURL
curl https://tokenfunc.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-d '{
"model": "gpt-5",
"instructions": "You are a helpful assistant.",
"input": "Explain HTTP in one sentence."
}'Python
from openai import OpenAI
client = OpenAI(base_url="https://tokenfunc.com/v1", api_key="sk-xxxxxxxxxxxxxxxx")
resp = client.responses.create(
model="gpt-5",
instructions="You are a helpful assistant.",
input="Explain HTTP in one sentence.",
)
print(resp.output_text)Node.js
import OpenAI from 'openai'
const client = new OpenAI({ baseURL: 'https://tokenfunc.com/v1', apiKey: 'sk-xxxxxxxxxxxxxxxx' })
const resp = await client.responses.create({
model: 'gpt-5',
instructions: 'You are a helpful assistant.',
input: 'Explain HTTP in one sentence.',
})
console.log(resp.output_text)Request parameters
200
{
"id": "resp_abc123",
"object": "response",
"status": "completed",
"model": "gpt-5",
"output": [
{
"type": "message",
"role": "assistant",
"content": [
{
"type": "output_text",
"text": "HTTP is the protocol browsers and servers use to exchange web pages and other data."
}
]
}
],
"usage": { "input_tokens": 25, "output_tokens": 22, "total_tokens": 47 }
}The SDKs expose output_text, which joins all text output for you.
Response fields
Streaming
With stream: true you receive a series of events; the common ones are response.output_text.delta (text increments) and response.completed (the end, with the final usage).
cURL
curl https://tokenfunc.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-N \
-d '{"model": "gpt-5", "input": "Write a four-line poem about autumn", "stream": true}'Python
stream = client.responses.create(model="gpt-5", input="Write a four-line poem about autumn", stream=True)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)Node.js
const stream = await client.responses.create({
model: 'gpt-5',
input: 'Write a four-line poem about autumn',
stream: true,
})
for await (const event of stream) {
if (event.type === 'response.output_text.delta')
process.stdout.write(event.delta)
}Examples
Multi-turn chat
Put the whole conversation in the input array, each item a role + content:
cURL
curl https://tokenfunc.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-d '{
"model": "gpt-5",
"input": [
{"role": "user", "content": "Redis or Memcached?"},
{"role": "assistant", "content": "Pick Redis for rich data structures or persistence, Memcached for plain caching."},
{"role": "user", "content": "What if I need persistence?"}
]
}'Python
history = [{"role": "user", "content": "Redis or Memcached?"}]
resp = client.responses.create(model="gpt-5", input=history)
history.append({"role": "assistant", "content": resp.output_text})
history.append({"role": "user", "content": "What if I need persistence?"})
resp = client.responses.create(model="gpt-5", input=history)
print(resp.output_text)Reasoning effort
Reasoning models take reasoning.effort (none / minimal / low / medium / high / xhigh / max; supported values vary by model); higher is slower and uses more output tokens:
cURL
curl https://tokenfunc.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer sk-xxxxxxxxxxxxxxxx" \
-d '{
"model": "gpt-5",
"input": "Design the database tables for a URL shortener",
"reasoning": {"effort": "low"}
}'Python
resp = client.responses.create(
model="gpt-5",
input="Design the database tables for a URL shortener",
reasoning={"effort": "low"},
)
print(resp.output_text)Responses or Chat Completions?
- Tools that only support Responses, such as Codex: this endpoint is the only option.
- Your own code: either works. Chat Completions covers more models and has a more mature ecosystem, so prefer it unless you need Responses.