Build Reliable Support Agents with the OpenAI API
Use the OpenAI Responses API with one read-only shipping function to answer shipment questions with verified records. Have your app check order ownership and pass only the fields needed for the reply. If customers only need a status field, use a tracking link or fixed template instead.

When a customer asks where their package is, your support agent needs a verified shipment record, not a plausible guess. Use the OpenAI Responses API with one read-only shipping function, and let your app control what runs and what the model sees. This setup suits teams that own their order API; skip it if a tracking page solves the problem or no one can maintain the integration.
Use a current model. As of December 2026, OpenAI’s deprecations page lists gpt-4.1-mini as shutting down on January 14, 2027, and names gpt-6-luna as the replacement. The gpt-6-luna model page says it supports the Responses API and function calling. Recheck those pages before you ship, because shutdown dates and recommended models change.
Know which limit you hit

Send requests to POST /v1/responses. The model proposes a custom function call; your middleware authorizes it, queries the shipping service, and returns only the fields needed for the reply. Unlike OpenAI-hosted tools such as File Search, your custom function runs in your app. ChatGPT product limits are separate from API limits.
| Bottleneck | What it measures | What to do |
|---|---|---|
| OpenAI model throttle | RPM counts requests; TPM counts tokens per minute | Queue calls and check the applicable model limits |
| OpenAI-hosted tool quota | A limit documented for the specific hosted tool, if one is enabled | Check that tool’s docs; this setup uses no hosted tools |
| Downstream API failure | A response from your shipping provider, such as a 429 or 503 | Log the source and apply the provider’s retry rules |
| Context overflow | Too much context for one model request, even at low traffic | Shrink the input while preserving required state |
Estimate the cost of one ticket

Use OpenAI’s API Pricing page for model token rates and any hosted-tool charges, and its Rate Limits guide for throughput limits. Count both model requests, including the function arguments the model generates and the filtered result it reads. Your shipping provider and middleware may have separate costs. Log token usage, tool attempts, and escalations per ticket so repeat work doesn’t disappear into an average.
Worked example (not a price quote for your account): Assume two model requests total 1,600 input and 200 output tokens, no cached-input discount, one shipping lookup at $0.002, no retries, and no hosted tools. On the gpt-6-luna model page as of December 2026, standard text tokens are $0.10 per million input and $0.50 per million output. That is about $0.00016 of input cost and $0.00010 of output cost, plus $0.002 for the lookup, or about $0.0023 per ticket before hosting or staff time. If the model uses reasoning tokens, output cost can be higher, so log actual usage. If 10% of tickets escalate and each escalation takes four minutes at $30/hour, that adds $0.20 in average labor per incoming ticket. Neither figure is realized savings: compare against the manual workflow and count review, rework, and maintenance.
Set up a shipping lookup you can reproduce
- Authorize the lookup. For “Where is order A123?” verify that the signed-in customer owns
A123. Keep identity and ownership in your app. If the order is missing or ambiguous, clarify before calling the tool. - Configure the first request. Put the customer’s question in
inputand use this configuration:
{
"model": "gpt-6-luna",
"store": false,
"instructions": "Use only validated shipping fields. Never guess a tracking number or date. Label estimated dates as estimates. If lookup fails, say you could not confirm the shipment status.",
"tools": [{"type":"function","name":"get_shipping_status","description":"Look up one authorized order.","strict":true,"parameters":{"type":"object","properties":{"order_id":{"type":"string"}},"required":["order_id"],"additionalProperties":false}}],
"tool_choice": {"type":"function","name":"get_shipping_status"},
"parallel_tool_calls": false,
"max_output_tokens": 200
}- Validate and filter in middleware. Allow one logical tool call per turn. Before execution, require the exact registered name and valid JSON matching the schema; reject any order ID other than the authorized one. Suppose the provider returns
{"order_id":"A123","status":"in_transit","tracking_number":"TRK12345","estimated_delivery":"2026-12-04","address":"18 Oak St","internal_notes":"label reprinted"}. Verify the order matches, check the status against your supported values, and send only{"status":"in_transit","tracking_number":"TRK12345","estimated_delivery":"2026-12-04"}. Check the tracking number against the carrier’s format and the date against your expected format and calendar; set missing or invalid optional fields tonull. Reject mismatched orders or invalid statuses and return a sanitized lookup error. - Write and check the reply. With
store: false, build the second request with the same model, instructions, and output cap, but omit tools and tool choice. Carry forward the relevant input, the first response’s output items, and afunction_call_outputwith the matchingcall_idand filtered JSON serialized asoutput. Preserve clarified order references across turns without replaying raw records. Expected reply: “Your order is in transit. The estimated delivery date is December 4, 2026. Your tracking number is TRK12345.” Test that null fields are omitted and the reply never upgrades an estimate to a promise. If exact wording matters, render validated fields with a template instead.
Retry without repeating side effects

Retry transient throttles or service failures, not exhausted billing quota, invalid arguments, or authorization failures. Honor Retry-After when present; otherwise use capped exponential backoff with jitter. Stop at your retry or time budget and offer a handoff rather than leaving the customer waiting. If you later add refunds, persist an idempotency key per approved refund and reuse it on retries; after an ambiguous timeout, reconcile the original outcome before attempting another write.
Copy this release checklist
- [ ] Enforce [max tool calls], [tool output budget], and [retry budget].
- [ ] Test [missing field], [wrong order], and [provider timeout].
- [ ] Set a billing alert at [alert amount]; enforce [spend cap] in your app rather than treating the alert as a cutoff.
- [ ] Check customer-data retention and training use in OpenAI’s API data controls and your own logs.
- [ ] Reduce lock-in: keep authorization, schemas, and [test cases] outside the model integration.
Choose the simplest workflow that fits
Choose the Responses API if customers ask in free text and your team can maintain the middleware. Pick a tracking link or fixed template if customers only need a status field. Start with step 3: run the sample record through your filter and confirm the address and notes never reach the model.
Related resources
Frequently Asked Questions
Does a smaller tool result fix every 429?
No. It reduces token load but does not reduce request count or change the shipping provider’s quota.
What if the delivery date is missing?
Omit it from the reply and report only the verified fields.
Where does the custom shipping function run?
It runs in your app. Your middleware authorizes the call, queries the shipping service, and returns only the fields needed for the reply.
When should the app retry a request?
Retry transient throttles or service failures, not exhausted billing quota, invalid arguments, or authorization failures. Honor Retry-After when present and stop at your retry or time budget.
Get the Weekly SMB AI & SaaS Brief
Practical software benchmarks, prompt templates, and ROI breakdowns delivered every Tuesday. No fluff, unsubscribe anytime.