Responses API (OpenAI)
Use the OpenAI Responses API at POST /v1/responses. Input items, instructions, function tools, reasoning effort, streaming events, and current limitations.
Use this page with an AI assistant
Opens a new chat with this docs URL and the correct AICredits base URLs.
POST https://api.aicredits.in/v1/responses accepts requests in the OpenAI Responses API format. It works with the OpenAI SDK (client.responses.create), the OpenAI Agents SDK, and tools such as n8n.
curl https://api.aicredits.in/v1/responses \
-H "Authorization: Bearer sk-your-key-here" \
-H "Content-Type: application/json" \
-d '{
"model": "openai/gpt-4o-mini",
"instructions": "You are a concise assistant.",
"input": "Explain UPI in one sentence."
}'from openai import OpenAI
client = OpenAI(
base_url="https://api.aicredits.in/v1",
api_key="sk-your-key-here",
)
response = client.responses.create(
model="openai/gpt-4o-mini",
instructions="You are a concise assistant.",
input="Explain UPI in one sentence.",
)
print(response.output_text)import OpenAI from "openai";
const client = new OpenAI({
baseURL: "https://api.aicredits.in/v1",
apiKey: "sk-your-key-here",
});
const response = await client.responses.create({
model: "openai/gpt-4o-mini",
instructions: "You are a concise assistant.",
input: "Explain UPI in one sentence.",
});
console.log(response.output_text);How requests are handled
- OpenAI models are forwarded to OpenAI's Responses API as-is, so the OpenAI feature set for that model applies.
- All other models (Claude, Gemini, and so on) are served through a conversion layer: the request is translated to chat format, run through the normal routing and billing pipeline, and the answer is translated back to Responses format. Only the features listed below are supported on this path.
Billing is the same on both paths: token usage converted to INR with your markup, deducted from your wallet.
Supported fields
| Field | Notes |
|---|---|
model | Required. |
input | A string, or an array of items (see below). |
instructions | Becomes the system prompt. |
max_output_tokens | Maximum tokens to generate. |
temperature, top_p, seed, stop, presence_penalty, frequency_penalty, user | Carried through. |
tools | Function tools: {"type": "function", "name": ..., "description": ..., "parameters": ...}. |
tool_choice | "auto", "none", "required", or {"type": "function", "name": "..."}. |
reasoning.effort | Mapped to reasoning effort on models that support it. |
stream | true for server-sent events. |
Input items
When input is an array it may contain:
- Messages (
rolepluscontent), withinput_text,output_text, andinput_imagecontent parts. function_callitems from a previous turn. Consecutive items are grouped into one assistant turn with parallel tool calls.function_call_outputitems carrying theoutputfor acall_id.
Function calling
The model returns function_call output items with call_id, name, and arguments. Run the function, then send the call and its result back as input items.
tools = [{
"type": "function",
"name": "get_weather",
"description": "Get the weather for a city",
"parameters": {
"type": "object",
"properties": {"city": {"type": "string"}},
"required": ["city"],
},
}]
first = client.responses.create(
model="anthropic/claude-sonnet-4.6",
input="Weather in Mumbai?",
tools=tools,
)
call = next(item for item in first.output if item.type == "function_call")
second = client.responses.create(
model="anthropic/claude-sonnet-4.6",
tools=tools,
input=[
{"role": "user", "content": "Weather in Mumbai?"},
{"type": "function_call", "call_id": call.call_id, "name": call.name, "arguments": call.arguments},
{"type": "function_call_output", "call_id": call.call_id, "output": "31C, humid"},
],
)
print(second.output_text)Streaming
With stream: true you receive Responses-style server-sent events. For non-OpenAI models the stream includes response.created, response.output_item.added, response.content_part.added, response.output_text.delta, response.output_text.done, response.content_part.done, response.function_call_arguments.delta, response.function_call_arguments.done, response.output_item.done, and a final response.completed event carrying usage. For OpenAI models the upstream event stream is passed through unchanged.
Response and usage
The response is a response object with an output array of message and function_call items, plus usage with input_tokens, output_tokens, and total_tokens.
Retrieving stored responses
Responses created on OpenAI models through AICredits can be fetched, cancelled, or deleted later by id. These calls are forwarded to OpenAI and are free (not billed).
| Method | Path | Purpose |
|---|---|---|
GET | /v1/responses/{id} | Retrieve a stored response |
DELETE | /v1/responses/{id} | Delete a stored response |
POST | /v1/responses/{id}/cancel | Cancel a response that is still running |
curl https://api.aicredits.in/v1/responses/resp_abc123 \
-H "Authorization: Bearer sk-your-key-here"- Ids start with
resp_. Any other well-formed id returns404, and a malformed id returns400. - Only the account that created a response can retrieve, cancel, or delete it. Anyone else, and any unknown id, gets
404. - Responses from non-OpenAI models are not stored and cannot be retrieved.
- If the ownership store is temporarily unavailable, the call returns
503. Retry shortly.
Limitations
- No server-side conversation state on non-OpenAI models.
previous_response_idandstoreare not supported on the conversion path. Resend the full conversation ininputon every request, and do not depend on stored responses. - Reasoning items and summaries are not supported on the conversion path.
reasoningitems ininputare dropped, andreasoning.summaryis ignored. Onlyreasoning.effortis mapped. - Hosted tools are OpenAI-only. Web search, file search, code interpreter, computer use, and remote MCP tools are not available for non-OpenAI models. On those models only function tools are supported.
- Usage detail is minimal on the conversion path. Usage reports input, output, and total tokens only.
- Request body: 10 MB maximum.
If you need the broadest provider compatibility, Chat Completions is the most fully featured surface.