Responses API
The OpenAI Responses format, for the OpenAI SDKs, Codex CLI and other tools that use /v1/responses.
Endpoint
POST https://freemodel.in/v1/responses
Send your key as Authorization: Bearer fm_…. The key needs the inference scope. Any listed model can be used, with the same plan rules as chat completions; free accounts can use the free models such as gpt-6-luna.
Quick example
curl https://freemodel.in/v1/responses \
-H "Authorization: Bearer fm_your_key_here" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-6-luna",
"instructions": "Answer in one sentence.",
"input": "What is a context window?"
}'
from openai import OpenAI
client = OpenAI(api_key="fm_your_key_here", base_url="https://freemodel.in/v1")
resp = client.responses.create(
model="gpt-6-luna",
instructions="Answer in one sentence.",
input="What is a context window?",
)
print(resp.output_text)
Request fields
| Field | Type | Notes |
|---|---|---|
model | string | A listed model id. Required in practice: without it the request is refused with 404 model_not_found. |
input | string or array | Required. A string is one user message; an array holds input items (below). |
instructions | string | System instructions, placed before the conversation. |
stream | bool | Stream server-sent events. Default false. |
max_output_tokens | int | Output limit. Values below 8,192 (or no value) are raised to 16,384, so reasoning models have room to answer. max_tokens is read too. |
temperature | number | Clamped to 0–2. |
top_p | number | Clamped to 0–1. |
tools | array | Function tools, either {"type":"function","name":…,"description":…,"parameters":{…}} or the chat-completions shape with a function object. |
tool_choice | string or object | Passed on when tools are present. |
parallel_tool_calls | bool | Passed on when tools are present. |
text.format | object | {"type":"json_object"} or {"type":"json_schema","name":…,"schema":{…},"strict":true}. See Structured output. |
previous_response_id | string | Continue from an earlier response (see below). |
store | bool | Default true. Set false and the conversation is not kept for previous_response_id. |
Other fields are ignored.
Input items
type | How it is used |
|---|---|
message (or any item with a role) | Roles user, assistant, system and developer (treated as system). Content may be a string or parts: input_text / output_text text, and input_image with an image_url (URL or data URL). |
function_call / function_call_output | A tool call made earlier and its result, matched by call_id. |
custom_tool_call / custom_tool_call_output | Same, for custom (free-text input) tools. |
local_shell_call / local_shell_call_output | Shell tool calls and results, as sent by Codex CLI. |
web_search_call | Kept as a note of the search query. |
reasoning, item_reference | Ignored. |
Images need a model with the Vision capability; see Vision.
Response
{
"id": "resp_3f1c9a0e5b7d2c4a6e8f0b1d",
"object": "response",
"created_at": 1795612800,
"status": "completed",
"model": "gpt-6-luna",
"output": [
{
"id": "msg_9b2e4f6a8c0d1e3f5a7b9c0d",
"type": "message",
"status": "completed",
"role": "assistant",
"content": [
{"type": "output_text", "text": "A context window is the maximum amount of text a model can read and write in one request.", "annotations": [], "logprobs": []}
]
}
],
"output_text": "A context window is the maximum amount of text a model can read and write in one request.",
"usage": {
"input_tokens": 31,
"input_tokens_details": {"cached_tokens": 0},
"output_tokens": 22,
"output_tokens_details": {"reasoning_tokens": 0},
"total_tokens": 53
}
}
output can also hold reasoning items (with a summary), function_call items (call_id, name, arguments), custom_tool_call, local_shell_call and web_search_call items. output_text is present on non-streamed responses.
Tool calling
tools = [{
"type": "function",
"name": "get_weather",
"description": "Current weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
}]
r1 = client.responses.create(model="gpt-6-luna", input="Weather in Pune?", tools=tools)
call = next(item for item in r1.output if item.type == "function_call")
r2 = client.responses.create(
model="gpt-6-luna",
previous_response_id=r1.id,
input=[{"type": "function_call_output", "call_id": call.call_id, "output": "31 °C, clear"}],
tools=tools,
)
print(r2.output_text)
Conversations with previous_response_id
When store is not false, the conversation of a successful response is kept for 7 days. Pass its id as previous_response_id and the stored turns are placed before your new input. Only the account that made the response can use it. An unknown or expired id is treated as no history, so for long-running work you can also send the full conversation in input yourself.
GET /v1/responses/{id} answers with a short object (id, object, status, created_at). It does not return the stored output.
Streaming
With "stream": true the response is a stream of server-sent events, each with an event: line and a JSON data: line carrying type and sequence_number:
| Event | When |
|---|---|
response.created, response.in_progress | At the start |
response.output_item.added / .done | An output item opens or closes |
response.content_part.added / .done | A text part opens or closes |
response.output_text.delta / .done | Answer text |
response.reasoning_summary_text.delta / .done | Reasoning summary text |
response.function_call_arguments.delta / .done | Tool call arguments |
response.completed | End, with the full response and usage |
response.failed | The request failed after the stream began |
stream = client.responses.create(model="gpt-6-luna", input="Count to five.", stream=True)
for event in stream:
if event.type == "response.output_text.delta":
print(event.delta, end="", flush=True)
Errors
Errors use the OpenAI shape. The ones specific to this endpoint:
| Status | Code | Cause |
|---|---|---|
| 400 | bad_request | Empty request body |
| 400 | invalid_json | Body is not JSON |
| 400 | missing_input | No usable input |
| 404 | model_not_found | Model id not listed, or no model sent |
Plan, key and rate limit errors are the same as on every endpoint; see Errors and status codes. Billing is the same as for chat completions: input plus output tokens times the model's multiplier, nothing for a failed request.