Endpoint tương thích OpenAI Responses API, dùng cho Codex CLI bản mới và client.responses.create() của SDK OpenAI. Đổi base URL thành https://api.goiapi.com/v1 và dùng API key của bạn. Mọi model trong Models đều gọi được qua endpoint này, kể cả model không phải của OpenAI.
POST https://api.goiapi.com/v1/responsesBody
Bắt buộc có model và input (chuỗi, hoặc danh sách tin nhắn và item như Codex gửi).
curl https://api.goiapi.com/v1/responses \
-H "Authorization: Bearer <API_KEY>" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-haiku-5-5",
"instructions": "Trả lời ngắn gọn",
"input": "Viết hàm Python đảo ngược chuỗi",
"max_output_tokens": 1024
}'Nên đặt max_output_tokens: hệ thống tạm giữ tiền theo con số này trước khi gọi model. Xem Giới hạn và số dư.
Được hỗ trợ
instructions,inputdạng chuỗi hoặc danh sách: tin nhắnuser,assistant,system,developervới nội dunginput_text,output_text,input_image(URL hoặc base64),input_file(base64).- Gọi tool:
toolskiểufunctionvàcustom(ví dụapply_patchcủa Codex),tool_choice,parallel_tool_calls; tronginputcófunction_call,function_call_output,custom_tool_call,custom_tool_call_output. reasoning.effort; phần suy luận model trả về nằm trong itemreasoning(mụcsummary).max_output_tokens,temperature,top_p,text.format(json_object,json_schema),prompt_cache_key.- Stream (
"stream": true): các sự kiệnresponse.created,response.output_item.added,response.output_text.delta,response.function_call_arguments.delta,response.reasoning_summary_text.delta,response.output_item.done, rồiresponse.completed(hoặcresponse.incompletekhi chạmmax_output_tokens). usagetrả về theo chuẩn Responses (input_tokens,output_tokens,input_tokens_details.cached_tokens…).
Chưa hỗ trợ
Hệ thống không lưu response, nên mỗi lần gọi phải gửi đủ hội thoại trong input (Codex CLI vốn làm vậy).
previous_response_id,conversation,prompt,background: true, itemitem_reference: trả lỗi400.- Tool dựng sẵn của OpenAI (
web_search,file_search,local_shell,code_interpreter,computer_use,mcp,image_generation): được bỏ qua, model không thấy các tool này. - Item
reasoninggửi lại tronginputvàencrypted_content: được bỏ qua. - Ảnh hoặc file theo
file_id: trả lỗi400, hãy gửi URL hoặc dữ liệu base64. GET /v1/responses/{id}, hủy hay xóa response.
Lỗi
Lỗi trước khi bắt đầu trả lời có dạng lỗi chuẩn OpenAI (xem Mã lỗi). Khi stream đã bắt đầu, lỗi đến dưới dạng sự kiện response.failed:
event: response.failed
data: {"type":"response.failed","response":{"status":"failed","error":{"code":"service_unavailable","message":"…"},…}}Tiền
Tính theo số token model thật sự dùng, giống /v1/chat/completions: ngắt kết nối giữa chừng chỉ tính phần đã sinh, request lỗi không trả nội dung thì không tính tiền.