A timeout in a text-generation client creates an awkward question: did the request fail before it reached the provider, or did the response get lost after processing?
An immediate retry with a new request ID can turn that uncertainty into duplicate work. A small onboarding client should make the safe path obvious.
Disclosure: this post is part of API Many's onboarding work, published by the team behind the product portfolio. It was prepared by an AI agent. The example was checked against the public API contract and local mock tests; no live paid inference was performed for this article. API Many is an independent service, not an official model-provider SDK.
Start with a tiny, checkable task
Instead of an impressive but hard-to-evaluate prompt, use fictional project notes:
The prototype review is scheduled for Thursday.
Maya will check keyboard navigation before the review.
A decision about the export format has not been made.
Ask for three short bullets. You can then check three things without a benchmark suite:
- Did the date survive?
- Did the ownership of the accessibility task survive?
- Did the model preserve the unresolved decision instead of inventing one?
A non-empty response is a transport signal. A faithful summary is a useful result. Those are different checks.
Persist intent before making the request
The small Node.js starter uses built-in Node APIs, with no package installation required.
git clone https://github.com/weidacn/ai-api-workflow-starters.git
cd ai-api-workflow-starters
node --test test/*.test.mjs
Use Node.js 22 or newer. Create your API key in the product console and set APIMANY_API_KEY through your normal server-side secret handling. Do not put the value in a public repository, screenshot, browser bundle, or issue.
Discover the currently enabled models first:
node apimany/run.mjs discover
Choose an exact ID returned with operation: chat.completions. A model listed in an article or on a marketing page is not a promise that your account can call it.
Next, prepare the request offline:
node apimany/run.mjs prepare apimany/notes.txt openai/gpt-5.4-mini private-runs/summary-01.json
node apimany/run.mjs inspect private-runs/summary-01.json
The model ID above is a documented example; use it only when discovery returns it. prepare writes the payload and a unique idempotency key to an owner-only local file. inspect retrieves the current model contract and price without starting generation.
Make the chargeable step explicit
Only after checking the price and available balance:
node apimany/run.mjs submit private-runs/summary-01.json --confirm-paid
This can consume account balance. There is no free-call promise or automatic top-up.
The request contains ordinary text messages, stream: false, and a 180-token output ceiling. It does not assume support for tools, structured output, streaming, or multimodal inputs.
The starter saves submitting before the POST. A verified response produces a saved receipt. If the response is missing or ambiguous, the state becomes uncertain and the command stops.
prepared -> submitting -> received
-> uncertain -> stop and reconcile
Re-running submit on that file deliberately refuses to send another request. Keep the original request ID and payload. An idempotency mechanism is not permission to blindly create a fresh logical request every time a timeout occurs.
Test the uncomfortable branches
The repository includes mock tests for:
- an absent or incompatible model;
- an explicit acknowledgement before the chargeable step;
- exactly one submission attempt;
- uncertainty persisted without automatic replay;
- upstream error bodies not being echoed into logs;
- asynchronous job polling without resubmission in the companion video example.
These tests verify client behavior, not provider uptime or generation quality. A real deployment still needs its own end-to-end check.
Finally, compare the summary with the source notes and reconcile the request with the console. Token usage is not independently a USD billing receipt.
If you try the example, feedback on the first point where the workflow becomes unclear is more useful than a star. Report a redacted error and request ID—not your key or private input—to support@apimany.com.
Top comments (0)