Summary
OpenAI has released the Responses API as the successor to the Chat Completions API. We should migrate OpenAIBackend (and OpenAIVisionBackend if applicable) to use the new API.
Current State
Both backends make direct URLSession requests to /v1/chat/completions with:
messages array (system + user roles)
response_format with json_schema for Structured Outputs
- Response parsing via
choices[0].message.content
Relevant files:
Sources/SwiftAutoGUI/OpenAIBackend.swift
Sources/SwiftAutoGUI/OpenAIVisionBackend.swift (shares schema and parsing logic)
Proposed Changes
Migrate to POST /v1/responses with:
| Chat Completions |
Responses API |
messages: [{role, content}] |
instructions + input |
response_format.json_schema |
text.format |
choices[0].message.content |
output array |
/v1/chat/completions |
/v1/responses |
Benefits
- Lower costs due to improved cache utilization
previous_response_id for stateful conversation management
- Built-in tools (web search, code interpreter, etc.) available for future use
- Better reasoning model integration
Notes
- The Chat Completions API is not deprecated yet, so this is not urgent
- No SDK dependency change needed — we use raw
URLSession calls
baseURL parameter should be updated to default to the new endpoint path
Summary
OpenAI has released the Responses API as the successor to the Chat Completions API. We should migrate
OpenAIBackend(andOpenAIVisionBackendif applicable) to use the new API.Current State
Both backends make direct
URLSessionrequests to/v1/chat/completionswith:messagesarray (system+userroles)response_formatwithjson_schemafor Structured Outputschoices[0].message.contentRelevant files:
Sources/SwiftAutoGUI/OpenAIBackend.swiftSources/SwiftAutoGUI/OpenAIVisionBackend.swift(shares schema and parsing logic)Proposed Changes
Migrate to
POST /v1/responseswith:messages: [{role, content}]instructions+inputresponse_format.json_schematext.formatchoices[0].message.contentoutputarray/v1/chat/completions/v1/responsesBenefits
previous_response_idfor stateful conversation managementNotes
URLSessioncallsbaseURLparameter should be updated to default to the new endpoint path