Responses API
Use the OpenAI Responses API endpoint with Token101 for agent-style workflows and structured outputs.
Overview
Token101 supports the OpenAI Responses API (/api/v1/responses), the same protocol used by OpenAI Codex CLI and other agent-oriented tools. The Responses API is designed for multi-step workflows where the model can reason, call tools, and produce structured outputs in a single request-response cycle.
The Responses API is a passthrough endpoint — Token101 authenticates, bills, and rate-limits your request, then forwards it to the upstream provider as-is. All Responses API features that your chosen model supports (tool calls, structured outputs, reasoning) work through Token101 without modification.
Endpoint
POST https://token.ppthub.shop/api/v1/responsesAuthentication
Include your Token101 API key in the Authorization header:
Authorization: Bearer sk-your-token101-api-keyQuick Example
curl
curl https://token.ppthub.shop/api/v1/responses \
--request POST \
--header "Content-Type: application/json" \
--header "Authorization: Bearer $TOKEN101_API_KEY" \
--data '{
"model": "gpt-5.2",
"input": "What are the three laws of robotics?"
}'Python (OpenAI SDK)
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["TOKEN101_API_KEY"],
base_url="https://token.ppthub.shop/api/v1",
)
response = client.responses.create(
model="gpt-5.2",
input="What are the three laws of robotics?",
)
print(response.output_text)Node.js / TypeScript (OpenAI SDK)
import OpenAI from 'openai';
const client = new OpenAI({
apiKey: process.env.TOKEN101_API_KEY!,
baseURL: 'https://token.ppthub.shop/api/v1',
});
const response = await client.responses.create({
model: 'gpt-5.2',
input: 'What are the three laws of robotics?',
});
console.log(response.output_text);Request Fields
The Responses API accepts the standard OpenAI Responses API request format. Key fields:
| Field | Type | Description |
|---|---|---|
model | string | Required. Model ID (e.g., gpt-5.2, gpt-5.3-codex) |
input | string or array | Required. User input — a simple string or structured message array |
instructions | string | Optional. System-level instructions |
max_output_tokens | integer | Optional. Maximum tokens in the response (default: 4096) |
stream | boolean | Optional. Enable streaming (default: false) |
tools | array | Optional. Tool definitions the model can invoke |
temperature | number | Optional. Sampling temperature |
top_p | number | Optional. Nucleus sampling parameter |
For the complete field reference, see the API Reference.
Streaming
Set stream: true to receive Server-Sent Events (SSE) as the response is generated:
response = client.responses.create(
model="gpt-5.2",
input="Explain quantum computing in simple terms.",
stream=True,
)
for event in response:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)Streaming events follow the OpenAI Responses API format — response.created, response.output_item.added, response.output_text.delta, response.completed, and others.
Supported Models
The following models support the Responses API endpoint:
| Model | Model ID | Best For |
|---|---|---|
| GPT-5.4 | gpt-5.4 | General reasoning, prompt caching |
| GPT-5.2 | gpt-5.2 | Balanced performance |
| GPT-5.3 Codex | gpt-5.3-codex | Code generation and editing |
See Supported Models for the full list including non-OpenAI models.
How It Works
When you send a request to /api/v1/responses:
- Token101 validates your API key and checks rate limits and billing
- The request body is forwarded to the upstream model provider by Token101's routing layer
- The upstream provider processes the Responses API request natively
- The response (streaming or non-streaming) passes back through Token101 to your client
Token101 preserves the full Responses API contract — tool calls, structured outputs, reasoning tokens, and streaming all work as expected with supported models.
Comparison with Other Endpoints
| Feature | /api/v1/messages | /api/v1/chat/completions | /api/v1/responses |
|---|---|---|---|
| Protocol | Anthropic Messages | OpenAI Chat Completions | OpenAI Responses |
| SDK | Anthropic SDK | OpenAI SDK | OpenAI SDK |
| Base URL | https://token.ppthub.shop/api | https://token.ppthub.shop/api/v1 | https://token.ppthub.shop/api/v1 |
| Best for | Anthropic ecosystem | Chat applications | Agent workflows, Codex CLI |
| Tool calling | ✅ Anthropic format | ✅ OpenAI format | ✅ OpenAI format |
| Streaming | ✅ | ✅ | ✅ |
Known Limitations
- Server-side tool execution: Token101's Responses API is a passthrough adapter. Server-side tools (e.g., web search, file search) rely on the upstream provider's native support.
- Model availability: Only OpenAI models currently support the Responses API natively. Other models (Claude, Gemini, Qwen) should use the Messages or Chat Completions endpoints instead.
- Reasoning token billing: Reasoning tokens generated through the Responses API receive the same automatic discounts as other endpoints (Codex series 50% off, non-Codex GPT 25% off the output rate). See Billing for details.
Troubleshooting
401 Unauthorized
Check that your API key is set and valid. See Authentication for details.
404 Not Found on /api/v1/responses
Confirm your base URL is correct:
# Correct
export OPENAI_BASE_URL="https://token.ppthub.shop/api/v1"
# Wrong — do not include /responses in the base URL
export OPENAI_BASE_URL="https://token.ppthub.shop/api/v1/responses"400 Invalid model
The model you specified may not support the Responses API. Use one of the model IDs listed in the Supported Models table above.
Model returns unexpected format
Some older OpenAI models may not fully support the Responses API format. Try using a newer model like gpt-5.2 or gpt-5.3-codex.
Next Steps
- Codex CLI Integration — use Codex CLI with Token101
- Supported Models — full list of available models
- Streaming — streaming guide for all endpoints
- API Reference — full endpoint documentation