🤖 AI Tools
OpenAI Chat Completions to Responses API Migration Planner: messages to input Map, instructions Field, Function Tool Format Changes, Structured Output text.format, and State Choices
Plan a move from the OpenAI Chat Completions API to the Responses API: map messages to input and instructions, convert function tool definitions and tool call handling, move structured outputs to text.format, decide on previous_response_id and store, and set up a side by side test before switching traffic.
0Reviews
Prompt
Act as an LLM platform engineer who migrates production code from OpenAI Chat Completions to the Responses API, rewrites request and response handling, converts tool calling and structured outputs, and runs a shadow comparison before switching traffic. Inputs: - Language and SDK version (Python openai, Node openai, raw HTTP): [SdkAndLanguage] - Current Chat Completions request code or a redacted sample including messages, model, temperature, tools, and response_format: [CurrentRequest] - How the code reads the result today (choices[0].message.content, tool_calls, finish_reason, usage): [ResponseHandling] - Tools in use: your own function tools, and any wish to use built in tools such as web search or file search: [ToolsInUse] - Conversation state today (resend full history, a database of turns) and data retention needs: [StateAndRetention] - Traffic and risk tolerance for the cutover: [CutoverRisk] - Output format: [Format] Generate: 1. A field map from CurrentRequest: messages to input items, system or developer message to instructions, max_tokens to max_output_tokens, response_format to text.format, and any fields with no direct equivalent marked [confirm in API reference]. 2. A rewritten request for SdkAndLanguage using client.responses.create. 3. A response handling map from ResponseHandling: output_text for plain text, output items for function calls, status and incomplete details instead of finish_reason, and usage field names. 4. A function tool conversion for ToolsInUse: flattened definitions with type, name, description, parameters, and strict, plus how to return results as function_call_output items with the matching call_id. 5. A state decision from StateAndRetention: keep sending full history, or use previous_response_id with store, and what that means for retention. 6. A built in tools note if ToolsInUse asks for them, with cost and data handling questions to confirm. 7. A shadow test plan for CutoverRisk: send a sample of real requests to both APIs, compare outputs, tool call accuracy, latency, and token usage, then ramp traffic. 8. A rollback switch: a feature flag that routes back to Chat Completions. Constraints: - Do not invent parameter names, model names, prices, or deprecation dates. Mark uncertain ones [confirm in API reference]. - Keep any secret keys out of the examples. - Plain engineer tone. No em dashes.
Instructions
Replace every [bracket] with your details before running. Works on ChatGPT, Claude, and Gemini.
Generated Output
This image was generated using the prompt above.

Examples
Example Input
SdkAndLanguage: Python, openai package 1.x
CurrentRequest: client.chat.completions.create(model="gpt-4.1-mini", messages=[{"role":"system","content":"You are a support triage bot."},{"role":"user","content":ticket_text}], temperature=0.2, max_tokens=600, tools=[{"type":"function","function":{"name":"lookup_order","description":"Get order status","parameters":{"type":"object","properties":{"order_id":{"type":"string"}},"required":["order_id"]}}}], response_format={"type":"json_schema","json_schema":{"name":"triage","schema":TRIAGE_SCHEMA,"strict":True}})
ResponseHandling: reads choices[0].message.tool_calls, runs lookup_order, appends a role tool message, calls again, then json.loads(choices[0].message.content); logs usage.prompt_tokens and usage.completion_tokens
ToolsInUse: lookup_order only; no built in tools for now
StateAndRetention: we resend the full ticket thread every call; legal wants no stored conversation data on the vendor side beyond defaults
CutoverRisk: about 40k calls a day; want a two week shadow period
Format: field map, rewritten request, response map, tool conversion, state decision, shadow plan, rollbackExample Output
1) FIELD MAP
| Chat Completions | Responses API |
| messages (system) | instructions |
| messages (user, assistant) | input (list of message items) |
| max_tokens | max_output_tokens |
| temperature | temperature |
| tools[].function.{name, description, parameters} | tools[] flattened: type, name, description, parameters, strict |
| response_format json_schema | text.format with type json_schema, name, schema, strict |
| n | no direct equivalent [confirm in API reference] |
2) REWRITTEN REQUEST
resp = client.responses.create(
model="gpt-4.1-mini",
instructions="You are a support triage bot.",
input=[{"role": "user", "content": ticket_text}],
temperature=0.2,
max_output_tokens=600,
tools=[{"type": "function", "name": "lookup_order", "description": "Get order status",
"parameters": {"type": "object", "properties": {"order_id": {"type": "string"}},
"required": ["order_id"], "additionalProperties": False},
"strict": True}],
text={"format": {"type": "json_schema", "name": "triage", "schema": TRIAGE_SCHEMA, "strict": True}},
store=False,
)
3) RESPONSE HANDLING
- Plain text or JSON: resp.output_text, then json.loads
- Tool calls: loop resp.output, pick items with type "function_call"; each has name, arguments (JSON string), and call_id
- Finish state: resp.status and resp.incomplete_details instead of finish_reason
- Usage: usage.input_tokens and usage.output_tokens replace prompt_tokens and completion_tokens [confirm in API reference]
4) TOOL LOOP
calls = [o for o in resp.output if o.type == "function_call"]
follow_up = list(prior_input) + list(resp.output)
for c in calls:
result = lookup_order(**json.loads(c.arguments))
follow_up.append({"type": "function_call_output", "call_id": c.call_id, "output": json.dumps(result)})
resp2 = client.responses.create(model=..., instructions=..., input=follow_up, tools=..., text=..., store=False)
Strict tools need additionalProperties false and every property listed in required.
5) STATE DECISION
Keep resending the ticket thread and set store=False. previous_response_id depends on stored responses, which conflicts with the legal request. Confirm default retention and any zero data retention terms on your account [confirm with OpenAI account settings].
6) BUILT IN TOOLS
Not used now. If you add web search or file search later, confirm pricing and data handling first [confirm in API reference].
7) SHADOW PLAN
- Weeks 1 and 2: send 5 percent of calls to both APIs; serve Chat Completions results only.
- Compare: triage JSON field match rate, lookup_order call match, p95 latency, input and output tokens.
- Ramp: 10, 25, 50, 100 percent once match rate meets your own bar.
8) ROLLBACK
Flag TRIAGE_API=responses|chat in config. Rollback is one config change; keep the Chat Completions path in code for one release after 100 percent.