Create a model response
client.responses.create(ResponseCreateParamsbody , RequestOptionsoptions ?): Response { id, access_programs, created_at, 36 more } | Stream<ResponseStreamEvent>
POST
/responsesCreates a model response. Provide text or image inputs to generate text or JSON outputs. Have the model call your own custom code or use built-in tools like web search or file search to use your own data as input for the model’s response.
Create a model response
import OpenAI from "openai";
const openai = new OpenAI();
const response = await openai.responses.create({
model: "gpt-6.2-astra",
input: [
{
role: "user",
content: [
{ type: "input_text", text: "what is in this file?" },
{
type: "input_file",
file_url: "https://www.berkshirehathaway.com/letters/2024ltr.pdf",
detail: "auto",
},
],
},
],
});
console.log(response);
Response example
{
"id": "resp_686eef60237881a2bd1180bb8b13de430e34c516d176ff86",
"object": "response",
"access_programs": null,
"created_at": 1752100704,
"status": "completed",
"completed_at": 1752100705,
"background": false,
"error": null,
"incomplete_details": null,
"instructions": null,
"max_output_tokens": null,
"max_tool_calls": null,
"model": "gpt-6.2-astra",
"output": [
{
"id": "msg_686eef60d3e081a29283bdcbc4322fd90e34c516d176ff86",
"type": "message",
"status": "completed",
"content": [
{
"type": "output_text",
"annotations": [],
"logprobs": [],
"text": "The file seems to contain excerpts from a letter to the shareholders of Berkshire Hathaway Inc., likely written by Warren Buffett. It covers several topics:\n\n1. **Communication Philosophy**: Buffett emphasizes the importance of transparency and candidness in reporting mistakes and successes to shareholders.\n\n2. **Mistakes and Learnings**: The letter acknowledges past mistakes in business assessments and management hires, highlighting the importance of correcting errors promptly.\n\n3. **CEO Succession**: Mention of Greg Abel stepping in as the new CEO and continuing the tradition of honest communication.\n\n4. **Pete Liegl Story**: A detailed account of acquiring Forest River and the relationship with its founder, highlighting trust and effective business decisions.\n\n5. **2024 Performance**: Overview of business performance, particularly in insurance and investment activities, with a focus on GEICO's improvement.\n\n6. **Tax Contributions**: Discussion of significant tax payments to the U.S. Treasury, credited to shareholders' reinvestments.\n\n7. **Investment Strategy**: A breakdown of Berkshire\u2019s investments in both controlled subsidiaries and marketable equities, along with a focus on long-term holding strategies.\n\n8. **American Capitalism**: Reflections on America\u2019s economic development and Berkshire\u2019s role within it.\n\n9. **Property-Casualty Insurance**: Insights into the P/C insurance business model and its challenges and benefits.\n\n10. **Japanese Investments**: Information about Berkshire\u2019s investments in Japanese companies and future plans.\n\n11. **Annual Meeting**: Details about the upcoming annual gathering in Omaha, including schedule changes and new book releases.\n\n12. **Personal Anecdotes**: Light-hearted stories about family and interactions, conveying Buffett's personable approach.\n\n13. **Financial Performance Data**: Tables comparing Berkshire\u2019s annual performance to the S&P 500, showing impressive long-term gains.\n\nOverall, the letter reinforces Berkshire Hathaway's commitment to transparency, investment in both its businesses and the wider economy, and emphasizes strong leadership and prudent financial management."
}
],
"role": "assistant"
}
],
"parallel_tool_calls": true,
"previous_response_id": null,
"reasoning": {
"effort": null,
"summary": null
},
"service_tier": "default",
"store": true,
"temperature": 1.0,
"text": {
"format": {
"type": "text"
}
},
"tool_choice": "auto",
"tools": [],
"top_logprobs": 0,
"top_p": 1.0,
"truncation": "disabled",
"usage": {
"input_tokens": 8438,
"input_tokens_details": {
"cached_tokens": 0,
"cache_write_tokens": 0
},
"output_tokens": 398,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 8836
},
"user": null,
"metadata": {}
}
Returns Examples
200 — Example
{
"id": "id",
"access_programs": {
"cyber": "standard"
},
"created_at": 0,
"error": {
"code": "server_error",
"message": "message",
"misalignment": {
"detailed_explanation": "detailed_explanation",
"error_type": "potentially_unintended_data_transfer",
"review_target": "review_target",
"steer": {
"message": "message"
}
},
"param": "param",
"type": "type"
},
"incomplete_details": {
"reason": "max_output_tokens"
},
"instructions": "string",
"metadata": {
"foo": "string"
},
"model": "gpt-6.2-astra",
"object": "response",
"output": [
{
"id": "id",
"content": [
{
"annotations": [
{
"file_id": "file_id",
"filename": "filename",
"index": 0,
"type": "file_citation"
}
],
"text": "text",
"type": "output_text",
"logprobs": [
{
"token": "token",
"bytes": [
0
],
"logprob": 0,
"top_logprobs": [
{
"token": "token",
"bytes": [
0
],
"logprob": 0
}
]
}
]
}
],
"role": "assistant",
"status": "in_progress",
"type": "message",
"phase": "commentary"
}
],
"parallel_tool_calls": true,
"temperature": 1,
"tool_choice": "none",
"tools": [
{
"name": "name",
"parameters": {
"foo": "bar"
},
"strict": true,
"type": "function",
"allowed_callers": [
"direct"
],
"async": true,
"defer_loading": true,
"description": "description",
"output_schema": {
"foo": "bar"
}
}
],
"top_p": 1,
"background": true,
"completed_at": 0,
"conversation": {
"id": "id"
},
"image": {
"context_compression": "enabled"
},
"input_transformations": [
{
"id": "id",
"action": "removed",
"reason": "organization_mismatch",
"type": "reasoning"
}
],
"max_output_tokens": 0,
"max_tool_calls": 0,
"moderation": {
"input": {
"categories": {
"foo": true
},
"category_applied_input_types": {
"foo": [
"text"
]
},
"category_scores": {
"foo": 0
},
"flagged": true,
"model": "model",
"type": "moderation_result"
},
"output": {
"categories": {
"foo": true
},
"category_applied_input_types": {
"foo": [
"text"
]
},
"category_scores": {
"foo": 0
},
"flagged": true,
"model": "model",
"type": "moderation_result"
}
},
"output_text": "output_text",
"previous_response_id": "previous_response_id",
"prompt": {
"id": "id",
"variables": {
"foo": "string"
},
"version": "version"
},
"prompt_cache_diagnostics": {
"cache_missed_tokens": 0,
"reason": "model_changed",
"type": "cache_miss",
"comparison_reusable_tokens": 0
},
"prompt_cache_key": "prompt-cache-key-1234",
"prompt_cache_options": {
"mode": "implicit",
"ttl": "30m",
"comparison_response_id": "comparison_response_id"
},
"prompt_cache_retention": "in_memory",
"reasoning": {
"context": "auto",
"effort": "none",
"generate_summary": "auto",
"mode": "standard",
"summary": "auto"
},
"safety_identifier": "safety-identifier-1234",
"service_tier": "auto",
"status": "completed",
"text": {
"format": {
"type": "text"
},
"verbosity": "low"
},
"tool_usage": {
"image_gen": {
"input_tokens": 0,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 0
},
"output_tokens": 0,
"total_tokens": 0,
"cached_tokens": 0,
"cached_tokens_details": {
"cached_image_tokens": 0,
"cached_text_tokens": 0
},
"output_tokens_details": {
"image_tokens": 0,
"text_tokens": 0
}
},
"web_search": {
"num_requests": 0
}
},
"top_logprobs": 0,
"truncation": "auto",
"usage": {
"input_tokens": 0,
"input_tokens_details": {
"cache_write_tokens": 0,
"cached_tokens": 0,
"cache_write_tokens_details": {
"ttl_12h_tokens": 0,
"ttl_30m_tokens": 0
}
},
"output_tokens": 0,
"output_tokens_details": {
"reasoning_tokens": 0
},
"total_tokens": 0
},
"user": "user-1234"
}