Use the OpenResponses API to generate text responses from AI models. The input array contains message objects with a role (user or assistant) and content field. The model processes the input and returns a response with the generated text.
Example request
import osimport requestsimport jsonurl ="https://llm.onerouter.pro/v1/responses"headers ={"Content-Type":"application/json","Authorization":"Bearer <API_KEY>",}data ={"model":"o4-mini","input":[{"type":"message","role":"user","content":"Why do developers prefer dark mode?",}],}response = requests.post(url,headers=headers,json=data)result = response.json()print(result)
Response format
The response includes the generated text in the output array, along with token usage information.
Image Input
The OpenResponses API supports sending images alongside text for vision-capable models to analyze. Include an image_url object in your message content array with either a public URL or a base64-encoded data URI. The detail parameter controls the resolution used for analysis.
Base64-encoded images
You can also use base64-encoded images:
Detail parameter
The detail parameter controls image resolution:
auto - Let the model decide the appropriate resolution
low - Use lower resolution for faster processing
high - Use higher resolution for more detailed analysis
{
'background': False,
'completed_at': 1771665090,
'created_at': 1771665084,
'error': None,
'frequency_penalty': 0,
'id': 'resp_07223b6d861d05ef00699976bc037481948075cde62d82e221',
'incomplete_details': None,
'instructions': None,
'max_output_tokens': None,
'max_tool_calls': None,
'metadata': {},
'model': 'o4-mini',
'object': 'response',
'output': [{
'id': 'rs_07223b6d861d05ef00699976bccb48819487f777752fc4925f',
'summary': [],
'type': 'reasoning'
}, {
'content': [{
'annotations': [],
'logprobs': [],
'text': 'Developers’ fondness for dark mode comes down to a mix of physiological, practical and even psychological factors. Some of the most commonly cited reasons:\n\n1. Reduced eye strain in low-light environments \n – A bright white screen in a dark room can feel harsh and cause glare. Dark backgrounds with lighter text are often perceived as gentler on the eyes when ambient light is low. \n – Less overall luminance can help prevent headaches and eye fatigue over long coding sessions.\n\n2. Better contrast for syntax highlighting \n – Modern code editors use multiple colors to distinguish keywords, strings, comments, etc. On a dark background, those hues often “pop” more distinctly, making it easier to scan and parse code structures quickly.\n\n3. Reduced blue-light exposure \n – Dark mode typically emits less overall blue light, which can interfere with circadian rhythms and keep you awake if you’re coding late at night.\n\n4. Battery savings on OLED/AMOLED screens \n – On these displays, black or very dark pixels are essentially “off” pixels, drawing less power. If you’re coding on a laptop or tablet running on battery, dark mode can eke out a bit more runtime.\n\n5. Minimized screen flicker and pulse perception \n – Some users who are sensitive to rapid backlight flicker find dark mode more comfortable, as it reduces the perceived pulse of a bright LCD backlight.\n\n6. Aesthetics and focus \n – Many developers simply “like the look” of dark themes—it feels more modern, sleek or immersive. That sense of immersion can help with focus and flow when you’re debugging or deep-diving into logic.\n\n7. Community and tooling momentum \n – Once a few popular editors (VS Code, JetBrains IDEs, etc.) introduced polished dark themes, the rest of the ecosystem followed. Code samples and screenshots on blogs and Stack Overflow often assume a dark theme, which reinforces its popularity.\n\n8. Personal preference and habit \n – At the end of the day, it often boils down to individual comfort. If you started out working in a dark-mode editor and find it soothing, you’ll set your other tools to match.\n\nCaveat: In very bright environments (e.g. outdoors or under strong overhead office lighting), a dark UI can become harder to read. Some developers switch dynamically—dark mode at night, light mode during the day. Ultimately, it’s less about objective “rightness” and more about finding what keeps you comfortable, focused and productive over long coding sessions.',
'type': 'output_text'
}],
'id': 'msg_07223b6d861d05ef00699976be60988194aa6ebc90f21a1c18',
'role': 'assistant',
'status': 'completed',
'type': 'message'
}],
'parallel_tool_calls': True,
'presence_penalty': 0,
'previous_response_id': None,
'prompt_cache_key': None,
'prompt_cache_retention': None,
'reasoning': {
'effort': 'medium',
'summary': None
},
'safety_identifier': None,
'service_tier': 'default',
'status': 'completed',
'store': True,
'temperature': 1,
'text': {
'format': {
'type': 'text'
},
'verbosity': 'medium'
},
'tool_choice': 'auto',
'tools': [],
'top_logprobs': 0,
'top_p': 1,
'truncation': 'disabled',
'usage': {
'input_tokens': 13,
'input_tokens_details': {
'cached_tokens': 0
},
'output_tokens': 720,
'output_tokens_details': {
'reasoning_tokens': 192
},
'total_tokens': 733
},
'user': None
}