I created an example on the playground.
When you create something in the playground, you can grab the code for it with the “code” button on the upper-right.
curl
curl https://api.openai.com/v1/responses \
-H "Content-Type: application/json" \
-H "Authorization: Bearer $OPENAI_API_KEY" \
-d '{
"model": "gpt-4.1",
"input": [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Hello! What is your refund policy?"
}
]
},
{
"type": "function_call",
"call_id": "manualToolCall_6p9u46",
"name": "lookup_context",
"arguments": "{}"
},
{
"type": "function_call_output",
"call_id": "manualToolCall_6p9u46",
"output": "# Refunds\n\nRefunds are issued at our sole discretion if there are any quality issues with the product. Please reach out via the \"Contact Us\" page if you would like to request a refund."
}
],
"text": {
"format": {
"type": "text"
}
},
"reasoning": {},
"tools": [
{
"type": "function",
"name": "lookup_context",
"description": "Search the vector store for context related to the latest message.",
"parameters": {
"type": "object",
"properties": {},
"additionalProperties": false,
"required": []
},
"strict": true
}
],
"temperature": 1,
"max_output_tokens": 2048,
"top_p": 1,
"store": false
}'```
Python
from openai import OpenAI
client = OpenAI()
response = client.responses.create(
model="gpt-4.1",
input=[
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Hello! What is your refund policy?"
}
]
},
{
"type": "function_call",
"call_id": "manualToolCall_6p9u46",
"name": "lookup_context",
"arguments": "{}"
},
{
"type": "function_call_output",
"call_id": "manualToolCall_6p9u46",
"output": "# Refunds\n\nRefunds are issued at our sole discretion if there are any quality issues with the product. Please reach out via the \"Contact Us\" page if you would like to request a refund."
}
],
text={
"format": {
"type": "text"
}
},
reasoning={},
tools=[
{
"type": "function",
"name": "lookup_context",
"description": "Search the vector store for context related to the latest message.",
"parameters": {
"type": "object",
"properties": {},
"additionalProperties": False,
"required": []
},
"strict": True
}
],
temperature=1,
max_output_tokens=2048,
top_p=1,
store=False
)
node.js
import OpenAI from "openai";
const openai = new OpenAI({
apiKey: process.env.OPENAI_API_KEY,
});
const response = await openai.responses.create({
model: "gpt-4.1",
input: [
{
"role": "user",
"content": [
{
"type": "input_text",
"text": "Hello! What is your refund policy?"
}
]
},
{
"type": "function_call",
"call_id": "manualToolCall_6p9u46",
"name": "lookup_context",
"arguments": "{}"
},
{
"type": "function_call_output",
"call_id": "manualToolCall_6p9u46",
"output": "# Refunds\n\nRefunds are issued at our sole discretion if there are any quality issues with the product. Please reach out via the \"Contact Us\" page if you would like to request a refund."
}
],
text: {
"format": {
"type": "text"
}
},
reasoning: {},
tools: [
{
"type": "function",
"name": "lookup_context",
"description": "Search the vector store for context related to the latest message.",
"parameters": {
"type": "object",
"properties": {},
"additionalProperties": false,
"required": []
},
"strict": true
}
],
temperature: 1,
max_output_tokens: 2048,
top_p: 1,
store: false
});
I’m not sure where call_id
is supposed to come from. I presume you can just make something up.
EDIT: Remember to set tool_choice
to none
! I forgot to do this.