Responses API
The OpenAI Responses API, with stateful multi-turn conversations and Alvin auto-routing.
The Responses API is OpenAI's newer inference interface. It works across every provider in the catalog — pass any model ID, or elyxir-alvin to let Alvin route.
Endpoint
POST https://api.elyxir.ai/v1/responses
How it differs from Chat Completions
| Chat Completions | Responses | |
|---|---|---|
| Prompt field | messages array | input — string or array |
| System prompt | A system message | instructions |
| Multi-turn | Resend the full history | previous_response_id |
| Output cap | max_tokens | max_output_tokens |
| Streaming | Token deltas | Richer typed events |
The big practical win is previous_response_id: you continue a conversation by referencing the last response instead of resending every prior turn.
Body parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
model | string | Yes | Model ID, or elyxir-alvin for auto-routing |
input | string | array | Yes | A prompt string, or an array of {role, content} items |
instructions | string | No | System-level instructions |
temperature | number | No | Defaults to 0.7 |
max_output_tokens | integer | No | Cap on generated tokens |
stream | boolean | No | Stream the response. Defaults to false |
previous_response_id | string | No | Continue from an earlier response |
tools | array | No | Custom function tools — see below |
Roles accepted in a structured input are developer, user, and assistant.
Examples
curl -X POST https://api.elyxir.ai/v1/responses \
-H "Authorization: Bearer elyxir_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "elyxir-alvin",
"input": "Write a Python function to sort a list using merge sort",
"max_output_tokens": 2000
}'With system instructions
{
"model": "claude-sonnet-4-6",
"instructions": "You are a senior software engineer. Be concise and include code examples.",
"input": [
{"role": "user", "content": "How do I implement retry logic with exponential backoff?"}
],
"temperature": 0.3
}Continuing a conversation
Reference the previous response instead of resending the history:
{
"model": "gpt-4o",
"input": "Can you add error handling to that function?",
"previous_response_id": "resp_abc123"
}Tools
Custom function tools work as they do in the OpenAI API — send type: "function" entries in tools.
The built-in tool types (web_search, file_search, code_interpreter) are not supported here. If you send them they are stripped before the request reaches the model, silently — the call succeeds without them. For web-grounded answers use a Perplexity Sonar model, or enable web search in Alvin Studio.
Alvin routing
Set model to elyxir-alvin and the response carries the routing decision in X-Alvin-Model, X-Alvin-Task-Type and X-Alvin-Confidence headers, plus a routing field in the body. See Alvin routing.
Which should I use?
Use Chat Completions if you have existing OpenAI-compatible code, or you want the widest client-library support.
Use Responses for new work, especially long multi-turn conversations where previous_response_id saves you resending — and paying for — the whole history on every turn.
Related
- Chat Completions — the widely-supported alternative
- Models — discover available model IDs
- Error handling — status codes and retries