Responses
Generate text with any text model using the OpenAI Responses API. This endpoint is a drop-in for client.responses.create(...) — point the OpenAI SDK at ImageRouter by changing the base URL. You are billed on the true token cost of each request.
curl 'https://api.imagerouter.io/v1/openai/responses' \-H 'Authorization: Bearer YOUR_API_KEY' \--json '{ "model": "openai/gpt-4o-mini", "input": "Write a haiku about the ocean."}'import OpenAI from 'openai'
const client = new OpenAI({apiKey: 'YOUR_API_KEY',baseURL: 'https://api.imagerouter.io/v1/openai',})
const response = await client.responses.create({model: 'openai/gpt-4o-mini',input: 'Write a haiku about the ocean.',})
console.log(response.output_text)from openai import OpenAI
client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.imagerouter.io/v1/openai",)
response = client.responses.create( model="openai/gpt-4o-mini", input="Write a haiku about the ocean.",)
print(response.output_text)Streaming
Section titled “Streaming”Set stream: true to receive a Server-Sent Events stream of Responses API events. The stream is proxied unchanged, and the final response.completed event carries token usage and the true cost.
curl 'https://api.imagerouter.io/v1/openai/responses' \-H 'Authorization: Bearer YOUR_API_KEY' \--json '{ "model": "openai/gpt-4o-mini", "input": "Write a haiku about the ocean.", "stream": true}'import OpenAI from 'openai'
const client = new OpenAI({apiKey: 'YOUR_API_KEY',baseURL: 'https://api.imagerouter.io/v1/openai',})
const stream = await client.responses.create({model: 'openai/gpt-4o-mini',input: 'Write a haiku about the ocean.',stream: true,})
for await (const event of stream) {if (event.type === 'response.output_text.delta') process.stdout.write(event.delta)}from openai import OpenAI
client = OpenAI( api_key="YOUR_API_KEY", base_url="https://api.imagerouter.io/v1/openai",)
stream = client.responses.create( model="openai/gpt-4o-mini", input="Write a haiku about the ocean.", stream=True,)
for event in stream: if event.type == "response.output_text.delta": print(event.delta, end="")Parameters
Section titled “Parameters”-
modelrequired Text model to use for the response. -
inputrequired The prompt. Either a plain string or an array of input items in OpenAI Responses format. -
streamoptional Whentrue, response events are streamed as Server-Sent Events. Defaults tofalse. -
instructions,max_output_tokens,temperature,top_p,tools,tool_choice,reasoning,text, … optional All standard OpenAI Responses parameters are passed through to the model unchanged.
Response
Section titled “Response”{ "id": "resp_...", "object": "response", "created_at": 1234567890, "model": "openai/gpt-4o-mini", "output": [ { "type": "message", "role": "assistant", "content": [{ "type": "output_text", "text": "..." }] } ], "usage": { "input_tokens": 12, "output_tokens": 24, "total_tokens": 36, "cost": 0.0000123 }, "cost": 0.0001}usage.cost is the true upstream cost in USD. The top-level cost field is what was charged to your ImageRouter credits (the true cost, rounded up to the nearest 1/10,000 USD).