Design an Integration Using the Chat Completions API
This use case demonstrates how to design an integration when using the Chat Completions API. The Chat Completions API enables you to call multiple LLMs (OpenAI, Anthropic, and Azure). This use case also provides an overview of the mapper differences between the Chat Completions API and Responses API input and output profiles.
Note:
The Chat Completions API makes no distinction between simple and extended prompts. By default, there is just an extended prompt. This differs from the Responses API, which provides both simple and extended prompts.- Configure a REST Adapter trigger connection.
- Configure an OpenAI Adapter invoke connection.
- Create an application integration.
- Drag the REST Adapter trigger connection into the integration
canvas and configure it. For this example, the adapter is configured as follows:
- A REST Service URL of
/extendedis specified for this example. - A Method of POST is selected.
- Configure a request payload for this endpoint and Configure this endpoint to receive the response are selected.
- A Request Media Type of
JSON is selected and the following sample JSON structure is
specified:
{ "previous_response_id" : "resp_67fcf9d44a441592841b47ff452bb2c40f3934e820b8b734", "messages" : [ { "role" : "user", "content" : "What is the weather like in Boston today?", "id" : "fc_59976d15c16c8192bfd40ea202148e2709a262500b6fb5c2", "type" : "function_call", "status" : "completed", "arguments" : "{\"document_name\":\"R010\"}", "call_id" : "call_MUbVuvEfzFkwFwD30ZiBQCUg", "name" : "classify_document", "output" : "receipts" }, { "role" : "user", "content" : "What is the weather like in Boston today?", "id" : "fc_59976d15c16c8192bfd40ea202148e2709a262500b6fb5c2", "type" : "function_call", "status" : "completed", "arguments" : "{\"document_name\":\"R010\"}", "call_id" : "call_MUbVuvEfzFkwFwD30ZiBQCUg", "name" : "classify_document", "output" : "receipts" } ], "tools" : "[ {\r\n \"type\" : \"function\",\r\n \"name\" : \"classify_document\",\r\n \"description\" : \"classifies document whether its item reciept or invoice\",\r\n \"parameters\" : {\r\n \"type\" : \"object\",\r\n \"required\" : [ \"document_name\"],\r\n \"properties\" : {\r\n \"document_name\" : {\r\n \"type\" : \"string\",\r\n \"description\" : \"This tells the document name\"\r\n }\r\n }\r\n }\r\n }, {\r\n \"type\" : \"function\",\r\n \"name\" : \"extract_receipt_data\",\r\n \"description\" : \"Extracts Receipt data\",\r\n \"parameters\" : {\r\n \"type\" : \"object\",\r\n \"required\" : [ \"receipt_id\"],\r\n \"properties\" : {\r\n \"receipt_id\" : {\r\n \"type\" : \"string\",\r\n \"description\" : \"the receipt id to extract.\"\r\n }\r\n }\r\n }\r\n }, {\r\n \"type\" : \"function\",\r\n \"name\" : \"rag_retrieval\",\r\n \"description\" : \"Extracts Receipt data\",\r\n \"parameters\" : {\r\n \"type\" : \"object\",\r\n \"properties\" : {\r\n \"question\" : {\r\n \"type\" : \"string\",\r\n \"description\" : \"The user's query.\"\r\n },\r\n \"collection_name\" : {\r\n \"type\" : \"string\",\r\n \"description\" : \"Name of the ChromaDB collection.\",\r\n \"default\" : \"oracle_integration_documents\",\r\n \"enum\" : [ \"oracle_integration_documents\", \"expense_report_policy_documents\" ]\r\n }\r\n },\r\n \"required\" : [ \"question\"]\r\n }\r\n }, {\r\n \"type\" : \"function\",\r\n \"name\" : \"create_expense_report\",\r\n \"description\" : \"This tool creates expense report\",\r\n \"parameters\" : {\r\n \"type\" : \"object\",\r\n \"properties\" : {\r\n \"amount\" : {\r\n \"type\" : \"string\",\r\n \"description\" : \"recipt expense amount\"\r\n }\r\n },\r\n \"required\" : [ \"amount\" ]\r\n }\r\n } ]" } - A Response Media Type of
JSON is selected and the following sample JSON structure is
specified:
{ "id" : "resp_68109ae7dd748192a3b562b362fa7e3104b7fafa5b45e5a9", "object" : "response", "created_at" : 1745918695, "status" : "completed", "error" : null, "incomplete_details" : null, "instructions" : null, "max_output_tokens" : null, "model" : "gpt-3.5-turbo-0125", "output" : [ { "id" : "fc_68109aed4f9881928817969dfa1f0fcc04b7fafa5b45e5a9", "type" : "function_call", "status" : "completed", "arguments" : "{\"location\":\"Boston, MA\",\"unit\":\"celsius\"}", "call_id" : "call_C65f116qkbd246rHQAnftPcf", "name" : "get_current_weather" } ], "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" : [ { "type" : "function", "name" : "classify_document", "description" : "classifies document whether its item reciept or invoice", "parameters" : { "type" : "object", "properties" : { "document_name" : { "type" : "string", "description" : "This tells the document name" } }, "required" : [ "document_name" ] }, "strict" : true }, { "type" : "function", "name" : "extract_receipt_data", "description" : "Extracts Receipt data", "parameters" : { "type" : "object", "properties" : { "receipt_id" : { "type" : "string", "description" : "the receipt id to extract." } }, "required" : [ "receipt_id" ] }, "strict" : true } ], "top_p" : 1.0, "truncation" : "disabled", "usage" : { "input_tokens" : 86, "input_tokens_details" : { "cached_tokens" : 0 }, "output_tokens" : 23, "output_tokens_details" : { "reasoning_tokens" : 0 }, "total_tokens" : 109 }, "user" : "myuser" }
- A REST Service URL of
- Drag the OpenAI Adapter invoke connection into the integration canvas.
- On the Basic Info page, select Chat completions API from the Action list.
- On the Summary page, click Finish.
- Open the request mapper.
- In the request mapper, map source elements to target elements. There are differences
with how the payload is handled between the Chat Completions API and the Responses
API:
- With the Chat Completions API, target subelements such as Role and Content are mapped under the Messages element. This differs from the Responses API, where target subelements such as Role and Content are mapped under the Input element.
- The target Tool Calls element handles subsequent prompt calls where your response is dependent on another tool. For example, in the first prompt, you get the type of document by calling the document tool. For the second prompt, you want to create an expense report. You call the expense report tool based on the existing document tool call. An ID value is used to call the next prompt. The target Tool Calls element is similar to the target Functions element available with the Responses API.

- In the response mapper, map source elements to target elements. There are differences
with how the payload is handled between the Chat Completions API and the Responses
API:
- Under the source Body element are the Choices, Message, and Tool Calls subelements. This differs from the Responses API, where the sources Output and Function are used.

- Complete integration design, then activate the integration.

- Run the integration from the Configure and run page, then view your results.